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

Dependencies:   MaximTinyTester MAX11131 CmdLine MAX541 USBDevice

Committer:
whismanoid
Date:
Tue Aug 13 16:29:59 2019 -0700
Revision:
23:cebc8b06c25e
Parent:
22:0ae9ebdd471b
Child:
24:38d2bef2bcdb
CmdLine optional diagnostic_led_EOF() handler

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 0:3edb3708c8c5 1 /*******************************************************************************
whismanoid 0:3edb3708c8c5 2 * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 0:3edb3708c8c5 3 *
whismanoid 0:3edb3708c8c5 4 * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 0:3edb3708c8c5 5 * copy of this software and associated documentation files (the "Software"),
whismanoid 0:3edb3708c8c5 6 * to deal in the Software without restriction, including without limitation
whismanoid 0:3edb3708c8c5 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 0:3edb3708c8c5 8 * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 0:3edb3708c8c5 9 * Software is furnished to do so, subject to the following conditions:
whismanoid 0:3edb3708c8c5 10 *
whismanoid 0:3edb3708c8c5 11 * The above copyright notice and this permission notice shall be included
whismanoid 0:3edb3708c8c5 12 * in all copies or substantial portions of the Software.
whismanoid 0:3edb3708c8c5 13 *
whismanoid 0:3edb3708c8c5 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 0:3edb3708c8c5 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 0:3edb3708c8c5 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 0:3edb3708c8c5 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 0:3edb3708c8c5 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 0:3edb3708c8c5 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 0:3edb3708c8c5 20 * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 0:3edb3708c8c5 21 *
whismanoid 0:3edb3708c8c5 22 * Except as contained in this notice, the name of Maxim Integrated
whismanoid 0:3edb3708c8c5 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 0:3edb3708c8c5 24 * Products, Inc. Branding Policy.
whismanoid 0:3edb3708c8c5 25 *
whismanoid 0:3edb3708c8c5 26 * The mere transfer of this software does not imply any licenses
whismanoid 0:3edb3708c8c5 27 * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 0:3edb3708c8c5 28 * trademarks, maskwork rights, or any other form of intellectual
whismanoid 0:3edb3708c8c5 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 0:3edb3708c8c5 30 * ownership rights.
whismanoid 0:3edb3708c8c5 31 *******************************************************************************
whismanoid 0:3edb3708c8c5 32 */
whismanoid 0:3edb3708c8c5 33
whismanoid 0:3edb3708c8c5 34 // Test fixture and application menu for breakout boards:
whismanoid 0:3edb3708c8c5 35 // - MAX5715BOB
whismanoid 0:3edb3708c8c5 36 // - MAX11131BOB
whismanoid 0:3edb3708c8c5 37 // - MAX5171BOB
whismanoid 0:3edb3708c8c5 38 // Platforms:
whismanoid 0:3edb3708c8c5 39 // - MAX32625MBED
whismanoid 14:93dbe154f46b 40 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 18:6d02d823fd7a 41 // - remove max32630fthr library (if present)
whismanoid 18:6d02d823fd7a 42 // - remove MAX32620FTHR library (if present)
whismanoid 14:93dbe154f46b 43 // - MAX32600MBED
whismanoid 18:6d02d823fd7a 44 // - remove max32630fthr library (if present)
whismanoid 18:6d02d823fd7a 45 // - remove MAX32620FTHR library (if present)
whismanoid 0:3edb3708c8c5 46 // - NUCLEO_F446RE
whismanoid 14:93dbe154f46b 47 // - remove USBDevice library
whismanoid 18:6d02d823fd7a 48 // - remove max32630fthr library (if present)
whismanoid 18:6d02d823fd7a 49 // - remove MAX32620FTHR library (if present)
whismanoid 0:3edb3708c8c5 50 // - NUCLEO_F401RE
whismanoid 14:93dbe154f46b 51 // - remove USBDevice library
whismanoid 18:6d02d823fd7a 52 // - remove max32630fthr library (if present)
whismanoid 18:6d02d823fd7a 53 // - remove MAX32620FTHR library (if present)
whismanoid 14:93dbe154f46b 54 // - MAX32630FTHR
whismanoid 18:6d02d823fd7a 55 // - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 18:6d02d823fd7a 56 // - remove MAX32620FTHR library (if present)
whismanoid 18:6d02d823fd7a 57 // - MAX32620FTHR
whismanoid 18:6d02d823fd7a 58 // - remove max32630fthr library (if present)
whismanoid 18:6d02d823fd7a 59 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 18:6d02d823fd7a 60 // - not tested yet
whismanoid 18:6d02d823fd7a 61 // - MAX32625PICO
whismanoid 18:6d02d823fd7a 62 // - remove max32630fthr library (if present)
whismanoid 18:6d02d823fd7a 63 // - remove MAX32620FTHR library (if present)
whismanoid 18:6d02d823fd7a 64 // - not tested yet
whismanoid 0:3edb3708c8c5 65
whismanoid 0:3edb3708c8c5 66 #include "mbed.h"
whismanoid 17:c2f46173f6b2 67 // mbed shared event queue run onTimerTick() in Thread context not Interrupt context
whismanoid 17:c2f46173f6b2 68 #include "mbed_events.h"
whismanoid 0:3edb3708c8c5 69 #if defined(TARGET)
whismanoid 0:3edb3708c8c5 70 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 0:3edb3708c8c5 71 // Create a string definition for the TARGET
whismanoid 0:3edb3708c8c5 72 #define STRING_ARG(arg) #arg
whismanoid 0:3edb3708c8c5 73 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 0:3edb3708c8c5 74 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 12:28aca24adc15 75 #elif defined(TARGET_MAX32600)
whismanoid 12:28aca24adc15 76 #define TARGET_NAME "MAX32600"
whismanoid 0:3edb3708c8c5 77 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 78 #define TARGET_NAME "LPC1768"
whismanoid 0:3edb3708c8c5 79 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 80 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 0:3edb3708c8c5 81 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 82 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 0:3edb3708c8c5 83 #else
whismanoid 0:3edb3708c8c5 84 #error TARGET NOT DEFINED
whismanoid 0:3edb3708c8c5 85 #endif
whismanoid 0:3edb3708c8c5 86 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 87 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 88 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 0:3edb3708c8c5 89 // +-------------[microUSB]-------------+
whismanoid 0:3edb3708c8c5 90 // | J1 MAX32630FTHR J2 |
whismanoid 0:3edb3708c8c5 91 // ______ | [ ] RST GND [ ] |
whismanoid 0:3edb3708c8c5 92 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 0:3edb3708c8c5 93 // ______ | [ ] 1V8 reset SW1 |
whismanoid 0:3edb3708c8c5 94 // ______ | [ ] GND J4 J3 |
whismanoid 0:3edb3708c8c5 95 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 0:3edb3708c8c5 96 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 0:3edb3708c8c5 97 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 14:93dbe154f46b 98 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 14:93dbe154f46b 99 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 14:93dbe154f46b 100 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 14:93dbe154f46b 101 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 14:93dbe154f46b 102 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 14:93dbe154f46b 103 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 14:93dbe154f46b 104 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 14:93dbe154f46b 105 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 14:93dbe154f46b 106 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 0:3edb3708c8c5 107 // | |
whismanoid 0:3edb3708c8c5 108 // | XIP Flash MAX14690N |
whismanoid 0:3edb3708c8c5 109 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 0:3edb3708c8c5 110 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 0:3edb3708c8c5 111 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 0:3edb3708c8c5 112 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 0:3edb3708c8c5 113 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 0:3edb3708c8c5 114 // | XIP_DIO3 P1_5 |
whismanoid 0:3edb3708c8c5 115 // | |
whismanoid 0:3edb3708c8c5 116 // | PAN1326B MicroSD LED |
whismanoid 0:3edb3708c8c5 117 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 0:3edb3708c8c5 118 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 0:3edb3708c8c5 119 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 0:3edb3708c8c5 120 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 0:3edb3708c8c5 121 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 0:3edb3708c8c5 122 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 0:3edb3708c8c5 123 // +------------------------------------+
whismanoid 0:3edb3708c8c5 124 // MAX32630FTHR board has MAX14690 PMIC on I2C bus (P5_7 SDA, P6_0 SCL) at slave address 0101_000r 0x50 (or 0x28 for 7 MSbit address).
whismanoid 0:3edb3708c8c5 125 // MAX32630FTHR board has BMI160 accelerometer on I2C bus (P5_7 SDA, P6_0 SCL) at slave address 1101_000r 0xD0 (or 0x68 for 7 MSbit address).
whismanoid 0:3edb3708c8c5 126 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 127 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 128 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 129 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 130 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 131 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 132 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 133 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 134 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 135 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:3edb3708c8c5 136 // AIN_10 = x undefined?
whismanoid 0:3edb3708c8c5 137 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 138 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 139 //
whismanoid 0:3edb3708c8c5 140 #include "max32630fthr.h"
whismanoid 0:3edb3708c8c5 141 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:3edb3708c8c5 142 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:3edb3708c8c5 143 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:3edb3708c8c5 144 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 14:93dbe154f46b 145 // Arduino connector
whismanoid 14:93dbe154f46b 146 #ifndef A0
whismanoid 14:93dbe154f46b 147 #define A0 AIN_0
whismanoid 14:93dbe154f46b 148 #endif
whismanoid 14:93dbe154f46b 149 #ifndef A1
whismanoid 14:93dbe154f46b 150 #define A1 AIN_1
whismanoid 14:93dbe154f46b 151 #endif
whismanoid 14:93dbe154f46b 152 #ifndef A2
whismanoid 14:93dbe154f46b 153 #define A2 AIN_2
whismanoid 14:93dbe154f46b 154 #endif
whismanoid 14:93dbe154f46b 155 #ifndef A3
whismanoid 14:93dbe154f46b 156 #define A3 AIN_3
whismanoid 14:93dbe154f46b 157 #endif
whismanoid 14:93dbe154f46b 158 #ifndef D0
whismanoid 14:93dbe154f46b 159 #define D0 P4_0
whismanoid 14:93dbe154f46b 160 #endif
whismanoid 14:93dbe154f46b 161 #ifndef D1
whismanoid 14:93dbe154f46b 162 #define D1 P5_6
whismanoid 14:93dbe154f46b 163 #endif
whismanoid 14:93dbe154f46b 164 #ifndef D2
whismanoid 14:93dbe154f46b 165 #define D2 P5_5
whismanoid 14:93dbe154f46b 166 #endif
whismanoid 14:93dbe154f46b 167 #ifndef D3
whismanoid 14:93dbe154f46b 168 #define D3 P5_4
whismanoid 14:93dbe154f46b 169 #endif
whismanoid 14:93dbe154f46b 170 #ifndef D4
whismanoid 14:93dbe154f46b 171 #define D4 P5_3
whismanoid 14:93dbe154f46b 172 #endif
whismanoid 14:93dbe154f46b 173 #ifndef D5
whismanoid 14:93dbe154f46b 174 #define D5 P3_3
whismanoid 14:93dbe154f46b 175 #endif
whismanoid 14:93dbe154f46b 176 #ifndef D6
whismanoid 14:93dbe154f46b 177 #define D6 P3_2
whismanoid 14:93dbe154f46b 178 #endif
whismanoid 14:93dbe154f46b 179 #ifndef D7
whismanoid 14:93dbe154f46b 180 #define D7 P3_5
whismanoid 14:93dbe154f46b 181 #endif
whismanoid 14:93dbe154f46b 182 #ifndef D8
whismanoid 14:93dbe154f46b 183 #define D8 P3_4
whismanoid 14:93dbe154f46b 184 #endif
whismanoid 14:93dbe154f46b 185 #ifndef D9
whismanoid 14:93dbe154f46b 186 #define D9 P3_1
whismanoid 14:93dbe154f46b 187 #endif
whismanoid 14:93dbe154f46b 188 #ifndef D10
whismanoid 14:93dbe154f46b 189 #define D10 P3_0
whismanoid 14:93dbe154f46b 190 #endif
whismanoid 14:93dbe154f46b 191 #ifndef D11
whismanoid 14:93dbe154f46b 192 #define D11 P5_1
whismanoid 14:93dbe154f46b 193 #endif
whismanoid 14:93dbe154f46b 194 #ifndef D12
whismanoid 14:93dbe154f46b 195 #define D12 P5_2
whismanoid 14:93dbe154f46b 196 #endif
whismanoid 14:93dbe154f46b 197 #ifndef D13
whismanoid 14:93dbe154f46b 198 #define D13 P5_0
whismanoid 14:93dbe154f46b 199 #endif
whismanoid 0:3edb3708c8c5 200 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 201 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 202 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 203 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:3edb3708c8c5 204 // +-------------------------------------+
whismanoid 0:3edb3708c8c5 205 // | MAX32625MBED Arduino UNO header |
whismanoid 0:3edb3708c8c5 206 // | |
whismanoid 0:3edb3708c8c5 207 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:3edb3708c8c5 208 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:3edb3708c8c5 209 // | AREF=N/C[ ] |
whismanoid 0:3edb3708c8c5 210 // | GND[ ] |
whismanoid 0:3edb3708c8c5 211 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:3edb3708c8c5 212 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:3edb3708c8c5 213 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:3edb3708c8c5 214 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:3edb3708c8c5 215 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:3edb3708c8c5 216 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:3edb3708c8c5 217 // | [ ]GND |
whismanoid 0:3edb3708c8c5 218 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:3edb3708c8c5 219 // | 6[ ]~| P0_6 dig6
whismanoid 0:3edb3708c8c5 220 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:3edb3708c8c5 221 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:3edb3708c8c5 222 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:3edb3708c8c5 223 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:3edb3708c8c5 224 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:3edb3708c8c5 225 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:3edb3708c8c5 226 // | [ ] [ ] [ ] |
whismanoid 0:3edb3708c8c5 227 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:3edb3708c8c5 228 // \_______________________/
whismanoid 0:3edb3708c8c5 229 //
whismanoid 0:3edb3708c8c5 230 // +------------------------+
whismanoid 0:3edb3708c8c5 231 // | |
whismanoid 0:3edb3708c8c5 232 // | MicroSD LED |
whismanoid 0:3edb3708c8c5 233 // | SD_SCLK P2_4 r P3_0 |
whismanoid 0:3edb3708c8c5 234 // | SD_MOSI P2_5 g P3_1 |
whismanoid 0:3edb3708c8c5 235 // | SD_MISO P2_6 b P3_2 |
whismanoid 0:3edb3708c8c5 236 // | SD_SSEL P2_7 y P3_3 |
whismanoid 0:3edb3708c8c5 237 // | |
whismanoid 0:3edb3708c8c5 238 // | DAPLINK BUTTONS |
whismanoid 0:3edb3708c8c5 239 // | TX P2_1 SW3 P2_3 |
whismanoid 0:3edb3708c8c5 240 // | RX P2_0 SW2 P2_2 |
whismanoid 0:3edb3708c8c5 241 // +------------------------+
whismanoid 0:3edb3708c8c5 242 //
whismanoid 0:3edb3708c8c5 243 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 244 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 245 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 246 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 247 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 248 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 249 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 250 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 251 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 252 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:3edb3708c8c5 253 // AIN_10 = x undefined?
whismanoid 0:3edb3708c8c5 254 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 255 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 256 //
whismanoid 0:3edb3708c8c5 257 //#include "max32625mbed.h" // ?
whismanoid 0:3edb3708c8c5 258 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 0:3edb3708c8c5 259 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:3edb3708c8c5 260 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:3edb3708c8c5 261 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:3edb3708c8c5 262 // Arduino connector
whismanoid 0:3edb3708c8c5 263 #ifndef A0
whismanoid 0:3edb3708c8c5 264 #define A0 AIN_0
whismanoid 0:3edb3708c8c5 265 #endif
whismanoid 0:3edb3708c8c5 266 #ifndef A1
whismanoid 0:3edb3708c8c5 267 #define A1 AIN_1
whismanoid 0:3edb3708c8c5 268 #endif
whismanoid 0:3edb3708c8c5 269 #ifndef A2
whismanoid 0:3edb3708c8c5 270 #define A2 AIN_2
whismanoid 0:3edb3708c8c5 271 #endif
whismanoid 0:3edb3708c8c5 272 #ifndef A3
whismanoid 0:3edb3708c8c5 273 #define A3 AIN_3
whismanoid 0:3edb3708c8c5 274 #endif
whismanoid 0:3edb3708c8c5 275 #ifndef D0
whismanoid 0:3edb3708c8c5 276 #define D0 P0_0
whismanoid 0:3edb3708c8c5 277 #endif
whismanoid 0:3edb3708c8c5 278 #ifndef D1
whismanoid 0:3edb3708c8c5 279 #define D1 P0_1
whismanoid 0:3edb3708c8c5 280 #endif
whismanoid 0:3edb3708c8c5 281 #ifndef D2
whismanoid 0:3edb3708c8c5 282 #define D2 P0_2
whismanoid 0:3edb3708c8c5 283 #endif
whismanoid 0:3edb3708c8c5 284 #ifndef D3
whismanoid 0:3edb3708c8c5 285 #define D3 P0_3
whismanoid 0:3edb3708c8c5 286 #endif
whismanoid 0:3edb3708c8c5 287 #ifndef D4
whismanoid 0:3edb3708c8c5 288 #define D4 P0_4
whismanoid 0:3edb3708c8c5 289 #endif
whismanoid 0:3edb3708c8c5 290 #ifndef D5
whismanoid 0:3edb3708c8c5 291 #define D5 P0_5
whismanoid 0:3edb3708c8c5 292 #endif
whismanoid 0:3edb3708c8c5 293 #ifndef D6
whismanoid 0:3edb3708c8c5 294 #define D6 P0_6
whismanoid 0:3edb3708c8c5 295 #endif
whismanoid 0:3edb3708c8c5 296 #ifndef D7
whismanoid 0:3edb3708c8c5 297 #define D7 P0_7
whismanoid 0:3edb3708c8c5 298 #endif
whismanoid 0:3edb3708c8c5 299 #ifndef D8
whismanoid 0:3edb3708c8c5 300 #define D8 P1_4
whismanoid 0:3edb3708c8c5 301 #endif
whismanoid 0:3edb3708c8c5 302 #ifndef D9
whismanoid 0:3edb3708c8c5 303 #define D9 P1_5
whismanoid 0:3edb3708c8c5 304 #endif
whismanoid 0:3edb3708c8c5 305 #ifndef D10
whismanoid 0:3edb3708c8c5 306 #define D10 P1_3
whismanoid 0:3edb3708c8c5 307 #endif
whismanoid 0:3edb3708c8c5 308 #ifndef D11
whismanoid 0:3edb3708c8c5 309 #define D11 P1_1
whismanoid 0:3edb3708c8c5 310 #endif
whismanoid 0:3edb3708c8c5 311 #ifndef D12
whismanoid 0:3edb3708c8c5 312 #define D12 P1_2
whismanoid 0:3edb3708c8c5 313 #endif
whismanoid 0:3edb3708c8c5 314 #ifndef D13
whismanoid 0:3edb3708c8c5 315 #define D13 P1_0
whismanoid 0:3edb3708c8c5 316 #endif
whismanoid 0:3edb3708c8c5 317 //--------------------------------------------------
whismanoid 12:28aca24adc15 318 #elif defined(TARGET_MAX32600)
whismanoid 12:28aca24adc15 319 // target MAX32600
whismanoid 12:28aca24adc15 320 //
whismanoid 12:28aca24adc15 321 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 12:28aca24adc15 322 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 12:28aca24adc15 323 //
whismanoid 12:28aca24adc15 324 //--------------------------------------------------
whismanoid 17:c2f46173f6b2 325 #elif defined(TARGET_MAX32620FTHR)
whismanoid 17:c2f46173f6b2 326 #warning "TARGET_MAX32620FTHR not previously tested; need to define pins..."
whismanoid 18:6d02d823fd7a 327 #include "MAX32620FTHR.h"
whismanoid 18:6d02d823fd7a 328 // Initialize I/O voltages on MAX32620FTHR board
whismanoid 18:6d02d823fd7a 329 MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3);
whismanoid 17:c2f46173f6b2 330 //#define USE_LEDS 0 ?
whismanoid 17:c2f46173f6b2 331 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 17:c2f46173f6b2 332 #warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 17:c2f46173f6b2 333 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 17:c2f46173f6b2 334 //
whismanoid 17:c2f46173f6b2 335 //--------------------------------------------------
whismanoid 17:c2f46173f6b2 336 #elif defined(TARGET_MAX32625PICO)
whismanoid 17:c2f46173f6b2 337 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 17:c2f46173f6b2 338 //#define USE_LEDS 0 ?
whismanoid 17:c2f46173f6b2 339 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 19:8e81fd761a62 340 #warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 17:c2f46173f6b2 341 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 17:c2f46173f6b2 342 //
whismanoid 17:c2f46173f6b2 343 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 344 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 345 // TODO1: target NUCLEO_F446RE
whismanoid 0:3edb3708c8c5 346 //
whismanoid 0:3edb3708c8c5 347 // USER_BUTTON PC13
whismanoid 0:3edb3708c8c5 348 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 0:3edb3708c8c5 349 #define USE_LEDS 0
whismanoid 0:3edb3708c8c5 350 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 8:132276960128 351 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 0:3edb3708c8c5 352 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:3edb3708c8c5 353 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:3edb3708c8c5 354 //
whismanoid 0:3edb3708c8c5 355 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 356 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 357 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 358 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 0:3edb3708c8c5 359 // +-------------[microUSB]-------------+
whismanoid 0:3edb3708c8c5 360 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 0:3edb3708c8c5 361 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 0:3edb3708c8c5 362 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 0:3edb3708c8c5 363 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 0:3edb3708c8c5 364 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 0:3edb3708c8c5 365 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 0:3edb3708c8c5 366 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 0:3edb3708c8c5 367 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 0:3edb3708c8c5 368 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 0:3edb3708c8c5 369 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 0:3edb3708c8c5 370 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 0:3edb3708c8c5 371 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 0:3edb3708c8c5 372 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 0:3edb3708c8c5 373 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 0:3edb3708c8c5 374 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 0:3edb3708c8c5 375 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 0:3edb3708c8c5 376 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 0:3edb3708c8c5 377 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 0:3edb3708c8c5 378 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 0:3edb3708c8c5 379 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 0:3edb3708c8c5 380 // +------------------------------------+
whismanoid 0:3edb3708c8c5 381 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 0:3edb3708c8c5 382 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 0:3edb3708c8c5 383 //
whismanoid 0:3edb3708c8c5 384 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 385 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 0:3edb3708c8c5 386 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:3edb3708c8c5 387 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 0:3edb3708c8c5 388 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:3edb3708c8c5 389 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 390 // unknown target
whismanoid 0:3edb3708c8c5 391 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 392 #endif // target definition
whismanoid 0:3edb3708c8c5 393
whismanoid 0:3edb3708c8c5 394
whismanoid 0:3edb3708c8c5 395 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 396 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 0:3edb3708c8c5 397 #ifndef APPLICATION_ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 398 #define APPLICATION_ArduinoPinsMonitor 1
whismanoid 0:3edb3708c8c5 399 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 400
whismanoid 0:3edb3708c8c5 401 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 402 // Support MAX5715BOB Breakout Board
whismanoid 0:3edb3708c8c5 403 #ifndef APPLICATION_MAX5715
whismanoid 5:a158b6246907 404 #define APPLICATION_MAX5715 0
whismanoid 0:3edb3708c8c5 405 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 406 #if APPLICATION_MAX5715 // header file
whismanoid 0:3edb3708c8c5 407 #include "MAX5715.h"
whismanoid 0:3edb3708c8c5 408 // suppress the I2C diagnostics, not relevant to this chip
whismanoid 0:3edb3708c8c5 409 #define HAS_I2C 0
whismanoid 0:3edb3708c8c5 410 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 411
whismanoid 0:3edb3708c8c5 412 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 413 // Support MAX11131BOB Breakout Board
whismanoid 0:3edb3708c8c5 414 #ifndef APPLICATION_MAX11131
whismanoid 5:a158b6246907 415 #define APPLICATION_MAX11131 1
whismanoid 0:3edb3708c8c5 416 #endif // APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 417 #if APPLICATION_MAX11131 // header file
whismanoid 0:3edb3708c8c5 418 #include "MAX11131.h"
whismanoid 0:3edb3708c8c5 419 // suppress the I2C diagnostics, not relevant to this chip
whismanoid 0:3edb3708c8c5 420 #define HAS_I2C 0
whismanoid 0:3edb3708c8c5 421 #endif // APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 422
whismanoid 0:3edb3708c8c5 423 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 424 // Support MAX5171BOB Breakout Board
whismanoid 0:3edb3708c8c5 425 #ifndef APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 426 #define APPLICATION_MAX5171 0
whismanoid 0:3edb3708c8c5 427 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 428 #if APPLICATION_MAX5171 // header file
whismanoid 0:3edb3708c8c5 429 #include "MAX5171.h"
whismanoid 0:3edb3708c8c5 430 // suppress the I2C diagnostics, not relevant to this chip
whismanoid 0:3edb3708c8c5 431 #define HAS_I2C 0
whismanoid 0:3edb3708c8c5 432 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 433
whismanoid 0:3edb3708c8c5 434 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 435 // Support MAX11410BOB Breakout Board (placeholder)
whismanoid 0:3edb3708c8c5 436 #ifndef APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 437 #define APPLICATION_MAX11410 0
whismanoid 0:3edb3708c8c5 438 #endif // APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 439 #if APPLICATION_MAX11410 // header file
whismanoid 0:3edb3708c8c5 440 #include "MAX11410.h"
whismanoid 16:09f10869b638 441 #define HAS_I2C 0
whismanoid 0:3edb3708c8c5 442 #endif // APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 443
whismanoid 0:3edb3708c8c5 444 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 445 // Support MAX12345BOB Breakout Board (placeholder)
whismanoid 0:3edb3708c8c5 446 #ifndef APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 447 #define APPLICATION_MAX12345 0
whismanoid 0:3edb3708c8c5 448 #endif // APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 449 #if APPLICATION_MAX12345 // header file
whismanoid 0:3edb3708c8c5 450 #include "MAX12345.h"
whismanoid 16:09f10869b638 451 #define HAS_I2C 0
whismanoid 0:3edb3708c8c5 452 #endif // APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 453
whismanoid 0:3edb3708c8c5 454
whismanoid 0:3edb3708c8c5 455 #include "MAX541.h"
whismanoid 0:3edb3708c8c5 456
whismanoid 0:3edb3708c8c5 457 #include "MaximTinyTester.h"
whismanoid 0:3edb3708c8c5 458
whismanoid 0:3edb3708c8c5 459 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 460 // Option to dedicate SPI port pins
whismanoid 0:3edb3708c8c5 461 //
whismanoid 0:3edb3708c8c5 462 // SPI2_MOSI = P5_1
whismanoid 0:3edb3708c8c5 463 // SPI2_MISO = P5_2
whismanoid 0:3edb3708c8c5 464 // SPI2_SCK = P5_0
whismanoid 0:3edb3708c8c5 465 // On this board I'm using P3_0 as spi_cs
whismanoid 0:3edb3708c8c5 466 // SPI2_SS = P5_3
whismanoid 0:3edb3708c8c5 467 // SPI2_SDIO2 = P5_4
whismanoid 0:3edb3708c8c5 468 // SPI2_SDIO3 = P5_5
whismanoid 0:3edb3708c8c5 469 // SPI2_SRN = P5_6
whismanoid 0:3edb3708c8c5 470 //
whismanoid 0:3edb3708c8c5 471 #ifndef HAS_SPI
whismanoid 0:3edb3708c8c5 472 #define HAS_SPI 1
whismanoid 0:3edb3708c8c5 473 #endif
whismanoid 0:3edb3708c8c5 474 #if HAS_SPI
whismanoid 0:3edb3708c8c5 475 #define SPI_MODE0 0
whismanoid 0:3edb3708c8c5 476 #define SPI_MODE1 1
whismanoid 0:3edb3708c8c5 477 #define SPI_MODE2 2
whismanoid 0:3edb3708c8c5 478 #define SPI_MODE3 3
whismanoid 0:3edb3708c8c5 479 //
whismanoid 0:3edb3708c8c5 480 // Define application-specific default SPI_SCLK_Hz and SPI_dataMode
whismanoid 0:3edb3708c8c5 481 #if APPLICATION_MAX5715 // SPI interface default settings
whismanoid 0:3edb3708c8c5 482 //
whismanoid 0:3edb3708c8c5 483 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 484 //#define SPI_SCLK_Hz 24000000 // 24MHz
whismanoid 0:3edb3708c8c5 485 #define SPI_SCLK_Hz 12000000 // 12MHz
whismanoid 0:3edb3708c8c5 486 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 487 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 488 //#define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 489 #define SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 490 //
whismanoid 0:3edb3708c8c5 491 #elif APPLICATION_MAX11131 // SPI interface default settings
whismanoid 0:3edb3708c8c5 492 //
whismanoid 0:3edb3708c8c5 493 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 494 //#define SPI_SCLK_Hz 24000000 // 24MHz
whismanoid 22:0ae9ebdd471b 495 #if defined(TARGET_MAX32600)
whismanoid 22:0ae9ebdd471b 496 // MAX11131BOB_Serial_Tester on MAX32600MBED limit SCLK=6MHz
whismanoid 22:0ae9ebdd471b 497 #define SPI_SCLK_Hz 6000000 // 6MHz
whismanoid 22:0ae9ebdd471b 498 #else
whismanoid 22:0ae9ebdd471b 499 // all other platforms
whismanoid 0:3edb3708c8c5 500 #define SPI_SCLK_Hz 12000000 // 12MHz
whismanoid 22:0ae9ebdd471b 501 #endif
whismanoid 0:3edb3708c8c5 502 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 503 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 504 //#define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 505 #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 506 //
whismanoid 0:3edb3708c8c5 507 #elif APPLICATION_MAX5171 // SPI interface default settings
whismanoid 0:3edb3708c8c5 508 //
whismanoid 0:3edb3708c8c5 509 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 510 //#define SPI_SCLK_Hz 24000000 // 24MHz
whismanoid 0:3edb3708c8c5 511 #define SPI_SCLK_Hz 12000000 // 12MHz
whismanoid 0:3edb3708c8c5 512 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 513 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 514 //#define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 515 #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 516 //
whismanoid 0:3edb3708c8c5 517 #elif APPLICATION_MAX11410 // SPI interface default settings
whismanoid 0:3edb3708c8c5 518 //
whismanoid 0:3edb3708c8c5 519 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 520 //#define SPI_SCLK_Hz 24000000 // 24MHz
whismanoid 0:3edb3708c8c5 521 //#define SPI_SCLK_Hz 12000000 // 12MHz
whismanoid 0:3edb3708c8c5 522 #define SPI_SCLK_Hz 8000000 // 8MHz
whismanoid 0:3edb3708c8c5 523 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 524 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 525 //#define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 526 #define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Falling Edge stable; SCLK idle Low
whismanoid 0:3edb3708c8c5 527 //
whismanoid 0:3edb3708c8c5 528 #elif APPLICATION_MAX12345 // SPI interface default settings
whismanoid 0:3edb3708c8c5 529 //
whismanoid 0:3edb3708c8c5 530 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 531 //#define SPI_SCLK_Hz 24000000 // 24MHz
whismanoid 0:3edb3708c8c5 532 #define SPI_SCLK_Hz 12000000 // 12MHz
whismanoid 0:3edb3708c8c5 533 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 534 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 535 //#define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 536 #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 537 //
whismanoid 0:3edb3708c8c5 538 #else // APPLICATION_ArduinoPinsMonitor diagnostic
whismanoid 0:3edb3708c8c5 539 //
whismanoid 0:3edb3708c8c5 540 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 541 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 542 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 543 #define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 544 //#define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low
whismanoid 0:3edb3708c8c5 545 //#define SPI_dataMode SPI_MODE1 // CPOL=0,CPHA=1: Falling Edge stable; SCLK idle Low
whismanoid 0:3edb3708c8c5 546 //#define SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 547 #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 548 //
whismanoid 0:3edb3708c8c5 549 #endif
whismanoid 0:3edb3708c8c5 550 //
whismanoid 15:6bc6822b8bca 551 #if defined(TARGET_MAX32630)
whismanoid 15:6bc6822b8bca 552 // Before setting global variables g_SPI_SCLK_Hz and g_SPI_dataMode,
whismanoid 15:6bc6822b8bca 553 // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem (issue #30)
whismanoid 15:6bc6822b8bca 554 #warning "MAX32630 SPI workaround..."
whismanoid 15:6bc6822b8bca 555 // replace SPI_MODE2 (CPOL=1,CPHA=0) with SPI_MODE1 (CPOL=0,CPHA=1) Falling Edge stable
whismanoid 15:6bc6822b8bca 556 // replace SPI_MODE3 (CPOL=1,CPHA=1) with SPI_MODE0 (CPOL=0,CPHA=0) Rising Edge stable
whismanoid 15:6bc6822b8bca 557 # if ((SPI_dataMode) == (SPI_MODE2))
whismanoid 15:6bc6822b8bca 558 #warning "MAX32630 SPI_MODE2 workaround, changing SPI_dataMode to SPI_MODE1..."
whismanoid 15:6bc6822b8bca 559 // SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High
whismanoid 15:6bc6822b8bca 560 # undef SPI_dataMode
whismanoid 15:6bc6822b8bca 561 # define SPI_dataMode SPI_MODE1 // CPOL=0,CPHA=1: Falling Edge stable; SCLK idle Low
whismanoid 15:6bc6822b8bca 562 # elif ((SPI_dataMode) == (SPI_MODE3))
whismanoid 15:6bc6822b8bca 563 #warning "MAX32630 SPI_MODE3 workaround, changing SPI_dataMode to SPI_MODE0..."
whismanoid 15:6bc6822b8bca 564 // SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 15:6bc6822b8bca 565 # undef SPI_dataMode
whismanoid 15:6bc6822b8bca 566 # define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low
whismanoid 15:6bc6822b8bca 567 # endif // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem
whismanoid 15:6bc6822b8bca 568 // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem (issue #30)
whismanoid 15:6bc6822b8bca 569 // limit SPI SCLK speed to 6MHz or less
whismanoid 15:6bc6822b8bca 570 # if ((SPI_SCLK_Hz) > (6000000))
whismanoid 15:6bc6822b8bca 571 #warning "MAX32630 SPI speed workaround, changing SPI_SCLK_Hz to 6000000 or 6MHz..."
whismanoid 15:6bc6822b8bca 572 # undef SPI_SCLK_Hz
whismanoid 15:6bc6822b8bca 573 # define SPI_SCLK_Hz 6000000 // 6MHz
whismanoid 15:6bc6822b8bca 574 # endif
whismanoid 15:6bc6822b8bca 575 #endif
whismanoid 15:6bc6822b8bca 576 //
whismanoid 0:3edb3708c8c5 577 uint32_t g_SPI_SCLK_Hz = SPI_SCLK_Hz;
whismanoid 0:3edb3708c8c5 578 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 0:3edb3708c8c5 579 #if defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 580 // Nucleo SPI frequency isn't working quite as expected...
whismanoid 0:3edb3708c8c5 581 // Looks like STMF4 has an spi clock prescaler (2,4,8,16,32,64,128,256)
whismanoid 0:3edb3708c8c5 582 // so 180MHz->[90.0, 45.0, 22.5, 11.25, 5.625, 2.8125, 1.40625, 0.703125]
whismanoid 0:3edb3708c8c5 583 // %SC SCLK=1MHz sets spi frequency 703.125kHz
whismanoid 0:3edb3708c8c5 584 // %SC SCLK=2MHz sets spi frequency 1.40625MHz
whismanoid 0:3edb3708c8c5 585 // %SC SCLK=3MHz sets spi frequency 2.8125MHz
whismanoid 0:3edb3708c8c5 586 // %SC SCLK=6MHz sets spi frequency 5.625MHz
whismanoid 0:3edb3708c8c5 587 // %SC SCLK=12MHz sets spi frequency 11.25MHz
whismanoid 0:3edb3708c8c5 588 // %SC SCLK=23MHz sets spi frequency 22.5MHz
whismanoid 0:3edb3708c8c5 589 // %SC SCLK=45MHz sets spi frequency 45.0MHz
whismanoid 0:3edb3708c8c5 590 // Don't know why I can't reach spi frequency 90.0MHz, but ok whatever.
whismanoid 0:3edb3708c8c5 591 const uint32_t limit_min_SPI_SCLK_divisor = 2;
whismanoid 0:3edb3708c8c5 592 const uint32_t limit_max_SPI_SCLK_divisor = 256;
whismanoid 0:3edb3708c8c5 593 // not really a divisor, just a powers-of-two prescaler with no intermediate divisors.
whismanoid 0:3edb3708c8c5 594 #else
whismanoid 0:3edb3708c8c5 595 const uint32_t limit_min_SPI_SCLK_divisor = 2;
whismanoid 0:3edb3708c8c5 596 const uint32_t limit_max_SPI_SCLK_divisor = 8191;
whismanoid 0:3edb3708c8c5 597 #endif
whismanoid 0:3edb3708c8c5 598 const uint32_t limit_max_SPI_SCLK_Hz = (SystemCoreClock / limit_min_SPI_SCLK_divisor); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 0:3edb3708c8c5 599 const uint32_t limit_min_SPI_SCLK_Hz = (SystemCoreClock / limit_max_SPI_SCLK_divisor); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 0:3edb3708c8c5 600 //
whismanoid 0:3edb3708c8c5 601 uint8_t g_SPI_dataMode = SPI_dataMode;
whismanoid 0:3edb3708c8c5 602 uint8_t g_SPI_cs_state = 1;
whismanoid 0:3edb3708c8c5 603 //
whismanoid 0:3edb3708c8c5 604 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 605 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 606 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:3edb3708c8c5 607 //SPI spi0(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi0 MAX32630FTHR: P0_5 P0_6 P0_4 ok but this is the microSD card, can't contact pins
whismanoid 0:3edb3708c8c5 608 //SPI spi1(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 MAX32630FTHR: P1_1 P1_2 P1_0 ok but this is the xip flash, can't contact pins
whismanoid 0:3edb3708c8c5 609 //SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0
whismanoid 0:3edb3708c8c5 610 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0
whismanoid 0:3edb3708c8c5 611 //
whismanoid 0:3edb3708c8c5 612 DigitalOut spi_cs(P3_0);
whismanoid 0:3edb3708c8c5 613 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 614 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 615 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:3edb3708c8c5 616 //SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi0 TARGET_MAX32635MBED: P0_5 P0_6 P0_4 Arduino 8-pin header D5 D6 D7
whismanoid 0:3edb3708c8c5 617 //DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32635MBED: P0_7 Arduino 8-pin header D4
whismanoid 0:3edb3708c8c5 618 SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32635MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13
whismanoid 0:3edb3708c8c5 619 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32635MBED: P1_3 Arduino 10-pin header D10
whismanoid 0:3edb3708c8c5 620 SPI spi2_max541(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 TARGET_MAX32635MBED: P2_5 P2_6 P2_4 Arduino 2x3-pin header; microSD
whismanoid 0:3edb3708c8c5 621 DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header
whismanoid 0:3edb3708c8c5 622 #define HAS_SPI2_MAX541 1
whismanoid 0:3edb3708c8c5 623 //
whismanoid 17:c2f46173f6b2 624 #elif defined(TARGET_MAX32620FTHR)
whismanoid 17:c2f46173f6b2 625 #warning "TARGET_MAX32620FTHR not previously tested; need to define SPI pins..."
whismanoid 17:c2f46173f6b2 626 //
whismanoid 17:c2f46173f6b2 627 // SPI0 P0_ PMOD Port 0 Back access
whismanoid 17:c2f46173f6b2 628 //SPI spi0(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32620FTHR: PMOD Port 0 Back access
whismanoid 17:c2f46173f6b2 629 //DigitalOut spi_cs0(SPI0_SS); // TARGET_MAX32620FTHR: PMOD Port 0 Back access
whismanoid 17:c2f46173f6b2 630 //
whismanoid 17:c2f46173f6b2 631 // SPI1 P1_ PMOD Port 1 Top Access
whismanoid 17:c2f46173f6b2 632 SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32620FTHR: PMOD Port 1 Top Access
whismanoid 17:c2f46173f6b2 633 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32620FTHR: PMOD Port 1 Top Access
whismanoid 17:c2f46173f6b2 634 //
whismanoid 17:c2f46173f6b2 635 // SPI2 P5_ Feather J1.11,12,13
whismanoid 17:c2f46173f6b2 636 //SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32620FTHR: Feather J1.11,12,13
whismanoid 17:c2f46173f6b2 637 //DigitalOut spi_cs2(SPI2_SS); // TARGET_MAX32620FTHR: Feather J1.11,12,13
whismanoid 17:c2f46173f6b2 638 //
whismanoid 17:c2f46173f6b2 639 #elif defined(TARGET_MAX32625PICO)
whismanoid 17:c2f46173f6b2 640 #warning "TARGET_MAX32625PICO not previously tested; need to define SPI pins..."
whismanoid 17:c2f46173f6b2 641 // Note to software maintainer:
whismanoid 17:c2f46173f6b2 642 // when adding new platform support,
whismanoid 17:c2f46173f6b2 643 // add another #elif block above to support the new platform
whismanoid 17:c2f46173f6b2 644 SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: 15 P0_5 MOSI; 14 P0_6 MISO; 16 P0_4 SCLK
whismanoid 17:c2f46173f6b2 645 DigitalOut spi_cs(SPI_SS); // TARGET_MAX32625PICO: 13 P0_7 SSEL
whismanoid 17:c2f46173f6b2 646 //
whismanoid 12:28aca24adc15 647 #elif defined(TARGET_MAX32600)
whismanoid 12:28aca24adc15 648 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 12:28aca24adc15 649 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 12:28aca24adc15 650 //
whismanoid 0:3edb3708c8c5 651 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 652 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 653 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:3edb3708c8c5 654 //
whismanoid 0:3edb3708c8c5 655 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:3edb3708c8c5 656 SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); // mosi, miso, sclk spi1 TARGET_NUCLEO_F446RE: Arduino 10-pin header D11 D12 D13
whismanoid 0:3edb3708c8c5 657 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:3edb3708c8c5 658 //
whismanoid 0:3edb3708c8c5 659 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 660 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 661 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:3edb3708c8c5 662 //SPI spi0(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi0 MAX32630FTHR: P0_5 P0_6 P0_4 ok but this is the microSD card, can't contact pins
whismanoid 0:3edb3708c8c5 663 //SPI spi1(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 MAX32630FTHR: P1_1 P1_2 P1_0 ok but this is the xip flash, can't contact pins
whismanoid 0:3edb3708c8c5 664 //SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0
whismanoid 0:3edb3708c8c5 665 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0
whismanoid 0:3edb3708c8c5 666 //
whismanoid 0:3edb3708c8c5 667 DigitalOut spi_cs(P3_0);
whismanoid 17:c2f46173f6b2 668 //
whismanoid 0:3edb3708c8c5 669 #else
whismanoid 0:3edb3708c8c5 670 // unknown target
whismanoid 17:c2f46173f6b2 671 #warning "target not previously tested; need to define SPI pins..."
whismanoid 17:c2f46173f6b2 672 // Note to software maintainer:
whismanoid 17:c2f46173f6b2 673 // when adding new platform support,
whismanoid 17:c2f46173f6b2 674 // add another #elif block above to support the new platform
whismanoid 17:c2f46173f6b2 675 //SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); // mosi, miso, sclk spi1 TARGET_xxx: Arduino 10-pin header D11 D12 D13
whismanoid 17:c2f46173f6b2 676 //DigitalOut spi_cs(SPI_CS); // TARGET_xxx: PX_x Arduino 10-pin header D10
whismanoid 0:3edb3708c8c5 677 #endif
whismanoid 0:3edb3708c8c5 678 #endif
whismanoid 0:3edb3708c8c5 679
whismanoid 0:3edb3708c8c5 680 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 681 // Device driver object
whismanoid 0:3edb3708c8c5 682 #if APPLICATION_MAX5715 // SPI interface default settings
whismanoid 0:3edb3708c8c5 683 DigitalOut LDACb_pin(D9); // Arduino 10-pin header D9
whismanoid 0:3edb3708c8c5 684 DigitalOut CLRb_pin(D8); // Arduino 10-pin header D8
whismanoid 0:3edb3708c8c5 685 //~ DigitalIn RDYb_pin(D12); // Arduino 10-pin header D12 (MISO)
whismanoid 0:3edb3708c8c5 686 MAX5715 g_MAX5715_device(spi, spi_cs,
whismanoid 0:3edb3708c8c5 687 LDACb_pin,
whismanoid 0:3edb3708c8c5 688 CLRb_pin,
whismanoid 0:3edb3708c8c5 689 ///* RDYb_pin */ digitalInOut12,
whismanoid 0:3edb3708c8c5 690 MAX5715::MAX5715_IC);
whismanoid 0:3edb3708c8c5 691 //
whismanoid 0:3edb3708c8c5 692 #elif APPLICATION_MAX11131 // SPI interface default settings
whismanoid 0:3edb3708c8c5 693 DigitalOut CNVSTb_pin(D9); // Arduino 10-pin header D9
whismanoid 0:3edb3708c8c5 694 //DigitalOut CLRb_pin(D8); // Arduino 10-pin header D8
whismanoid 0:3edb3708c8c5 695 DigitalIn EOCb_pin(D12); // Arduino 10-pin header D12 (MISO)
whismanoid 0:3edb3708c8c5 696 MAX11131 g_MAX11131_device(spi, spi_cs,
whismanoid 0:3edb3708c8c5 697 CNVSTb_pin,
whismanoid 0:3edb3708c8c5 698 EOCb_pin,
whismanoid 0:3edb3708c8c5 699 ///* RDYb_pin */ digitalInOut12,
whismanoid 0:3edb3708c8c5 700 MAX11131::MAX11131_IC);
whismanoid 0:3edb3708c8c5 701 //
whismanoid 0:3edb3708c8c5 702 //
whismanoid 0:3edb3708c8c5 703 #elif APPLICATION_MAX5171 // SPI interface default settings
whismanoid 0:3edb3708c8c5 704 // AnalogOut FB_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5171 device
whismanoid 0:3edb3708c8c5 705 DigitalOut RS_pin(D9); // Digital Configuration Input to MAX5171 device
whismanoid 0:3edb3708c8c5 706 DigitalOut PDLb_pin(D8); // Digital Configuration Input to MAX5171 device
whismanoid 0:3edb3708c8c5 707 DigitalOut CLRb_pin(D7); // Digital Configuration Input to MAX5171 device
whismanoid 0:3edb3708c8c5 708 DigitalOut SHDN_pin(D6); // Digital Configuration Input to MAX5171 device
whismanoid 0:3edb3708c8c5 709 // AnalogIn OUT_pin(A0); // Analog Output from MAX5171 device
whismanoid 0:3edb3708c8c5 710 DigitalIn UPO_pin(D2); // Digital General-Purpose Output from MAX5171 device
whismanoid 0:3edb3708c8c5 711 MAX5171 g_MAX5171_device(spi, spi_cs, RS_pin, PDLb_pin, CLRb_pin, SHDN_pin, UPO_pin, MAX5171::MAX5171_IC);
whismanoid 0:3edb3708c8c5 712 //
whismanoid 0:3edb3708c8c5 713 #elif APPLICATION_MAX11410 // SPI interface default settings
whismanoid 0:3edb3708c8c5 714 //
whismanoid 0:3edb3708c8c5 715 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 0:3edb3708c8c5 716 //
whismanoid 0:3edb3708c8c5 717 #elif APPLICATION_MAX12345 // SPI interface default settings
whismanoid 0:3edb3708c8c5 718 //
whismanoid 0:3edb3708c8c5 719 MAX12345 g_MAX12345_device(spi, spi_cs, ...);
whismanoid 0:3edb3708c8c5 720 //
whismanoid 0:3edb3708c8c5 721 #else // APPLICATION_ArduinoPinsMonitor diagnostic
whismanoid 0:3edb3708c8c5 722 //
whismanoid 0:3edb3708c8c5 723 #endif
whismanoid 0:3edb3708c8c5 724
whismanoid 0:3edb3708c8c5 725
whismanoid 0:3edb3708c8c5 726 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 727 // Option to dedicate I2C port pins
whismanoid 0:3edb3708c8c5 728 //
whismanoid 0:3edb3708c8c5 729 #ifndef HAS_I2C
whismanoid 0:3edb3708c8c5 730 #define HAS_I2C 1
whismanoid 0:3edb3708c8c5 731 #endif
whismanoid 0:3edb3708c8c5 732 #if HAS_I2C
whismanoid 0:3edb3708c8c5 733 //#include "I2C.h"
whismanoid 0:3edb3708c8c5 734 //#include "I2CSlave.h"
whismanoid 0:3edb3708c8c5 735 //#define I2C_SCL_Hz 400000 // 400kHz
whismanoid 0:3edb3708c8c5 736 //#define I2C_SCL_Hz 200000 // 200kHz
whismanoid 0:3edb3708c8c5 737 #define I2C_SCL_Hz 100000 // 100kHz
whismanoid 0:3edb3708c8c5 738 //
whismanoid 0:3edb3708c8c5 739 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 740 // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 0:3edb3708c8c5 741 const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 0:3edb3708c8c5 742 const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 0:3edb3708c8c5 743 //
whismanoid 0:3edb3708c8c5 744 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 745 //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl MAX32630FTHR: NOT_CONNECTED
whismanoid 0:3edb3708c8c5 746 //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl MAX32630FTHR: P3_4, P3_5
whismanoid 0:3edb3708c8c5 747 //I2C i2cMaster2(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0
whismanoid 0:3edb3708c8c5 748 //I2C i2cMaster(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0
whismanoid 0:3edb3708c8c5 749 //
whismanoid 0:3edb3708c8c5 750 //I2CSlave i2cSlave0(I2C0_SDA, I2C0_SCL); // sda scl MAX32630FTHR: NOT_CONNECTED
whismanoid 0:3edb3708c8c5 751 //I2CSlave i2cSlave1(I2C1_SDA, I2C1_SCL); // sda scl MAX32630FTHR: P3_4, P3_5
whismanoid 0:3edb3708c8c5 752 //I2CSlave i2cSlave2(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0
whismanoid 0:3edb3708c8c5 753 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 754 // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 0:3edb3708c8c5 755 const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 0:3edb3708c8c5 756 const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 0:3edb3708c8c5 757 //
whismanoid 0:3edb3708c8c5 758 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 759 //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 760 //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header
whismanoid 0:3edb3708c8c5 761 // declare in narrower scope: MAX32625MBED I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 762 //
whismanoid 0:3edb3708c8c5 763 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 764 // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 0:3edb3708c8c5 765 const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 0:3edb3708c8c5 766 const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 0:3edb3708c8c5 767 //
whismanoid 0:3edb3708c8c5 768 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 769 //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 770 //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header
whismanoid 0:3edb3708c8c5 771 // declare in narrower scope: MAX32625MBED I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 772 # ifndef I2C0_SDA
whismanoid 0:3edb3708c8c5 773 # define I2C0_SDA I2C_SDA
whismanoid 0:3edb3708c8c5 774 # define I2C0_SCL I2C_SCL
whismanoid 0:3edb3708c8c5 775 # endif
whismanoid 0:3edb3708c8c5 776 //
whismanoid 0:3edb3708c8c5 777 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 778 // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 0:3edb3708c8c5 779 const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 0:3edb3708c8c5 780 const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 0:3edb3708c8c5 781 //
whismanoid 0:3edb3708c8c5 782 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 783 //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 784 //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header
whismanoid 0:3edb3708c8c5 785 // declare in narrower scope: MAX32625MBED I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 786 # ifndef I2C0_SDA
whismanoid 0:3edb3708c8c5 787 # define I2C0_SDA I2C_SDA
whismanoid 0:3edb3708c8c5 788 # define I2C0_SCL I2C_SCL
whismanoid 0:3edb3708c8c5 789 # endif
whismanoid 0:3edb3708c8c5 790 //
whismanoid 0:3edb3708c8c5 791 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 792 #else
whismanoid 0:3edb3708c8c5 793 // unknown target
whismanoid 17:c2f46173f6b2 794 #warning "target not previously tested; need to define I2C pins..."
whismanoid 0:3edb3708c8c5 795 #endif
whismanoid 0:3edb3708c8c5 796 //
whismanoid 0:3edb3708c8c5 797 #endif
whismanoid 0:3edb3708c8c5 798 #if HAS_I2C
whismanoid 0:3edb3708c8c5 799 uint32_t g_I2C_SCL_Hz = I2C_SCL_Hz;
whismanoid 0:3edb3708c8c5 800 uint8_t g_I2C_status = 0; // g_I2C_status = Wire_Sr.endTransmission();
whismanoid 0:3edb3708c8c5 801 uint8_t g_I2C_deviceAddress7 = (0xA0 >> 1); // I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified.
whismanoid 0:3edb3708c8c5 802 uint8_t g_I2C_read_count = 0;
whismanoid 0:3edb3708c8c5 803 uint8_t g_I2C_write_count = 0;
whismanoid 0:3edb3708c8c5 804 uint8_t g_I2C_write_data[256];
whismanoid 0:3edb3708c8c5 805 uint8_t g_I2C_command_regAddress;
whismanoid 0:3edb3708c8c5 806 //
whismanoid 0:3edb3708c8c5 807 // TODO: i2c init
whismanoid 0:3edb3708c8c5 808 // i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 0:3edb3708c8c5 809 #endif
whismanoid 0:3edb3708c8c5 810 #if HAS_I2C
whismanoid 0:3edb3708c8c5 811 // TODO: i2c transfer
whismanoid 0:3edb3708c8c5 812 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 0:3edb3708c8c5 813 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 0:3edb3708c8c5 814 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 0:3edb3708c8c5 815 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 0:3edb3708c8c5 816 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 0:3edb3708c8c5 817 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 0:3edb3708c8c5 818 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 0:3edb3708c8c5 819 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 0:3edb3708c8c5 820 // /* 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 0:3edb3708c8c5 821 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 0:3edb3708c8c5 822 #endif
whismanoid 0:3edb3708c8c5 823
whismanoid 0:3edb3708c8c5 824
whismanoid 0:3edb3708c8c5 825 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 826 // Declare the Serial driver
whismanoid 0:3edb3708c8c5 827 // default baud rate settings are 9600 8N1
whismanoid 0:3edb3708c8c5 828 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 0:3edb3708c8c5 829 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 0:3edb3708c8c5 830 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 831 #include "USBSerial.h"
whismanoid 0:3edb3708c8c5 832 // Hardware serial port over DAPLink
whismanoid 0:3edb3708c8c5 833 // The default baud rate for the DapLink UART is 9600
whismanoid 0:3edb3708c8c5 834 Serial DAPLINKserial(P2_1, P2_0); // tx, rx
whismanoid 0:3edb3708c8c5 835 #define HAS_DAPLINK_SERIAL 1
whismanoid 0:3edb3708c8c5 836 // Virtual serial port over USB
whismanoid 0:3edb3708c8c5 837 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:132276960128 838 USBSerial serial;
whismanoid 0:3edb3708c8c5 839 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 840 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 841 #include "USBSerial.h"
whismanoid 0:3edb3708c8c5 842 // Hardware serial port over DAPLink
whismanoid 0:3edb3708c8c5 843 // The default baud rate for the DapLink UART is 9600
whismanoid 0:3edb3708c8c5 844 Serial DAPLINKserial(P2_1, P2_0); // tx, rx
whismanoid 0:3edb3708c8c5 845 #define HAS_DAPLINK_SERIAL 1
whismanoid 0:3edb3708c8c5 846 // Virtual serial port over USB
whismanoid 0:3edb3708c8c5 847 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:132276960128 848 USBSerial serial;
whismanoid 17:c2f46173f6b2 849 //
whismanoid 17:c2f46173f6b2 850 //--------------------------------------------------
whismanoid 17:c2f46173f6b2 851 #elif defined(TARGET_MAX32620FTHR)
whismanoid 17:c2f46173f6b2 852 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 19:8e81fd761a62 853 // Hardware serial port over DAPLink
whismanoid 19:8e81fd761a62 854 // The default baud rate for the DapLink UART is 9600
whismanoid 19:8e81fd761a62 855 Serial DAPLINKserial(USBTX, USBRX); // tx, rx MAX32620FTHR: P2_1,P2_0
whismanoid 19:8e81fd761a62 856 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 19:8e81fd761a62 857 #define HAS_DAPLINK_SERIAL 1
whismanoid 19:8e81fd761a62 858 // Virtual serial port over USB
whismanoid 19:8e81fd761a62 859 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 19:8e81fd761a62 860 // #include "USBSerial.h"
whismanoid 19:8e81fd761a62 861 //USBSerial serial;
whismanoid 19:8e81fd761a62 862 //Serial serial(UART0_TX, UART0_RX); // tx, rx MAX32620FTHR: P0_1,P0_0 (PMOD Port 0)
whismanoid 19:8e81fd761a62 863 //Serial serial(UART1_TX, UART1_RX); // tx, rx MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 19:8e81fd761a62 864 Serial serial(UART2_TX, UART2_RX); // tx, rx MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 19:8e81fd761a62 865 //Serial serial(UART3_TX, UART3_RX); // tx, rx MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 17:c2f46173f6b2 866 //Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 19:8e81fd761a62 867 //Serial serial(USBTX, USBRX); // tx, rx
whismanoid 17:c2f46173f6b2 868 //Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 17:c2f46173f6b2 869 //
whismanoid 17:c2f46173f6b2 870 //--------------------------------------------------
whismanoid 17:c2f46173f6b2 871 #elif defined(TARGET_MAX32625PICO)
whismanoid 17:c2f46173f6b2 872 #warning "TARGET_MAX32625PICO not previously tested; need to verify serial pins..."
whismanoid 17:c2f46173f6b2 873 // Note to software maintainer:
whismanoid 17:c2f46173f6b2 874 // when adding new platform support,
whismanoid 17:c2f46173f6b2 875 // add another #elif block above to support the new platform
whismanoid 17:c2f46173f6b2 876 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 17:c2f46173f6b2 877 //
whismanoid 0:3edb3708c8c5 878 //--------------------------------------------------
whismanoid 12:28aca24adc15 879 #elif defined(TARGET_MAX32600)
whismanoid 12:28aca24adc15 880 #include "USBSerial.h"
whismanoid 12:28aca24adc15 881 // Hardware serial port over DAPLink
whismanoid 12:28aca24adc15 882 // The default baud rate for the DapLink UART is 9600
whismanoid 12:28aca24adc15 883 Serial DAPLINKserial(P1_1, P1_0); // tx, rx
whismanoid 12:28aca24adc15 884 #define HAS_DAPLINK_SERIAL 1
whismanoid 12:28aca24adc15 885 // Virtual serial port over USB
whismanoid 12:28aca24adc15 886 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 12:28aca24adc15 887 USBSerial serial;
whismanoid 12:28aca24adc15 888 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 889 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:132276960128 890 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 0:3edb3708c8c5 891 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 892 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:3edb3708c8c5 893 #elif defined(TARGET_LPC1768)
whismanoid 8:132276960128 894 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 0:3edb3708c8c5 895 #else
whismanoid 0:3edb3708c8c5 896 // unknown target
whismanoid 17:c2f46173f6b2 897 #if defined(SERIAL_TX)
whismanoid 17:c2f46173f6b2 898 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 17:c2f46173f6b2 899 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 17:c2f46173f6b2 900 #elif defined(USBTX)
whismanoid 17:c2f46173f6b2 901 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 17:c2f46173f6b2 902 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 17:c2f46173f6b2 903 #elif defined(UART_TX)
whismanoid 17:c2f46173f6b2 904 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 17:c2f46173f6b2 905 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 17:c2f46173f6b2 906 #else
whismanoid 17:c2f46173f6b2 907 #warning "target not previously tested; need to define serial pins..."
whismanoid 17:c2f46173f6b2 908 #endif
whismanoid 0:3edb3708c8c5 909 #endif
whismanoid 0:3edb3708c8c5 910
whismanoid 0:3edb3708c8c5 911 void on_immediate_0x21(); // Unicode (U+0021) ! EXCLAMATION MARK
whismanoid 0:3edb3708c8c5 912 void on_immediate_0x7b(); // Unicode (U+007B) { LEFT CURLY BRACKET
whismanoid 0:3edb3708c8c5 913 void on_immediate_0x7d(); // Unicode (U+007D) } RIGHT CURLY BRACKET
whismanoid 0:3edb3708c8c5 914
whismanoid 0:3edb3708c8c5 915 #include "CmdLine.h"
whismanoid 0:3edb3708c8c5 916
whismanoid 0:3edb3708c8c5 917 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 918 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 0:3edb3708c8c5 919 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:132276960128 920 CmdLine cmdLine_serial(serial, "serial");
whismanoid 0:3edb3708c8c5 921
whismanoid 0:3edb3708c8c5 922
whismanoid 0:3edb3708c8c5 923 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 924 // tolerate AT commands, which may be sent during probe, such as:
whismanoid 0:3edb3708c8c5 925 // AT
whismanoid 0:3edb3708c8c5 926 // AT+CGMI -- request manufacturer identification AT+CMGI=?
whismanoid 0:3edb3708c8c5 927 // AT+CGMM -- request manufacturer model
whismanoid 0:3edb3708c8c5 928 // AT%IPSYS?
whismanoid 0:3edb3708c8c5 929 // ATE0 -- echo disable
whismanoid 0:3edb3708c8c5 930 // ATV1 -- verbose result codes OK | ERROR | NO CARRIER
whismanoid 0:3edb3708c8c5 931 // AT+CMEE=1
whismanoid 0:3edb3708c8c5 932 // ATX4
whismanoid 0:3edb3708c8c5 933 // AT&C1
whismanoid 0:3edb3708c8c5 934 // ATE0
whismanoid 0:3edb3708c8c5 935 // AT+CMEE=1
whismanoid 0:3edb3708c8c5 936 // AT+GCAP
whismanoid 0:3edb3708c8c5 937 // ATI
whismanoid 0:3edb3708c8c5 938 // AT+CPIN?
whismanoid 0:3edb3708c8c5 939 // AT+CGMM
whismanoid 0:3edb3708c8c5 940 #ifndef IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 941 #define IGNORE_AT_COMMANDS 1
whismanoid 0:3edb3708c8c5 942 #endif
whismanoid 0:3edb3708c8c5 943
whismanoid 0:3edb3708c8c5 944
whismanoid 0:3edb3708c8c5 945 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:3edb3708c8c5 946 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 947 // Declare the DigitalInOut GPIO pins
whismanoid 0:3edb3708c8c5 948 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:3edb3708c8c5 949 // D) Digital High/Low/Input Pin
whismanoid 0:3edb3708c8c5 950 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 951 // +-------------[microUSB]-------------+
whismanoid 0:3edb3708c8c5 952 // | J1 MAX32630FTHR J2 |
whismanoid 0:3edb3708c8c5 953 // | [ ] RST GND [ ] |
whismanoid 0:3edb3708c8c5 954 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:3edb3708c8c5 955 // | [ ] 1V8 reset SW1 |
whismanoid 0:3edb3708c8c5 956 // | [ ] GND J4 J3 |
whismanoid 0:3edb3708c8c5 957 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:3edb3708c8c5 958 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:3edb3708c8c5 959 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:3edb3708c8c5 960 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:3edb3708c8c5 961 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:3edb3708c8c5 962 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:3edb3708c8c5 963 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:3edb3708c8c5 964 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:3edb3708c8c5 965 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:3edb3708c8c5 966 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:3edb3708c8c5 967 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:3edb3708c8c5 968 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:3edb3708c8c5 969 // +------------------------------------+
whismanoid 0:3edb3708c8c5 970 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:3edb3708c8c5 971 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:3edb3708c8c5 972 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:3edb3708c8c5 973 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:3edb3708c8c5 974 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:3edb3708c8c5 975 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:3edb3708c8c5 976 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:3edb3708c8c5 977 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:3edb3708c8c5 978 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:3edb3708c8c5 979 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:3edb3708c8c5 980 #if HAS_I2C
whismanoid 0:3edb3708c8c5 981 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 982 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:3edb3708c8c5 983 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:3edb3708c8c5 984 #else // HAS_I2C
whismanoid 0:3edb3708c8c5 985 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:3edb3708c8c5 986 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:3edb3708c8c5 987 #endif // HAS_I2C
whismanoid 0:3edb3708c8c5 988 #if HAS_SPI
whismanoid 0:3edb3708c8c5 989 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 990 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:3edb3708c8c5 991 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:3edb3708c8c5 992 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:3edb3708c8c5 993 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:3edb3708c8c5 994 #else // HAS_SPI
whismanoid 0:3edb3708c8c5 995 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:3edb3708c8c5 996 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:3edb3708c8c5 997 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:3edb3708c8c5 998 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:3edb3708c8c5 999 #endif // HAS_SPI
whismanoid 0:3edb3708c8c5 1000 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 1001 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:3edb3708c8c5 1002 #endif
whismanoid 0:3edb3708c8c5 1003 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 1004 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:3edb3708c8c5 1005 #endif
whismanoid 0:3edb3708c8c5 1006 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 1007 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:3edb3708c8c5 1008 #endif
whismanoid 0:3edb3708c8c5 1009 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 1010 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:3edb3708c8c5 1011 #endif
whismanoid 0:3edb3708c8c5 1012 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 1013 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:3edb3708c8c5 1014 #endif
whismanoid 0:3edb3708c8c5 1015 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 1016 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:3edb3708c8c5 1017 #endif
whismanoid 0:3edb3708c8c5 1018 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 1019 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:3edb3708c8c5 1020 #endif
whismanoid 0:3edb3708c8c5 1021 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 1022 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:3edb3708c8c5 1023 #endif
whismanoid 0:3edb3708c8c5 1024 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 1025 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:3edb3708c8c5 1026 #endif
whismanoid 0:3edb3708c8c5 1027 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 1028 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:3edb3708c8c5 1029 #endif
whismanoid 0:3edb3708c8c5 1030 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 1031 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:3edb3708c8c5 1032 #endif
whismanoid 0:3edb3708c8c5 1033 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 1034 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:3edb3708c8c5 1035 #endif
whismanoid 0:3edb3708c8c5 1036 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 1037 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:3edb3708c8c5 1038 #endif
whismanoid 0:3edb3708c8c5 1039 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 1040 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:3edb3708c8c5 1041 #endif
whismanoid 0:3edb3708c8c5 1042 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 1043 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:3edb3708c8c5 1044 #endif
whismanoid 0:3edb3708c8c5 1045 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 1046 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:3edb3708c8c5 1047 #endif
whismanoid 0:3edb3708c8c5 1048 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1049 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 1050 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:3edb3708c8c5 1051 // +-------------------------------------+
whismanoid 0:3edb3708c8c5 1052 // | MAX32625MBED Arduino UNO header |
whismanoid 0:3edb3708c8c5 1053 // | |
whismanoid 0:3edb3708c8c5 1054 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:3edb3708c8c5 1055 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:3edb3708c8c5 1056 // | AREF=N/C[ ] |
whismanoid 0:3edb3708c8c5 1057 // | GND[ ] |
whismanoid 0:3edb3708c8c5 1058 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:3edb3708c8c5 1059 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:3edb3708c8c5 1060 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:3edb3708c8c5 1061 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:3edb3708c8c5 1062 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:3edb3708c8c5 1063 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:3edb3708c8c5 1064 // | [ ]GND |
whismanoid 0:3edb3708c8c5 1065 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:3edb3708c8c5 1066 // | 6[ ]~| P0_6 dig6
whismanoid 0:3edb3708c8c5 1067 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:3edb3708c8c5 1068 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:3edb3708c8c5 1069 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:3edb3708c8c5 1070 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:3edb3708c8c5 1071 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:3edb3708c8c5 1072 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:3edb3708c8c5 1073 // | [ ] [ ] [ ] |
whismanoid 0:3edb3708c8c5 1074 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:3edb3708c8c5 1075 // \_______________________/
whismanoid 0:3edb3708c8c5 1076 //
whismanoid 0:3edb3708c8c5 1077 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:3edb3708c8c5 1078 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:3edb3708c8c5 1079 #if APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 1080 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:3edb3708c8c5 1081 #else
whismanoid 0:3edb3708c8c5 1082 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:3edb3708c8c5 1083 #endif
whismanoid 0:3edb3708c8c5 1084 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:3edb3708c8c5 1085 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:3edb3708c8c5 1086 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:3edb3708c8c5 1087 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:3edb3708c8c5 1088 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:3edb3708c8c5 1089 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:3edb3708c8c5 1090 #if APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 1091 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:3edb3708c8c5 1092 #else
whismanoid 0:3edb3708c8c5 1093 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:3edb3708c8c5 1094 #endif
whismanoid 0:3edb3708c8c5 1095 #if HAS_SPI
whismanoid 0:3edb3708c8c5 1096 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 1097 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:3edb3708c8c5 1098 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:3edb3708c8c5 1099 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:3edb3708c8c5 1100 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:3edb3708c8c5 1101 #else // HAS_SPI
whismanoid 0:3edb3708c8c5 1102 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:3edb3708c8c5 1103 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:3edb3708c8c5 1104 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:3edb3708c8c5 1105 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:3edb3708c8c5 1106 #endif // HAS_SPI
whismanoid 0:3edb3708c8c5 1107 #if HAS_I2C
whismanoid 0:3edb3708c8c5 1108 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 1109 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 1110 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 1111 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 1112 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 1113 #else // HAS_I2C
whismanoid 0:3edb3708c8c5 1114 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 1115 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 1116 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 1117 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 1118 #endif // HAS_I2C
whismanoid 0:3edb3708c8c5 1119 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 1120 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:3edb3708c8c5 1121 #endif
whismanoid 0:3edb3708c8c5 1122 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 1123 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:3edb3708c8c5 1124 #endif
whismanoid 0:3edb3708c8c5 1125 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 1126 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:3edb3708c8c5 1127 #endif
whismanoid 0:3edb3708c8c5 1128 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 1129 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:3edb3708c8c5 1130 #endif
whismanoid 0:3edb3708c8c5 1131 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 1132 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:3edb3708c8c5 1133 #endif
whismanoid 0:3edb3708c8c5 1134 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 1135 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:3edb3708c8c5 1136 #endif
whismanoid 0:3edb3708c8c5 1137 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 1138 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:3edb3708c8c5 1139 #endif
whismanoid 0:3edb3708c8c5 1140 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 1141 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:3edb3708c8c5 1142 #endif
whismanoid 0:3edb3708c8c5 1143 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 1144 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:3edb3708c8c5 1145 #endif
whismanoid 0:3edb3708c8c5 1146 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 1147 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:3edb3708c8c5 1148 #endif
whismanoid 0:3edb3708c8c5 1149 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 1150 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:3edb3708c8c5 1151 #endif
whismanoid 0:3edb3708c8c5 1152 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 1153 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:3edb3708c8c5 1154 #endif
whismanoid 0:3edb3708c8c5 1155 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 1156 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:3edb3708c8c5 1157 #endif
whismanoid 0:3edb3708c8c5 1158 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 1159 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:3edb3708c8c5 1160 #endif
whismanoid 0:3edb3708c8c5 1161 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 1162 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:3edb3708c8c5 1163 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:3edb3708c8c5 1164 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 1165 #endif
whismanoid 0:3edb3708c8c5 1166 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 1167 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:3edb3708c8c5 1168 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 1169 #endif
whismanoid 0:3edb3708c8c5 1170 #if HAS_digitalInOut16
whismanoid 0:3edb3708c8c5 1171 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:3edb3708c8c5 1172 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:3edb3708c8c5 1173 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:3edb3708c8c5 1174 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 1175 #endif
whismanoid 0:3edb3708c8c5 1176 #if HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 1177 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:3edb3708c8c5 1178 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 1179 #endif
whismanoid 0:3edb3708c8c5 1180 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1181 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 1182 #define HAS_digitalInOut0 0 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:3edb3708c8c5 1183 #define HAS_digitalInOut1 0 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:3edb3708c8c5 1184 #if APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 1185 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:3edb3708c8c5 1186 #else
whismanoid 0:3edb3708c8c5 1187 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:3edb3708c8c5 1188 #endif
whismanoid 0:3edb3708c8c5 1189 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:3edb3708c8c5 1190 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:3edb3708c8c5 1191 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:3edb3708c8c5 1192 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:3edb3708c8c5 1193 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:3edb3708c8c5 1194 #if APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 1195 #define HAS_digitalInOut8 0 // P1_4 TARGET_MAX32625MBED D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:3edb3708c8c5 1196 #else
whismanoid 0:3edb3708c8c5 1197 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:3edb3708c8c5 1198 #endif
whismanoid 0:3edb3708c8c5 1199 #if APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 1200 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:3edb3708c8c5 1201 #elif APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 1202 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:3edb3708c8c5 1203 #else
whismanoid 0:3edb3708c8c5 1204 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:3edb3708c8c5 1205 #endif
whismanoid 0:3edb3708c8c5 1206 #if HAS_SPI
whismanoid 0:3edb3708c8c5 1207 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 1208 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:3edb3708c8c5 1209 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:3edb3708c8c5 1210 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:3edb3708c8c5 1211 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:3edb3708c8c5 1212 #define HAS_digitalInOut10 0
whismanoid 0:3edb3708c8c5 1213 #define HAS_digitalInOut11 0
whismanoid 0:3edb3708c8c5 1214 #define HAS_digitalInOut12 0
whismanoid 0:3edb3708c8c5 1215 #define HAS_digitalInOut13 0
whismanoid 0:3edb3708c8c5 1216 #else // HAS_SPI
whismanoid 0:3edb3708c8c5 1217 #define HAS_digitalInOut10 1
whismanoid 0:3edb3708c8c5 1218 #define HAS_digitalInOut11 1
whismanoid 0:3edb3708c8c5 1219 #define HAS_digitalInOut12 1
whismanoid 0:3edb3708c8c5 1220 #define HAS_digitalInOut13 1
whismanoid 0:3edb3708c8c5 1221 #endif // HAS_SPI
whismanoid 0:3edb3708c8c5 1222 #if HAS_I2C
whismanoid 0:3edb3708c8c5 1223 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 1224 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 1225 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 1226 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 1227 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 1228 #define HAS_digitalInOut14 0
whismanoid 0:3edb3708c8c5 1229 #define HAS_digitalInOut15 0
whismanoid 0:3edb3708c8c5 1230 #define HAS_digitalInOut16 0
whismanoid 0:3edb3708c8c5 1231 #define HAS_digitalInOut17 0
whismanoid 0:3edb3708c8c5 1232 #else // HAS_I2C
whismanoid 0:3edb3708c8c5 1233 #define HAS_digitalInOut14 1
whismanoid 0:3edb3708c8c5 1234 #define HAS_digitalInOut15 1
whismanoid 0:3edb3708c8c5 1235 #define HAS_digitalInOut16 0
whismanoid 0:3edb3708c8c5 1236 #define HAS_digitalInOut17 0
whismanoid 0:3edb3708c8c5 1237 #endif // HAS_I2C
whismanoid 0:3edb3708c8c5 1238 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 1239 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1240 #endif
whismanoid 0:3edb3708c8c5 1241 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 1242 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1243 #endif
whismanoid 0:3edb3708c8c5 1244 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 1245 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1246 #endif
whismanoid 0:3edb3708c8c5 1247 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 1248 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1249 #endif
whismanoid 0:3edb3708c8c5 1250 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 1251 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1252 #endif
whismanoid 0:3edb3708c8c5 1253 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 1254 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1255 #endif
whismanoid 0:3edb3708c8c5 1256 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 1257 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1258 #endif
whismanoid 0:3edb3708c8c5 1259 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 1260 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1261 #endif
whismanoid 0:3edb3708c8c5 1262 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 1263 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1264 #endif
whismanoid 0:3edb3708c8c5 1265 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 1266 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1267 #endif
whismanoid 0:3edb3708c8c5 1268 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 1269 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:3edb3708c8c5 1270 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1271 #endif
whismanoid 0:3edb3708c8c5 1272 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 1273 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:3edb3708c8c5 1274 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1275 #endif
whismanoid 0:3edb3708c8c5 1276 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 1277 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:3edb3708c8c5 1278 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1279 #endif
whismanoid 0:3edb3708c8c5 1280 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 1281 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:3edb3708c8c5 1282 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1283 #endif
whismanoid 0:3edb3708c8c5 1284 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 1285 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 1286 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1287 #endif
whismanoid 0:3edb3708c8c5 1288 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 1289 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 1290 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1291 #endif
whismanoid 0:3edb3708c8c5 1292 #if HAS_digitalInOut16
whismanoid 0:3edb3708c8c5 1293 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 1294 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1295 #endif
whismanoid 0:3edb3708c8c5 1296 #if HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 1297 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 1298 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1299 #endif
whismanoid 0:3edb3708c8c5 1300 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1301 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 1302 #define HAS_digitalInOut0 1
whismanoid 0:3edb3708c8c5 1303 #define HAS_digitalInOut1 1
whismanoid 0:3edb3708c8c5 1304 #define HAS_digitalInOut2 1
whismanoid 0:3edb3708c8c5 1305 #define HAS_digitalInOut3 1
whismanoid 0:3edb3708c8c5 1306 #define HAS_digitalInOut4 1
whismanoid 0:3edb3708c8c5 1307 #define HAS_digitalInOut5 1
whismanoid 0:3edb3708c8c5 1308 #define HAS_digitalInOut6 1
whismanoid 0:3edb3708c8c5 1309 #define HAS_digitalInOut7 1
whismanoid 0:3edb3708c8c5 1310 #define HAS_digitalInOut8 1
whismanoid 0:3edb3708c8c5 1311 #define HAS_digitalInOut9 1
whismanoid 0:3edb3708c8c5 1312 // #define HAS_digitalInOut10 1
whismanoid 0:3edb3708c8c5 1313 // #define HAS_digitalInOut11 1
whismanoid 0:3edb3708c8c5 1314 // #define HAS_digitalInOut12 1
whismanoid 0:3edb3708c8c5 1315 // #define HAS_digitalInOut13 1
whismanoid 0:3edb3708c8c5 1316 // #define HAS_digitalInOut14 1
whismanoid 0:3edb3708c8c5 1317 // #define HAS_digitalInOut15 1
whismanoid 0:3edb3708c8c5 1318 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 1319 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:3edb3708c8c5 1320 #endif
whismanoid 0:3edb3708c8c5 1321 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 1322 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:3edb3708c8c5 1323 #endif
whismanoid 0:3edb3708c8c5 1324 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 1325 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:3edb3708c8c5 1326 #endif
whismanoid 0:3edb3708c8c5 1327 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 1328 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:3edb3708c8c5 1329 #endif
whismanoid 0:3edb3708c8c5 1330 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 1331 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:3edb3708c8c5 1332 #endif
whismanoid 0:3edb3708c8c5 1333 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 1334 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:3edb3708c8c5 1335 #endif
whismanoid 0:3edb3708c8c5 1336 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 1337 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:3edb3708c8c5 1338 #endif
whismanoid 0:3edb3708c8c5 1339 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 1340 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:3edb3708c8c5 1341 #endif
whismanoid 0:3edb3708c8c5 1342 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 1343 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:3edb3708c8c5 1344 #endif
whismanoid 0:3edb3708c8c5 1345 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 1346 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:3edb3708c8c5 1347 #endif
whismanoid 0:3edb3708c8c5 1348 //
whismanoid 0:3edb3708c8c5 1349 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:3edb3708c8c5 1350 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:3edb3708c8c5 1351 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:3edb3708c8c5 1352 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:3edb3708c8c5 1353 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:3edb3708c8c5 1354 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:3edb3708c8c5 1355 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:3edb3708c8c5 1356 //
whismanoid 0:3edb3708c8c5 1357 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:3edb3708c8c5 1358 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:3edb3708c8c5 1359 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:3edb3708c8c5 1360 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:3edb3708c8c5 1361 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:3edb3708c8c5 1362 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:3edb3708c8c5 1363 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:3edb3708c8c5 1364 //
whismanoid 0:3edb3708c8c5 1365 // these could be additional digitalInOut pins
whismanoid 0:3edb3708c8c5 1366 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 1367 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:3edb3708c8c5 1368 #endif
whismanoid 0:3edb3708c8c5 1369 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 1370 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:3edb3708c8c5 1371 #endif
whismanoid 0:3edb3708c8c5 1372 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 1373 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:3edb3708c8c5 1374 #endif
whismanoid 0:3edb3708c8c5 1375 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 1376 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:3edb3708c8c5 1377 #endif
whismanoid 0:3edb3708c8c5 1378 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 1379 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1380 #endif
whismanoid 0:3edb3708c8c5 1381 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 1382 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1383 #endif
whismanoid 0:3edb3708c8c5 1384 #else
whismanoid 0:3edb3708c8c5 1385 // unknown target
whismanoid 0:3edb3708c8c5 1386 #endif
whismanoid 0:3edb3708c8c5 1387 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:3edb3708c8c5 1388 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:3edb3708c8c5 1389 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:3edb3708c8c5 1390 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:3edb3708c8c5 1391 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:3edb3708c8c5 1392 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:3edb3708c8c5 1393 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:3edb3708c8c5 1394 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:3edb3708c8c5 1395 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:3edb3708c8c5 1396 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 1397 #define HAS_digitalInOuts 1
whismanoid 0:3edb3708c8c5 1398 #endif
whismanoid 0:3edb3708c8c5 1399
whismanoid 0:3edb3708c8c5 1400 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:3edb3708c8c5 1401 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1402 // Declare the AnalogIn driver
whismanoid 0:3edb3708c8c5 1403 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:3edb3708c8c5 1404 // A) analog input
whismanoid 0:3edb3708c8c5 1405 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 1406 #define HAS_analogIn0 1
whismanoid 0:3edb3708c8c5 1407 #define HAS_analogIn1 1
whismanoid 0:3edb3708c8c5 1408 #define HAS_analogIn2 1
whismanoid 0:3edb3708c8c5 1409 #define HAS_analogIn3 1
whismanoid 0:3edb3708c8c5 1410 #define HAS_analogIn4 1
whismanoid 0:3edb3708c8c5 1411 #define HAS_analogIn5 1
whismanoid 0:3edb3708c8c5 1412 #define HAS_analogIn6 1
whismanoid 0:3edb3708c8c5 1413 #define HAS_analogIn7 1
whismanoid 0:3edb3708c8c5 1414 #define HAS_analogIn8 1
whismanoid 0:3edb3708c8c5 1415 #define HAS_analogIn9 1
whismanoid 0:3edb3708c8c5 1416 // #define HAS_analogIn10 0
whismanoid 0:3edb3708c8c5 1417 // #define HAS_analogIn11 0
whismanoid 0:3edb3708c8c5 1418 // #define HAS_analogIn12 0
whismanoid 0:3edb3708c8c5 1419 // #define HAS_analogIn13 0
whismanoid 0:3edb3708c8c5 1420 // #define HAS_analogIn14 0
whismanoid 0:3edb3708c8c5 1421 // #define HAS_analogIn15 0
whismanoid 0:3edb3708c8c5 1422 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 1423 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1424 #endif
whismanoid 0:3edb3708c8c5 1425 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 1426 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1427 #endif
whismanoid 0:3edb3708c8c5 1428 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 1429 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1430 #endif
whismanoid 0:3edb3708c8c5 1431 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 1432 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1433 #endif
whismanoid 0:3edb3708c8c5 1434 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 1435 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 1436 #endif
whismanoid 0:3edb3708c8c5 1437 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 1438 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 1439 #endif
whismanoid 0:3edb3708c8c5 1440 #if HAS_analogIn6
whismanoid 0:3edb3708c8c5 1441 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 1442 #endif
whismanoid 0:3edb3708c8c5 1443 #if HAS_analogIn7
whismanoid 0:3edb3708c8c5 1444 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1445 #endif
whismanoid 0:3edb3708c8c5 1446 #if HAS_analogIn8
whismanoid 0:3edb3708c8c5 1447 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1448 #endif
whismanoid 0:3edb3708c8c5 1449 #if HAS_analogIn9
whismanoid 0:3edb3708c8c5 1450 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:3edb3708c8c5 1451 #endif
whismanoid 0:3edb3708c8c5 1452 #if HAS_analogIn10
whismanoid 0:3edb3708c8c5 1453 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:3edb3708c8c5 1454 #endif
whismanoid 0:3edb3708c8c5 1455 #if HAS_analogIn11
whismanoid 0:3edb3708c8c5 1456 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 1457 #endif
whismanoid 0:3edb3708c8c5 1458 #if HAS_analogIn12
whismanoid 0:3edb3708c8c5 1459 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 1460 #endif
whismanoid 0:3edb3708c8c5 1461 #if HAS_analogIn13
whismanoid 0:3edb3708c8c5 1462 AnalogIn analogIn13(____);
whismanoid 0:3edb3708c8c5 1463 #endif
whismanoid 0:3edb3708c8c5 1464 #if HAS_analogIn14
whismanoid 0:3edb3708c8c5 1465 AnalogIn analogIn14(____);
whismanoid 0:3edb3708c8c5 1466 #endif
whismanoid 0:3edb3708c8c5 1467 #if HAS_analogIn15
whismanoid 0:3edb3708c8c5 1468 AnalogIn analogIn15(____);
whismanoid 0:3edb3708c8c5 1469 #endif
whismanoid 0:3edb3708c8c5 1470 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1471 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 1472 #define HAS_analogIn0 1
whismanoid 0:3edb3708c8c5 1473 #define HAS_analogIn1 1
whismanoid 0:3edb3708c8c5 1474 #define HAS_analogIn2 1
whismanoid 0:3edb3708c8c5 1475 #define HAS_analogIn3 1
whismanoid 0:3edb3708c8c5 1476 #define HAS_analogIn4 1
whismanoid 0:3edb3708c8c5 1477 #define HAS_analogIn5 1
whismanoid 0:3edb3708c8c5 1478 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 1479 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1480 #endif
whismanoid 0:3edb3708c8c5 1481 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 1482 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1483 #endif
whismanoid 0:3edb3708c8c5 1484 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 1485 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1486 #endif
whismanoid 0:3edb3708c8c5 1487 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 1488 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1489 #endif
whismanoid 0:3edb3708c8c5 1490 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 1491 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 1492 #endif
whismanoid 0:3edb3708c8c5 1493 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 1494 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 1495 #endif
whismanoid 0:3edb3708c8c5 1496 //--------------------------------------------------
whismanoid 17:c2f46173f6b2 1497 #elif defined(TARGET_MAX32620FTHR)
whismanoid 17:c2f46173f6b2 1498 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 17:c2f46173f6b2 1499 #define HAS_analogIn0 1
whismanoid 17:c2f46173f6b2 1500 #define HAS_analogIn1 1
whismanoid 17:c2f46173f6b2 1501 #define HAS_analogIn2 1
whismanoid 17:c2f46173f6b2 1502 #define HAS_analogIn3 1
whismanoid 17:c2f46173f6b2 1503 #define HAS_analogIn4 1
whismanoid 17:c2f46173f6b2 1504 #define HAS_analogIn5 1
whismanoid 17:c2f46173f6b2 1505 #define HAS_analogIn6 1
whismanoid 17:c2f46173f6b2 1506 #define HAS_analogIn7 1
whismanoid 17:c2f46173f6b2 1507 #define HAS_analogIn8 1
whismanoid 17:c2f46173f6b2 1508 #define HAS_analogIn9 1
whismanoid 17:c2f46173f6b2 1509 // #define HAS_analogIn10 0
whismanoid 17:c2f46173f6b2 1510 // #define HAS_analogIn11 0
whismanoid 17:c2f46173f6b2 1511 // #define HAS_analogIn12 0
whismanoid 17:c2f46173f6b2 1512 // #define HAS_analogIn13 0
whismanoid 17:c2f46173f6b2 1513 // #define HAS_analogIn14 0
whismanoid 17:c2f46173f6b2 1514 // #define HAS_analogIn15 0
whismanoid 17:c2f46173f6b2 1515 #if HAS_analogIn0
whismanoid 17:c2f46173f6b2 1516 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 17:c2f46173f6b2 1517 #endif
whismanoid 17:c2f46173f6b2 1518 #if HAS_analogIn1
whismanoid 17:c2f46173f6b2 1519 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 17:c2f46173f6b2 1520 #endif
whismanoid 17:c2f46173f6b2 1521 #if HAS_analogIn2
whismanoid 17:c2f46173f6b2 1522 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 17:c2f46173f6b2 1523 #endif
whismanoid 17:c2f46173f6b2 1524 #if HAS_analogIn3
whismanoid 17:c2f46173f6b2 1525 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 17:c2f46173f6b2 1526 #endif
whismanoid 17:c2f46173f6b2 1527 #if HAS_analogIn4
whismanoid 17:c2f46173f6b2 1528 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 17:c2f46173f6b2 1529 #endif
whismanoid 17:c2f46173f6b2 1530 #if HAS_analogIn5
whismanoid 17:c2f46173f6b2 1531 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 17:c2f46173f6b2 1532 #endif
whismanoid 17:c2f46173f6b2 1533 #if HAS_analogIn6
whismanoid 17:c2f46173f6b2 1534 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 17:c2f46173f6b2 1535 #endif
whismanoid 17:c2f46173f6b2 1536 #if HAS_analogIn7
whismanoid 17:c2f46173f6b2 1537 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 17:c2f46173f6b2 1538 #endif
whismanoid 17:c2f46173f6b2 1539 #if HAS_analogIn8
whismanoid 17:c2f46173f6b2 1540 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 17:c2f46173f6b2 1541 #endif
whismanoid 17:c2f46173f6b2 1542 #if HAS_analogIn9
whismanoid 17:c2f46173f6b2 1543 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 17:c2f46173f6b2 1544 #endif
whismanoid 17:c2f46173f6b2 1545 #if HAS_analogIn10
whismanoid 17:c2f46173f6b2 1546 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 17:c2f46173f6b2 1547 #endif
whismanoid 17:c2f46173f6b2 1548 #if HAS_analogIn11
whismanoid 17:c2f46173f6b2 1549 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 17:c2f46173f6b2 1550 #endif
whismanoid 17:c2f46173f6b2 1551 #if HAS_analogIn12
whismanoid 17:c2f46173f6b2 1552 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 17:c2f46173f6b2 1553 #endif
whismanoid 17:c2f46173f6b2 1554 #if HAS_analogIn13
whismanoid 17:c2f46173f6b2 1555 AnalogIn analogIn13(____);
whismanoid 17:c2f46173f6b2 1556 #endif
whismanoid 17:c2f46173f6b2 1557 #if HAS_analogIn14
whismanoid 17:c2f46173f6b2 1558 AnalogIn analogIn14(____);
whismanoid 17:c2f46173f6b2 1559 #endif
whismanoid 17:c2f46173f6b2 1560 #if HAS_analogIn15
whismanoid 17:c2f46173f6b2 1561 AnalogIn analogIn15(____);
whismanoid 17:c2f46173f6b2 1562 #endif
whismanoid 17:c2f46173f6b2 1563 //--------------------------------------------------
whismanoid 17:c2f46173f6b2 1564 #elif defined(TARGET_MAX32625PICO)
whismanoid 17:c2f46173f6b2 1565 #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 17:c2f46173f6b2 1566 #define HAS_analogIn0 1
whismanoid 17:c2f46173f6b2 1567 #define HAS_analogIn1 1
whismanoid 17:c2f46173f6b2 1568 #define HAS_analogIn2 1
whismanoid 17:c2f46173f6b2 1569 #define HAS_analogIn3 1
whismanoid 17:c2f46173f6b2 1570 #define HAS_analogIn4 1
whismanoid 17:c2f46173f6b2 1571 #define HAS_analogIn5 1
whismanoid 17:c2f46173f6b2 1572 #if HAS_analogIn0
whismanoid 17:c2f46173f6b2 1573 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 17:c2f46173f6b2 1574 #endif
whismanoid 17:c2f46173f6b2 1575 #if HAS_analogIn1
whismanoid 17:c2f46173f6b2 1576 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 17:c2f46173f6b2 1577 #endif
whismanoid 17:c2f46173f6b2 1578 #if HAS_analogIn2
whismanoid 17:c2f46173f6b2 1579 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 17:c2f46173f6b2 1580 #endif
whismanoid 17:c2f46173f6b2 1581 #if HAS_analogIn3
whismanoid 17:c2f46173f6b2 1582 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 17:c2f46173f6b2 1583 #endif
whismanoid 17:c2f46173f6b2 1584 #if HAS_analogIn4
whismanoid 17:c2f46173f6b2 1585 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 17:c2f46173f6b2 1586 #endif
whismanoid 17:c2f46173f6b2 1587 #if HAS_analogIn5
whismanoid 17:c2f46173f6b2 1588 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 17:c2f46173f6b2 1589 #endif
whismanoid 17:c2f46173f6b2 1590 //--------------------------------------------------
whismanoid 12:28aca24adc15 1591 #elif defined(TARGET_MAX32600)
whismanoid 12:28aca24adc15 1592 #define HAS_analogIn0 1
whismanoid 12:28aca24adc15 1593 #define HAS_analogIn1 1
whismanoid 12:28aca24adc15 1594 #define HAS_analogIn2 1
whismanoid 12:28aca24adc15 1595 #define HAS_analogIn3 1
whismanoid 12:28aca24adc15 1596 #define HAS_analogIn4 1
whismanoid 12:28aca24adc15 1597 #define HAS_analogIn5 1
whismanoid 12:28aca24adc15 1598 #if HAS_analogIn0
whismanoid 12:28aca24adc15 1599 AnalogIn analogIn0(A0);
whismanoid 12:28aca24adc15 1600 #endif
whismanoid 12:28aca24adc15 1601 #if HAS_analogIn1
whismanoid 12:28aca24adc15 1602 AnalogIn analogIn1(A1);
whismanoid 12:28aca24adc15 1603 #endif
whismanoid 12:28aca24adc15 1604 #if HAS_analogIn2
whismanoid 12:28aca24adc15 1605 AnalogIn analogIn2(A2);
whismanoid 12:28aca24adc15 1606 #endif
whismanoid 12:28aca24adc15 1607 #if HAS_analogIn3
whismanoid 12:28aca24adc15 1608 AnalogIn analogIn3(A3);
whismanoid 12:28aca24adc15 1609 #endif
whismanoid 12:28aca24adc15 1610 #if HAS_analogIn4
whismanoid 12:28aca24adc15 1611 AnalogIn analogIn4(A4);
whismanoid 12:28aca24adc15 1612 #endif
whismanoid 12:28aca24adc15 1613 #if HAS_analogIn5
whismanoid 12:28aca24adc15 1614 AnalogIn analogIn5(A5);
whismanoid 12:28aca24adc15 1615 #endif
whismanoid 12:28aca24adc15 1616 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1617 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 1618 #define HAS_analogIn0 1
whismanoid 0:3edb3708c8c5 1619 #define HAS_analogIn1 1
whismanoid 0:3edb3708c8c5 1620 #define HAS_analogIn2 1
whismanoid 0:3edb3708c8c5 1621 #define HAS_analogIn3 1
whismanoid 0:3edb3708c8c5 1622 #define HAS_analogIn4 1
whismanoid 0:3edb3708c8c5 1623 #define HAS_analogIn5 1
whismanoid 0:3edb3708c8c5 1624 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 1625 AnalogIn analogIn0(A0);
whismanoid 0:3edb3708c8c5 1626 #endif
whismanoid 0:3edb3708c8c5 1627 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 1628 AnalogIn analogIn1(A1);
whismanoid 0:3edb3708c8c5 1629 #endif
whismanoid 0:3edb3708c8c5 1630 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 1631 AnalogIn analogIn2(A2);
whismanoid 0:3edb3708c8c5 1632 #endif
whismanoid 0:3edb3708c8c5 1633 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 1634 AnalogIn analogIn3(A3);
whismanoid 0:3edb3708c8c5 1635 #endif
whismanoid 0:3edb3708c8c5 1636 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 1637 AnalogIn analogIn4(A4);
whismanoid 0:3edb3708c8c5 1638 #endif
whismanoid 0:3edb3708c8c5 1639 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 1640 AnalogIn analogIn5(A5);
whismanoid 0:3edb3708c8c5 1641 #endif
whismanoid 0:3edb3708c8c5 1642 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1643 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 1644 #define HAS_analogIn0 1
whismanoid 0:3edb3708c8c5 1645 #define HAS_analogIn1 1
whismanoid 0:3edb3708c8c5 1646 #define HAS_analogIn2 1
whismanoid 0:3edb3708c8c5 1647 #define HAS_analogIn3 1
whismanoid 0:3edb3708c8c5 1648 #define HAS_analogIn4 1
whismanoid 0:3edb3708c8c5 1649 #define HAS_analogIn5 1
whismanoid 0:3edb3708c8c5 1650 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 1651 AnalogIn analogIn0(A0);
whismanoid 0:3edb3708c8c5 1652 #endif
whismanoid 0:3edb3708c8c5 1653 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 1654 AnalogIn analogIn1(A1);
whismanoid 0:3edb3708c8c5 1655 #endif
whismanoid 0:3edb3708c8c5 1656 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 1657 AnalogIn analogIn2(A2);
whismanoid 0:3edb3708c8c5 1658 #endif
whismanoid 0:3edb3708c8c5 1659 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 1660 AnalogIn analogIn3(A3);
whismanoid 0:3edb3708c8c5 1661 #endif
whismanoid 0:3edb3708c8c5 1662 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 1663 AnalogIn analogIn4(A4);
whismanoid 0:3edb3708c8c5 1664 #endif
whismanoid 0:3edb3708c8c5 1665 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 1666 AnalogIn analogIn5(A5);
whismanoid 0:3edb3708c8c5 1667 #endif
whismanoid 0:3edb3708c8c5 1668 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1669 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:3edb3708c8c5 1670 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 1671 #define HAS_analogIn0 1
whismanoid 0:3edb3708c8c5 1672 #define HAS_analogIn1 1
whismanoid 0:3edb3708c8c5 1673 #define HAS_analogIn2 1
whismanoid 0:3edb3708c8c5 1674 #define HAS_analogIn3 1
whismanoid 0:3edb3708c8c5 1675 #define HAS_analogIn4 1
whismanoid 0:3edb3708c8c5 1676 #define HAS_analogIn5 1
whismanoid 0:3edb3708c8c5 1677 // #define HAS_analogIn6 1
whismanoid 0:3edb3708c8c5 1678 // #define HAS_analogIn7 1
whismanoid 0:3edb3708c8c5 1679 // #define HAS_analogIn8 1
whismanoid 0:3edb3708c8c5 1680 // #define HAS_analogIn9 1
whismanoid 0:3edb3708c8c5 1681 // #define HAS_analogIn10 1
whismanoid 0:3edb3708c8c5 1682 // #define HAS_analogIn11 1
whismanoid 0:3edb3708c8c5 1683 // #define HAS_analogIn12 1
whismanoid 0:3edb3708c8c5 1684 // #define HAS_analogIn13 1
whismanoid 0:3edb3708c8c5 1685 // #define HAS_analogIn14 1
whismanoid 0:3edb3708c8c5 1686 // #define HAS_analogIn15 1
whismanoid 0:3edb3708c8c5 1687 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 1688 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:3edb3708c8c5 1689 #endif
whismanoid 0:3edb3708c8c5 1690 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 1691 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:3edb3708c8c5 1692 #endif
whismanoid 0:3edb3708c8c5 1693 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 1694 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:3edb3708c8c5 1695 #endif
whismanoid 0:3edb3708c8c5 1696 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 1697 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:3edb3708c8c5 1698 #endif
whismanoid 0:3edb3708c8c5 1699 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 1700 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:3edb3708c8c5 1701 #endif
whismanoid 0:3edb3708c8c5 1702 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 1703 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:3edb3708c8c5 1704 #endif
whismanoid 0:3edb3708c8c5 1705 #if HAS_analogIn6
whismanoid 0:3edb3708c8c5 1706 AnalogIn analogIn6(____);
whismanoid 0:3edb3708c8c5 1707 #endif
whismanoid 0:3edb3708c8c5 1708 #if HAS_analogIn7
whismanoid 0:3edb3708c8c5 1709 AnalogIn analogIn7(____);
whismanoid 0:3edb3708c8c5 1710 #endif
whismanoid 0:3edb3708c8c5 1711 #if HAS_analogIn8
whismanoid 0:3edb3708c8c5 1712 AnalogIn analogIn8(____);
whismanoid 0:3edb3708c8c5 1713 #endif
whismanoid 0:3edb3708c8c5 1714 #if HAS_analogIn9
whismanoid 0:3edb3708c8c5 1715 AnalogIn analogIn9(____);
whismanoid 0:3edb3708c8c5 1716 #endif
whismanoid 0:3edb3708c8c5 1717 #if HAS_analogIn10
whismanoid 0:3edb3708c8c5 1718 AnalogIn analogIn10(____);
whismanoid 0:3edb3708c8c5 1719 #endif
whismanoid 0:3edb3708c8c5 1720 #if HAS_analogIn11
whismanoid 0:3edb3708c8c5 1721 AnalogIn analogIn11(____);
whismanoid 0:3edb3708c8c5 1722 #endif
whismanoid 0:3edb3708c8c5 1723 #if HAS_analogIn12
whismanoid 0:3edb3708c8c5 1724 AnalogIn analogIn12(____);
whismanoid 0:3edb3708c8c5 1725 #endif
whismanoid 0:3edb3708c8c5 1726 #if HAS_analogIn13
whismanoid 0:3edb3708c8c5 1727 AnalogIn analogIn13(____);
whismanoid 0:3edb3708c8c5 1728 #endif
whismanoid 0:3edb3708c8c5 1729 #if HAS_analogIn14
whismanoid 0:3edb3708c8c5 1730 AnalogIn analogIn14(____);
whismanoid 0:3edb3708c8c5 1731 #endif
whismanoid 0:3edb3708c8c5 1732 #if HAS_analogIn15
whismanoid 0:3edb3708c8c5 1733 AnalogIn analogIn15(____);
whismanoid 0:3edb3708c8c5 1734 #endif
whismanoid 0:3edb3708c8c5 1735 #else
whismanoid 0:3edb3708c8c5 1736 // unknown target
whismanoid 0:3edb3708c8c5 1737 #endif
whismanoid 0:3edb3708c8c5 1738 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:3edb3708c8c5 1739 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:3edb3708c8c5 1740 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:3edb3708c8c5 1741 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:3edb3708c8c5 1742 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:3edb3708c8c5 1743 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:3edb3708c8c5 1744 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:3edb3708c8c5 1745 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:3edb3708c8c5 1746 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:3edb3708c8c5 1747 #define HAS_analogIns 1
whismanoid 0:3edb3708c8c5 1748 #endif
whismanoid 0:3edb3708c8c5 1749
whismanoid 0:3edb3708c8c5 1750 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1751 // Option to use LEDs to show status
whismanoid 0:3edb3708c8c5 1752 #ifndef USE_LEDS
whismanoid 0:3edb3708c8c5 1753 #define USE_LEDS 1
whismanoid 0:3edb3708c8c5 1754 #endif
whismanoid 0:3edb3708c8c5 1755 #if USE_LEDS
whismanoid 0:3edb3708c8c5 1756 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 1757 # define LED_ON 0
whismanoid 0:3edb3708c8c5 1758 # define LED_OFF 1
whismanoid 0:3edb3708c8c5 1759 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1760 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 1761 # define LED_ON 0
whismanoid 0:3edb3708c8c5 1762 # define LED_OFF 1
whismanoid 0:3edb3708c8c5 1763 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1764 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:3edb3708c8c5 1765 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 1766 # define LED_ON 1
whismanoid 0:3edb3708c8c5 1767 # define LED_OFF 0
whismanoid 0:3edb3708c8c5 1768 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:3edb3708c8c5 1769 # define LED_ON 1
whismanoid 0:3edb3708c8c5 1770 # define LED_OFF 0
whismanoid 0:3edb3708c8c5 1771 #endif // target definition
whismanoid 0:3edb3708c8c5 1772 DigitalOut led1(LED1, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 0:3edb3708c8c5 1773 DigitalOut led2(LED2, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 0:3edb3708c8c5 1774 DigitalOut led3(LED3, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 0:3edb3708c8c5 1775 DigitalOut led4(LED4, LED_OFF);
whismanoid 13:7757d28efaa5 1776 #else // USE_LEDS=0
whismanoid 13:7757d28efaa5 1777 // issue #41 support Nucleo_F446RE
whismanoid 13:7757d28efaa5 1778 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 13:7757d28efaa5 1779 // but we still need placeholders led1 led2 led3 led4.
whismanoid 13:7757d28efaa5 1780 // Declare DigitalOut led1 led2 led3 led4 targeting safe pins.
whismanoid 13:7757d28efaa5 1781 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 13:7757d28efaa5 1782 # define LED_ON 0
whismanoid 13:7757d28efaa5 1783 # define LED_OFF 1
whismanoid 13:7757d28efaa5 1784 DigitalOut led1(NC, LED_OFF);
whismanoid 13:7757d28efaa5 1785 DigitalOut led2(NC, LED_OFF);
whismanoid 13:7757d28efaa5 1786 DigitalOut led3(NC, LED_OFF);
whismanoid 13:7757d28efaa5 1787 DigitalOut led4(NC, LED_OFF);
whismanoid 0:3edb3708c8c5 1788 #endif // USE_LEDS
whismanoid 0:3edb3708c8c5 1789
whismanoid 0:3edb3708c8c5 1790 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1791 #if USE_LEDS
whismanoid 0:3edb3708c8c5 1792 class RGB_LED {
whismanoid 0:3edb3708c8c5 1793 public:
whismanoid 0:3edb3708c8c5 1794 RGB_LED(DigitalOut &led_red, DigitalOut &led_green, DigitalOut &led_blue)
whismanoid 0:3edb3708c8c5 1795 : m_red(led_red), m_green(led_green), m_blue(led_blue)
whismanoid 0:3edb3708c8c5 1796 {
whismanoid 0:3edb3708c8c5 1797 };
whismanoid 0:3edb3708c8c5 1798 DigitalOut &m_red;
whismanoid 0:3edb3708c8c5 1799 DigitalOut &m_green;
whismanoid 0:3edb3708c8c5 1800 DigitalOut &m_blue;
whismanoid 0:3edb3708c8c5 1801 ~RGB_LED()
whismanoid 0:3edb3708c8c5 1802 {
whismanoid 0:3edb3708c8c5 1803 };
whismanoid 0:3edb3708c8c5 1804 /* diagnostic rbg led RED
whismanoid 0:3edb3708c8c5 1805 */
whismanoid 0:3edb3708c8c5 1806 void red() {
whismanoid 0:3edb3708c8c5 1807 m_red = LED_ON; m_green = LED_OFF; m_blue = LED_OFF; // diagnostic rbg led RED
whismanoid 0:3edb3708c8c5 1808 };
whismanoid 0:3edb3708c8c5 1809 /* diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 1810 */
whismanoid 0:3edb3708c8c5 1811 void green() {
whismanoid 0:3edb3708c8c5 1812 m_red = LED_OFF; m_green = LED_ON; m_blue = LED_OFF; // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 1813 };
whismanoid 0:3edb3708c8c5 1814 /* diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 1815 */
whismanoid 0:3edb3708c8c5 1816 void blue() {
whismanoid 0:3edb3708c8c5 1817 m_red = LED_OFF; m_green = LED_OFF; m_blue = LED_ON; // diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 1818 };
whismanoid 0:3edb3708c8c5 1819 /* diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 0:3edb3708c8c5 1820 */
whismanoid 0:3edb3708c8c5 1821 void white() {
whismanoid 0:3edb3708c8c5 1822 m_red = LED_ON; m_green = LED_ON; m_blue = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 0:3edb3708c8c5 1823 };
whismanoid 0:3edb3708c8c5 1824 /* diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 0:3edb3708c8c5 1825 */
whismanoid 0:3edb3708c8c5 1826 void cyan() {
whismanoid 0:3edb3708c8c5 1827 m_red = LED_OFF; m_green = LED_ON; m_blue = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 0:3edb3708c8c5 1828 };
whismanoid 0:3edb3708c8c5 1829 /* diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 0:3edb3708c8c5 1830 */
whismanoid 0:3edb3708c8c5 1831 void magenta() {
whismanoid 0:3edb3708c8c5 1832 m_red = LED_ON; m_green = LED_OFF; m_blue = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 0:3edb3708c8c5 1833 };
whismanoid 0:3edb3708c8c5 1834 /* diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 1835 */
whismanoid 0:3edb3708c8c5 1836 void yellow() {
whismanoid 0:3edb3708c8c5 1837 m_red = LED_ON; m_green = LED_ON; m_blue = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 1838 };
whismanoid 0:3edb3708c8c5 1839 /* diagnostic rbg led BLACK
whismanoid 0:3edb3708c8c5 1840 */
whismanoid 0:3edb3708c8c5 1841 void black() {
whismanoid 0:3edb3708c8c5 1842 m_red = LED_OFF; m_green = LED_OFF; m_blue = LED_OFF; // diagnostic rbg led BLACK
whismanoid 0:3edb3708c8c5 1843 };
whismanoid 0:3edb3708c8c5 1844 };
whismanoid 0:3edb3708c8c5 1845 RGB_LED rgb_led(led1, led2, led3); // red, green, blue LEDs
whismanoid 0:3edb3708c8c5 1846 #endif // USE_LEDS
whismanoid 0:3edb3708c8c5 1847
whismanoid 0:3edb3708c8c5 1848 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1849 // use BUTTON1 trigger some action
whismanoid 0:3edb3708c8c5 1850 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 1851 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 14:93dbe154f46b 1852 #define HAS_BUTTON2_DEMO 0
whismanoid 14:93dbe154f46b 1853 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 17:c2f46173f6b2 1854 #elif defined(TARGET_MAX32625PICO)
whismanoid 17:c2f46173f6b2 1855 #warning "TARGET_MAX32625PICO not previously tested; need to define buttons..."
whismanoid 17:c2f46173f6b2 1856 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 17:c2f46173f6b2 1857 #define HAS_BUTTON2_DEMO 0
whismanoid 17:c2f46173f6b2 1858 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 0:3edb3708c8c5 1859 #elif defined(TARGET_MAX32625)
whismanoid 0:3edb3708c8c5 1860 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 0:3edb3708c8c5 1861 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 17:c2f46173f6b2 1862 #elif defined(TARGET_MAX32620FTHR)
whismanoid 17:c2f46173f6b2 1863 #warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..."
whismanoid 17:c2f46173f6b2 1864 #define BUTTON1 SW1
whismanoid 17:c2f46173f6b2 1865 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 17:c2f46173f6b2 1866 #define HAS_BUTTON2_DEMO 0
whismanoid 17:c2f46173f6b2 1867 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 0:3edb3708c8c5 1868 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 1869 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 0:3edb3708c8c5 1870 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 0:3edb3708c8c5 1871 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 1872 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 0:3edb3708c8c5 1873 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 17:c2f46173f6b2 1874 #else
whismanoid 17:c2f46173f6b2 1875 #warning "target not previously tested; need to define buttons..."
whismanoid 0:3edb3708c8c5 1876 #endif
whismanoid 0:3edb3708c8c5 1877 //
whismanoid 0:3edb3708c8c5 1878 #ifndef HAS_BUTTON1_DEMO
whismanoid 0:3edb3708c8c5 1879 #define HAS_BUTTON1_DEMO 0
whismanoid 0:3edb3708c8c5 1880 #endif
whismanoid 0:3edb3708c8c5 1881 #ifndef HAS_BUTTON2_DEMO
whismanoid 0:3edb3708c8c5 1882 #define HAS_BUTTON2_DEMO 0
whismanoid 0:3edb3708c8c5 1883 #endif
whismanoid 0:3edb3708c8c5 1884 //
whismanoid 0:3edb3708c8c5 1885 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 0:3edb3708c8c5 1886 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 0:3edb3708c8c5 1887 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 1888 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 0:3edb3708c8c5 1889 #endif
whismanoid 0:3edb3708c8c5 1890 //
whismanoid 0:3edb3708c8c5 1891 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 1892 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 0:3edb3708c8c5 1893 #endif
whismanoid 0:3edb3708c8c5 1894 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 1895 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 0:3edb3708c8c5 1896 #endif
whismanoid 0:3edb3708c8c5 1897 //
whismanoid 0:3edb3708c8c5 1898 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 1899 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 1900 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 0:3edb3708c8c5 1901 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 0:3edb3708c8c5 1902 DigitalIn button1(BUTTON1);
whismanoid 0:3edb3708c8c5 1903 # else
whismanoid 0:3edb3708c8c5 1904 InterruptIn button1(BUTTON1);
whismanoid 0:3edb3708c8c5 1905 # endif
whismanoid 0:3edb3708c8c5 1906 #elif HAS_BUTTON1_DEMO
whismanoid 0:3edb3708c8c5 1907 DigitalIn button1(BUTTON1);
whismanoid 0:3edb3708c8c5 1908 #endif
whismanoid 0:3edb3708c8c5 1909 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 1910 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 1911 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 0:3edb3708c8c5 1912 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 0:3edb3708c8c5 1913 DigitalIn button2(BUTTON2);
whismanoid 0:3edb3708c8c5 1914 # else
whismanoid 0:3edb3708c8c5 1915 InterruptIn button2(BUTTON2);
whismanoid 0:3edb3708c8c5 1916 # endif
whismanoid 0:3edb3708c8c5 1917 #elif HAS_BUTTON2_DEMO
whismanoid 0:3edb3708c8c5 1918 DigitalIn button2(BUTTON2);
whismanoid 0:3edb3708c8c5 1919 #endif
whismanoid 0:3edb3708c8c5 1920
whismanoid 0:3edb3708c8c5 1921 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1922 // Ticker is the periodic interrupt timer itself
whismanoid 17:c2f46173f6b2 1923 #ifndef USE_PERIODIC_TIMER
whismanoid 0:3edb3708c8c5 1924 #define USE_PERIODIC_TIMER 0
whismanoid 17:c2f46173f6b2 1925 #endif
whismanoid 0:3edb3708c8c5 1926 #if USE_PERIODIC_TIMER
whismanoid 0:3edb3708c8c5 1927 Ticker periodicInterruptTimer;
whismanoid 0:3edb3708c8c5 1928 us_timestamp_t periodicInterruptTimer_interval_usec = 50;
whismanoid 0:3edb3708c8c5 1929 us_timestamp_t periodicInterruptTimer_interval_usec_MAX = 1000;
whismanoid 0:3edb3708c8c5 1930 us_timestamp_t periodicInterruptTimer_interval_usec_MIN = 20;
whismanoid 0:3edb3708c8c5 1931 #endif
whismanoid 0:3edb3708c8c5 1932
whismanoid 0:3edb3708c8c5 1933
whismanoid 0:3edb3708c8c5 1934 #if APPLICATION_MAX11131 // hardware interface functions
whismanoid 0:3edb3708c8c5 1935 //----------------------------------------
whismanoid 0:3edb3708c8c5 1936 void print_value(CmdLine& cmdLine, int16_t value_u12, int channelId)
whismanoid 0:3edb3708c8c5 1937 {
whismanoid 0:3edb3708c8c5 1938 int channelPairIndex = channelId / 2;
whismanoid 0:3edb3708c8c5 1939 // format: 1 0 0 0 1 UCH0/1 UCH2/3 UCH4/5 UCH6/7 UCH8/9 UCH10/11 UCH12/13 UCH14/15 PDIFF_COM x x
whismanoid 0:3edb3708c8c5 1940 // unused variable: int UCHn = (g_MAX11131_device.UNIPOLAR >> (10 - channelPairIndex)) & 0x01;
whismanoid 0:3edb3708c8c5 1941 int BCHn = (g_MAX11131_device.BIPOLAR >> (10 - channelPairIndex)) & 0x01;
whismanoid 0:3edb3708c8c5 1942 // unused variable: int RANGEn = (g_MAX11131_device.RANGE >> (10 - channelPairIndex)) & 0x01;
whismanoid 0:3edb3708c8c5 1943 //
whismanoid 0:3edb3708c8c5 1944 cmdLine.serial().printf(" ch=");
whismanoid 0:3edb3708c8c5 1945 // TODO1: if CHANID=0 don't print ch=channelId
whismanoid 0:3edb3708c8c5 1946 if ((g_MAX11131_device.isExternalClock == 0) || (g_MAX11131_device.chan_id_0_1 == 1))
whismanoid 0:3edb3708c8c5 1947 {
whismanoid 0:3edb3708c8c5 1948 // Internal clock modes always use channel ID.
whismanoid 0:3edb3708c8c5 1949 // External clock modes use channel ID if ADC_MODE_CONTROL.CHAN_ID is 1.
whismanoid 0:3edb3708c8c5 1950 cmdLine.serial().printf("%d", channelId);
whismanoid 0:3edb3708c8c5 1951 } else {
whismanoid 0:3edb3708c8c5 1952 cmdLine.serial().printf("?");
whismanoid 0:3edb3708c8c5 1953 }
whismanoid 0:3edb3708c8c5 1954 if (BCHn)
whismanoid 0:3edb3708c8c5 1955 {
whismanoid 3:8913cb4a8b9f 1956 cmdLine.serial().printf(" xb=%ld", g_MAX11131_device.TwosComplementValue(value_u12));
whismanoid 0:3edb3708c8c5 1957 }
whismanoid 0:3edb3708c8c5 1958 else
whismanoid 0:3edb3708c8c5 1959 {
whismanoid 0:3edb3708c8c5 1960 cmdLine.serial().printf(" xu=%d", value_u12);
whismanoid 0:3edb3708c8c5 1961 }
whismanoid 0:3edb3708c8c5 1962 cmdLine.serial().printf(" = 0x%4.4x = %6.4fV",
whismanoid 0:3edb3708c8c5 1963 (value_u12 & 0xFFFF),
whismanoid 0:3edb3708c8c5 1964 g_MAX11131_device.VoltageOfCode(value_u12, channelId)
whismanoid 0:3edb3708c8c5 1965 );
whismanoid 0:3edb3708c8c5 1966 // dtostrf width and precision: 2.5v / 4096 LSB = 0.0006103515625 volts per LSB
whismanoid 0:3edb3708c8c5 1967 }
whismanoid 0:3edb3708c8c5 1968
whismanoid 0:3edb3708c8c5 1969 //----------------------------------------
whismanoid 0:3edb3708c8c5 1970 // read data words
whismanoid 0:3edb3708c8c5 1971 // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 1972 // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 1973 // For internal clock modes, the data format always includes the channel address.
whismanoid 0:3edb3708c8c5 1974 // misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 1975 void AINcode_print_value_chanID(CmdLine& cmdLine, int nWords)
whismanoid 0:3edb3708c8c5 1976 {
whismanoid 0:3edb3708c8c5 1977 cmdLine.serial().printf("ScanRead_nWords_chanID nWords=%d\r\n", nWords);
whismanoid 0:3edb3708c8c5 1978 for (int index = 0; index < nWords; index++) {
whismanoid 0:3edb3708c8c5 1979 //~ int16_t misoData16 = MAX11131_ScanRead();
whismanoid 0:3edb3708c8c5 1980 // For internal clock modes, the data format always includes the channel address.
whismanoid 0:3edb3708c8c5 1981 // misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 1982 int16_t value_u12 = (g_MAX11131_device.RAW_misoData16[index] & 0x0FFF);
whismanoid 0:3edb3708c8c5 1983 int channelId = ((g_MAX11131_device.RAW_misoData16[index] >> 12) & 0x000F);
whismanoid 0:3edb3708c8c5 1984 // diagnostic: print raw MISO data
whismanoid 0:3edb3708c8c5 1985 cmdLine.serial().printf(" MAX11131.MISO[%u]=0x%4.4x:", index,
whismanoid 0:3edb3708c8c5 1986 (g_MAX11131_device.RAW_misoData16[index] & 0xFFFF));
whismanoid 0:3edb3708c8c5 1987 print_value(cmdLine, value_u12, channelId);
whismanoid 0:3edb3708c8c5 1988 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 1989 }
whismanoid 0:3edb3708c8c5 1990 }
whismanoid 0:3edb3708c8c5 1991
whismanoid 0:3edb3708c8c5 1992 //----------------------------------------
whismanoid 0:3edb3708c8c5 1993 // read data words
whismanoid 0:3edb3708c8c5 1994 // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 1995 // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 1996 // For external clock modes, the data format returned depends on the CHAN_ID bit.
whismanoid 0:3edb3708c8c5 1997 // when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x
whismanoid 0:3edb3708c8c5 1998 // when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 1999 void AINcode_print_value_externalClock(CmdLine& cmdLine, int nWords)
whismanoid 0:3edb3708c8c5 2000 {
whismanoid 0:3edb3708c8c5 2001 // For external clock modes, the data format returned depends on the CHAN_ID bit.
whismanoid 0:3edb3708c8c5 2002 // when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x
whismanoid 0:3edb3708c8c5 2003 // when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 2004 // For internal clock modes, the data format always includes the channel address.
whismanoid 0:3edb3708c8c5 2005 // misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 2006 if (g_MAX11131_device.chan_id_0_1 != 0) {
whismanoid 0:3edb3708c8c5 2007 AINcode_print_value_chanID(cmdLine, nWords);
whismanoid 0:3edb3708c8c5 2008 return;
whismanoid 0:3edb3708c8c5 2009 }
whismanoid 0:3edb3708c8c5 2010 cmdLine.serial().printf("ScanRead_nWords_externalClock nWords=%d\r\n", nWords);
whismanoid 0:3edb3708c8c5 2011 for (int index = 0; index < nWords; index++) {
whismanoid 0:3edb3708c8c5 2012 // int16_t misoData16 = MAX11131_ScanRead();
whismanoid 0:3edb3708c8c5 2013 int16_t value_u12 = ((g_MAX11131_device.RAW_misoData16[index] >> 3) & 0x0FFF);
whismanoid 0:3edb3708c8c5 2014 int channelId = g_MAX11131_device.channelNumber_0_15;
whismanoid 0:3edb3708c8c5 2015 // diagnostic: print raw MISO data
whismanoid 0:3edb3708c8c5 2016 cmdLine.serial().printf(" MAX11131.MISO[%u]=0x%4.4x:", index,
whismanoid 0:3edb3708c8c5 2017 (g_MAX11131_device.RAW_misoData16[index] & 0xFFFF));
whismanoid 0:3edb3708c8c5 2018 print_value(cmdLine, value_u12, channelId);
whismanoid 0:3edb3708c8c5 2019 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 2020 }
whismanoid 0:3edb3708c8c5 2021 }
whismanoid 0:3edb3708c8c5 2022
whismanoid 0:3edb3708c8c5 2023 //----------------------------------------
whismanoid 0:3edb3708c8c5 2024 // read data words and calculate mean, stddev
whismanoid 0:3edb3708c8c5 2025 // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 2026 // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 2027 void AINcode_print_value_chanID_mean(CmdLine& cmdLine, int nWords)
whismanoid 0:3edb3708c8c5 2028 {
whismanoid 0:3edb3708c8c5 2029 cmdLine.serial().printf("ScanRead_nWords_chanID_mean nWords=%d\r\n", nWords);
whismanoid 0:3edb3708c8c5 2030 double Sx = 0;
whismanoid 0:3edb3708c8c5 2031 double Sxx = 0;
whismanoid 0:3edb3708c8c5 2032 for (int index = 0; index < nWords; index++) {
whismanoid 0:3edb3708c8c5 2033 //~ int16_t misoData16 = MAX11131_ScanRead();
whismanoid 0:3edb3708c8c5 2034 // For internal clock modes, the data format always includes the channel address.
whismanoid 0:3edb3708c8c5 2035 // misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 2036 int16_t value_u12 = (g_MAX11131_device.RAW_misoData16[index] & 0x0FFF);
whismanoid 0:3edb3708c8c5 2037 int channelId = ((g_MAX11131_device.RAW_misoData16[index] >> 12) & 0x000F);
whismanoid 0:3edb3708c8c5 2038 // TODO: sign-extend value_s12 from value_u12
whismanoid 0:3edb3708c8c5 2039 //
whismanoid 0:3edb3708c8c5 2040 cmdLine.serial().printf("n=%d", index);
whismanoid 0:3edb3708c8c5 2041 print_value(cmdLine, value_u12, channelId);
whismanoid 0:3edb3708c8c5 2042 //
whismanoid 0:3edb3708c8c5 2043 Sx = Sx + value_u12;
whismanoid 0:3edb3708c8c5 2044 Sxx = Sxx + ((double)value_u12 * value_u12);
whismanoid 0:3edb3708c8c5 2045 cmdLine.serial().printf(" Sx=%f Sxx=%f\r\n", Sx, Sxx);
whismanoid 0:3edb3708c8c5 2046 }
whismanoid 0:3edb3708c8c5 2047 double mean = Sx / nWords;
whismanoid 0:3edb3708c8c5 2048 cmdLine.serial().printf(" mean=%f=0x%4.4x", mean, (int)mean);
whismanoid 0:3edb3708c8c5 2049 // calculate standard deviation from N, Sx, Sxx
whismanoid 0:3edb3708c8c5 2050 if (nWords >= 2)
whismanoid 0:3edb3708c8c5 2051 {
whismanoid 0:3edb3708c8c5 2052 double variance = (Sxx - ( Sx * Sx / nWords)) / (nWords - 1);
whismanoid 0:3edb3708c8c5 2053 // stddev = square root of variance
whismanoid 0:3edb3708c8c5 2054 double stddev = sqrt(variance);
whismanoid 0:3edb3708c8c5 2055 cmdLine.serial().printf(" variance=%f stddev=%f", variance, stddev);
whismanoid 0:3edb3708c8c5 2056 }
whismanoid 0:3edb3708c8c5 2057 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 2058 }
whismanoid 0:3edb3708c8c5 2059
whismanoid 0:3edb3708c8c5 2060 /* MAX11131_print_register_verbose
whismanoid 0:3edb3708c8c5 2061 *
whismanoid 0:3edb3708c8c5 2062 * TODO: document this function
whismanoid 0:3edb3708c8c5 2063 * This header was inserted by uncrustify; see uncrustify_func_header.txt.
whismanoid 0:3edb3708c8c5 2064 *
whismanoid 0:3edb3708c8c5 2065 */
whismanoid 0:3edb3708c8c5 2066 void MAX11131_print_register_verbose(CmdLine& cmdLine, int16_t registerData)
whismanoid 0:3edb3708c8c5 2067 {
whismanoid 0:3edb3708c8c5 2068 if (registerData & 0x8000)
whismanoid 0:3edb3708c8c5 2069 {
whismanoid 0:3edb3708c8c5 2070 switch (registerData & 0xF800)
whismanoid 0:3edb3708c8c5 2071 {
whismanoid 0:3edb3708c8c5 2072 case 0x8000: // ADC_CONFIGURATION 0x8000..0x87FF format: 1 0 0 0 0 REFSEL AVGON NAVG[1:0] NSCAN[1:0] SPM[1:0] ECHO 0 0
whismanoid 0:3edb3708c8c5 2073 cmdLine.serial().printf(" ADC_CONFIGURATION");
whismanoid 0:3edb3708c8c5 2074 {
whismanoid 0:3edb3708c8c5 2075 // define write-only register ADC_CONFIGURATION
whismanoid 0:3edb3708c8c5 2076 //int16_t ADC_CONFIGURATION = 0x8000; //!< registerData 0x8000..0x87FF format: 1 0 0 0 0 REFSEL AVGON NAVG[1:0] NSCAN[1:0] SPM[1:0] ECHO 0 0
whismanoid 0:3edb3708c8c5 2077 const int REFSEL_LSB = 10; const int REFSEL_BITS = 0x01; // ADC_CONFIGURATION.REFSEL
whismanoid 0:3edb3708c8c5 2078 const int AVGON_LSB = 9; const int AVGON_BITS = 0x01; // ADC_CONFIGURATION.AVGON
whismanoid 0:3edb3708c8c5 2079 const int NAVG_LSB = 7; const int NAVG_BITS = 0x03; // ADC_CONFIGURATION.NAVG[1:0]
whismanoid 0:3edb3708c8c5 2080 const int NSCAN_LSB = 5; const int NSCAN_BITS = 0x03; // ADC_CONFIGURATION.NSCAN[1:0]
whismanoid 0:3edb3708c8c5 2081 const int SPM_LSB = 3; const int SPM_BITS = 0x03; // ADC_CONFIGURATION.SPM[1:0]
whismanoid 0:3edb3708c8c5 2082 const int ECHO_LSB = 2; const int ECHO_BITS = 0x01; // ADC_CONFIGURATION.ECHO
whismanoid 0:3edb3708c8c5 2083
whismanoid 0:3edb3708c8c5 2084 const int REFSEL = ((registerData >> REFSEL_LSB) & REFSEL_BITS);
whismanoid 0:3edb3708c8c5 2085 const int AVGON = ((registerData >> AVGON_LSB) & AVGON_BITS);
whismanoid 0:3edb3708c8c5 2086 const int NAVG = ((registerData >> NAVG_LSB) & NAVG_BITS);
whismanoid 0:3edb3708c8c5 2087 const int NSCAN = ((registerData >> NSCAN_LSB) & NSCAN_BITS);
whismanoid 0:3edb3708c8c5 2088 const int SPM = ((registerData >> SPM_LSB) & SPM_BITS);
whismanoid 0:3edb3708c8c5 2089 const int ECHO = ((registerData >> ECHO_LSB) & ECHO_BITS);
whismanoid 0:3edb3708c8c5 2090
whismanoid 0:3edb3708c8c5 2091 if (REFSEL) {
whismanoid 0:3edb3708c8c5 2092 cmdLine.serial().printf(" REFSEL=%d", REFSEL);
whismanoid 0:3edb3708c8c5 2093 }
whismanoid 0:3edb3708c8c5 2094 if (AVGON) {
whismanoid 0:3edb3708c8c5 2095 cmdLine.serial().printf(" AVGON=%d", AVGON);
whismanoid 0:3edb3708c8c5 2096 }
whismanoid 0:3edb3708c8c5 2097 if (NAVG) {
whismanoid 0:3edb3708c8c5 2098 cmdLine.serial().printf(" NAVG=%d", NAVG);
whismanoid 0:3edb3708c8c5 2099 }
whismanoid 0:3edb3708c8c5 2100 if (NSCAN) {
whismanoid 0:3edb3708c8c5 2101 cmdLine.serial().printf(" NSCAN=%d", NSCAN);
whismanoid 0:3edb3708c8c5 2102 }
whismanoid 0:3edb3708c8c5 2103 if (SPM) {
whismanoid 0:3edb3708c8c5 2104 cmdLine.serial().printf(" SPM=%d", SPM);
whismanoid 0:3edb3708c8c5 2105 }
whismanoid 0:3edb3708c8c5 2106 if (ECHO) {
whismanoid 0:3edb3708c8c5 2107 cmdLine.serial().printf(" ECHO=%d", ECHO);
whismanoid 0:3edb3708c8c5 2108 }
whismanoid 0:3edb3708c8c5 2109 }
whismanoid 0:3edb3708c8c5 2110 break;
whismanoid 0:3edb3708c8c5 2111 case 0x8800: // UNIPOLAR 0x8800..0x8FFF format: 1 0 0 0 1 UCH0/1 UCH2/3 UCH4/5 UCH6/7 UCH8/9 UCH10/11 UCH12/13 UCH14/15 PDIFF_COM x x
whismanoid 0:3edb3708c8c5 2112 cmdLine.serial().printf(" UNIPOLAR 0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 2113 if ((registerData >> 2) & 0x01) {
whismanoid 0:3edb3708c8c5 2114 cmdLine.serial().printf(" PDIFF_COM");
whismanoid 0:3edb3708c8c5 2115 }
whismanoid 0:3edb3708c8c5 2116 break;
whismanoid 0:3edb3708c8c5 2117 case 0x9000: // BIPOLAR 0x9000..0x97FF format: 1 0 0 1 0 BCH0/1 BCH2/3 BCH4/5 BCH6/7 BCH8/9 BCH10/11 BCH12/13 BCH14/15 x x x
whismanoid 0:3edb3708c8c5 2118 cmdLine.serial().printf(" BIPOLAR 0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 2119 break;
whismanoid 0:3edb3708c8c5 2120 case 0x9800: // RANGE 0x9800..0x9FFF format: 1 0 0 1 1 RANGE0/1 RANGE2/3 RANGE4/5 RANGE6/7 RANGE8/9 RANGE10/11 RANGE12/13 RANGE14/15 x x x
whismanoid 0:3edb3708c8c5 2121 cmdLine.serial().printf(" RANGE 0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 2122 break;
whismanoid 0:3edb3708c8c5 2123 case 0xA000: // CSCAN0 0xA000..0xA7FF format: 1 0 1 0 0 CHSCAN15 CHSCAN14 CHSCAN13 CHSCAN12 CHSCAN11 CHSCAN10 CHSCAN9 CHSCAN8 x x x
whismanoid 0:3edb3708c8c5 2124 cmdLine.serial().printf(" CSCAN0 0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 2125 break;
whismanoid 0:3edb3708c8c5 2126 case 0xA800: // CSCAN1 0xA800..0xAFFF format: 1 0 1 0 1 CHSCAN7 CHSCAN6 CHSCAN5 CHSCAN4 CHSCAN3 CHSCAN2 CHSCAN1 CHSCAN0 x x x
whismanoid 0:3edb3708c8c5 2127 cmdLine.serial().printf(" CSCAN1 0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 2128 break;
whismanoid 0:3edb3708c8c5 2129 case 0xB000: // SAMPLESET 0xB000..0xB7FF format: 1 0 1 1 0 SEQ_LENGTH[7:0] x x x
whismanoid 0:3edb3708c8c5 2130 cmdLine.serial().printf(" SAMPLESET SEQ_LENGTH[7:0]=0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 2131 cmdLine.serial().printf(" so length=%d channels", (((registerData >> 3) & 0xFF) + 1));
whismanoid 0:3edb3708c8c5 2132 break;
whismanoid 0:3edb3708c8c5 2133 default:
whismanoid 0:3edb3708c8c5 2134 cmdLine.serial().printf(" ???");
whismanoid 0:3edb3708c8c5 2135 break;
whismanoid 0:3edb3708c8c5 2136 }
whismanoid 0:3edb3708c8c5 2137 }
whismanoid 0:3edb3708c8c5 2138 else
whismanoid 0:3edb3708c8c5 2139 {
whismanoid 0:3edb3708c8c5 2140 // ADC_MODE_CONTROL 0x0000..0x7FFF format: 0 SCAN[3:0] CHSEL[3:0] RESET[1:0] PM[1:0] CHAN_ID SWCNV 0
whismanoid 0:3edb3708c8c5 2141 cmdLine.serial().printf(" ADC_MODE_CONTROL");
whismanoid 0:3edb3708c8c5 2142
whismanoid 0:3edb3708c8c5 2143 // define write-only register ADC_MODE_CONTROL
whismanoid 0:3edb3708c8c5 2144 //int16_t ADC_MODE_CONTROL = 0; //!< registerData 0x0000..0x7FFF format: 0 SCAN[3:0] CHSEL[3:0] RESET[1:0] PM[1:0] CHAN_ID SWCNV 0
whismanoid 0:3edb3708c8c5 2145 const int SCAN_LSB = 11; const int SCAN_BITS = 0x0F; //!< ADC_MODE_CONTROL.SCAN[3:0] ADC Scan Control (command)
whismanoid 0:3edb3708c8c5 2146 const int CHSEL_LSB = 7; const int CHSEL_BITS = 0x0F; //!< ADC_MODE_CONTROL.CHSEL[3:0] Analog Input Channel Select AIN0..AIN15
whismanoid 0:3edb3708c8c5 2147 const int RESET_LSB = 5; const int RESET_BITS = 0x03; //!< ADC_MODE_CONTROL.RESET[1:0] Reset 0=Normal 1=ResetFIFO 2=ResetAllRegisters 3=reserved
whismanoid 0:3edb3708c8c5 2148 const int PM_LSB = 3; const int PM_BITS = 0x03; //!< ADC_MODE_CONTROL.PM[1:0] Power Management 0=Normal, 1=AutoShutdown, 2=AutoStandby 3=reserved
whismanoid 0:3edb3708c8c5 2149 const int CHAN_ID_LSB = 2; const int CHAN_ID_BITS = 0x01; //!< ADC_MODE_CONTROL.CHAN_ID
whismanoid 0:3edb3708c8c5 2150 const int SWCNV_LSB = 1; const int SWCNV_BITS = 0x01; //!< ADC_MODE_CONTROL.SWCNV
whismanoid 0:3edb3708c8c5 2151
whismanoid 0:3edb3708c8c5 2152 const int SCAN = ((registerData >> SCAN_LSB) & SCAN_BITS);
whismanoid 0:3edb3708c8c5 2153 const int CHSEL = ((registerData >> CHSEL_LSB) & CHSEL_BITS);
whismanoid 0:3edb3708c8c5 2154 const int RESET = ((registerData >> RESET_LSB) & RESET_BITS);
whismanoid 0:3edb3708c8c5 2155 const int PM = ((registerData >> PM_LSB) & PM_BITS);
whismanoid 0:3edb3708c8c5 2156 const int CHANID = ((registerData >> CHAN_ID_LSB) & CHAN_ID_BITS);
whismanoid 0:3edb3708c8c5 2157 const int SWCNV = ((registerData >> SWCNV_LSB) & SWCNV_BITS);
whismanoid 0:3edb3708c8c5 2158
whismanoid 0:3edb3708c8c5 2159 switch (SCAN)
whismanoid 0:3edb3708c8c5 2160 {
whismanoid 0:3edb3708c8c5 2161 case MAX11131::SCAN_0000_NOP:
whismanoid 0:3edb3708c8c5 2162 cmdLine.serial().printf(" SCAN_0000_NOP");
whismanoid 0:3edb3708c8c5 2163 break;
whismanoid 0:3edb3708c8c5 2164 case MAX11131::SCAN_0001_Manual:
whismanoid 0:3edb3708c8c5 2165 cmdLine.serial().printf(" SCAN_0001_Manual CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 2166 break;
whismanoid 0:3edb3708c8c5 2167 case MAX11131::SCAN_0010_Repeat:
whismanoid 0:3edb3708c8c5 2168 cmdLine.serial().printf(" SCAN_0010_Repeat CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 2169 break;
whismanoid 0:3edb3708c8c5 2170 case MAX11131::SCAN_0011_StandardInternalClock:
whismanoid 0:3edb3708c8c5 2171 cmdLine.serial().printf(" SCAN_0011_StandardInt CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 2172 break;
whismanoid 0:3edb3708c8c5 2173 case MAX11131::SCAN_0100_StandardExternalClock:
whismanoid 0:3edb3708c8c5 2174 cmdLine.serial().printf(" SCAN_0100_StandardExt CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 2175 break;
whismanoid 0:3edb3708c8c5 2176 case MAX11131::SCAN_0101_UpperInternalClock:
whismanoid 0:3edb3708c8c5 2177 cmdLine.serial().printf(" SCAN_0101_UpperInt CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 2178 break;
whismanoid 0:3edb3708c8c5 2179 case MAX11131::SCAN_0110_UpperExternalClock:
whismanoid 0:3edb3708c8c5 2180 cmdLine.serial().printf(" SCAN_0110_UpperExt CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 2181 break;
whismanoid 0:3edb3708c8c5 2182 case MAX11131::SCAN_0111_CustomInternalClock:
whismanoid 0:3edb3708c8c5 2183 cmdLine.serial().printf(" SCAN_0111_CustomInt");
whismanoid 0:3edb3708c8c5 2184 break;
whismanoid 0:3edb3708c8c5 2185 case MAX11131::SCAN_1000_CustomExternalClock:
whismanoid 0:3edb3708c8c5 2186 cmdLine.serial().printf(" SCAN_1000_CustomExt");
whismanoid 0:3edb3708c8c5 2187 break;
whismanoid 0:3edb3708c8c5 2188 case MAX11131::SCAN_1001_SampleSetExternalClock:
whismanoid 0:3edb3708c8c5 2189 cmdLine.serial().printf(" SCAN_1001_SampleSetExt");
whismanoid 0:3edb3708c8c5 2190 break;
whismanoid 0:3edb3708c8c5 2191 default:
whismanoid 0:3edb3708c8c5 2192 cmdLine.serial().printf(" SCAN=%d", SCAN);
whismanoid 0:3edb3708c8c5 2193 cmdLine.serial().printf(" CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 2194 }
whismanoid 0:3edb3708c8c5 2195 if (RESET) {
whismanoid 0:3edb3708c8c5 2196 cmdLine.serial().printf(" RESET=%d", RESET);
whismanoid 0:3edb3708c8c5 2197 }
whismanoid 0:3edb3708c8c5 2198 if (PM) {
whismanoid 0:3edb3708c8c5 2199 cmdLine.serial().printf(" PM=%d", PM);
whismanoid 0:3edb3708c8c5 2200 }
whismanoid 0:3edb3708c8c5 2201 if (SCAN != MAX11131::SCAN_0000_NOP)
whismanoid 0:3edb3708c8c5 2202 {
whismanoid 0:3edb3708c8c5 2203 if (g_MAX11131_device.isExternalClock)
whismanoid 0:3edb3708c8c5 2204 {
whismanoid 0:3edb3708c8c5 2205 // if external clock mode, print CHANID
whismanoid 0:3edb3708c8c5 2206 cmdLine.serial().printf(" CHANID=%d", CHANID);
whismanoid 0:3edb3708c8c5 2207 }
whismanoid 0:3edb3708c8c5 2208 else
whismanoid 0:3edb3708c8c5 2209 {
whismanoid 0:3edb3708c8c5 2210 // if internal clock mode, print SWCNV
whismanoid 0:3edb3708c8c5 2211 cmdLine.serial().printf(" SWCNV=%d", SWCNV);
whismanoid 0:3edb3708c8c5 2212 }
whismanoid 0:3edb3708c8c5 2213 }
whismanoid 0:3edb3708c8c5 2214 }
whismanoid 0:3edb3708c8c5 2215 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 2216 }
whismanoid 0:3edb3708c8c5 2217 #endif
whismanoid 0:3edb3708c8c5 2218
whismanoid 0:3edb3708c8c5 2219
whismanoid 0:3edb3708c8c5 2220 #if APPLICATION_MAX5171 // hardware interface functions
whismanoid 0:3edb3708c8c5 2221 #endif
whismanoid 0:3edb3708c8c5 2222
whismanoid 0:3edb3708c8c5 2223
whismanoid 0:3edb3708c8c5 2224 #if APPLICATION_MAX11410 // hardware interface functions
whismanoid 0:3edb3708c8c5 2225 #endif
whismanoid 0:3edb3708c8c5 2226
whismanoid 0:3edb3708c8c5 2227
whismanoid 0:3edb3708c8c5 2228 #if APPLICATION_MAX12345 // hardware interface functions
whismanoid 0:3edb3708c8c5 2229 #endif
whismanoid 0:3edb3708c8c5 2230
whismanoid 0:3edb3708c8c5 2231
whismanoid 0:3edb3708c8c5 2232 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2233 // print banner message to serial port
whismanoid 0:3edb3708c8c5 2234 void print_banner()
whismanoid 0:3edb3708c8c5 2235 {
whismanoid 0:3edb3708c8c5 2236 #if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 2237 DAPLINKserial.printf("\r\n");
whismanoid 0:3edb3708c8c5 2238 # if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 2239 DAPLINKserial.printf("MAX32630");
whismanoid 0:3edb3708c8c5 2240 # elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 2241 DAPLINKserial.printf("MAX32625MBED");
whismanoid 0:3edb3708c8c5 2242 # elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 2243 DAPLINKserial.printf("NUCLEO_F446RE");
whismanoid 0:3edb3708c8c5 2244 # elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 2245 DAPLINKserial.printf("NUCLEO_F401RE");
whismanoid 0:3edb3708c8c5 2246 # elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 2247 DAPLINKserial.printf("LPC1768");
whismanoid 0:3edb3708c8c5 2248 # else
whismanoid 0:3edb3708c8c5 2249 // unknown target
whismanoid 0:3edb3708c8c5 2250 DAPLINKserial.printf("unknownTarget");
whismanoid 0:3edb3708c8c5 2251 # endif
whismanoid 0:3edb3708c8c5 2252 DAPLINKserial.printf(" DAPLINKserial\r\n");
whismanoid 0:3edb3708c8c5 2253 #endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 2254
whismanoid 8:132276960128 2255 serial.printf("\r\n");
whismanoid 0:3edb3708c8c5 2256 # if defined(TARGET_MAX32630)
whismanoid 8:132276960128 2257 serial.printf("MAX32630");
whismanoid 0:3edb3708c8c5 2258 # elif defined(TARGET_MAX32625MBED)
whismanoid 8:132276960128 2259 serial.printf("MAX32625MBED");
whismanoid 0:3edb3708c8c5 2260 # elif defined(TARGET_NUCLEO_F446RE)
whismanoid 8:132276960128 2261 serial.printf("NUCLEO_F446RE");
whismanoid 0:3edb3708c8c5 2262 # elif defined(TARGET_NUCLEO_F401RE)
whismanoid 8:132276960128 2263 serial.printf("NUCLEO_F401RE");
whismanoid 0:3edb3708c8c5 2264 # elif defined(TARGET_LPC1768)
whismanoid 8:132276960128 2265 serial.printf("LPC1768");
whismanoid 0:3edb3708c8c5 2266 # else
whismanoid 0:3edb3708c8c5 2267 // unknown target
whismanoid 8:132276960128 2268 serial.printf("unknownTarget");
whismanoid 0:3edb3708c8c5 2269 # endif
whismanoid 8:132276960128 2270 serial.printf(" Tester\r\n");
whismanoid 0:3edb3708c8c5 2271 }
whismanoid 0:3edb3708c8c5 2272
whismanoid 8:132276960128 2273 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:3edb3708c8c5 2274 #if HAS_digitalInOuts
whismanoid 0:3edb3708c8c5 2275 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:3edb3708c8c5 2276 {
whismanoid 0:3edb3708c8c5 2277 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 2278 serialStream.printf(" 0");
whismanoid 0:3edb3708c8c5 2279 #endif
whismanoid 0:3edb3708c8c5 2280 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 2281 serialStream.printf(" 1");
whismanoid 0:3edb3708c8c5 2282 #endif
whismanoid 0:3edb3708c8c5 2283 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 2284 serialStream.printf(" 2");
whismanoid 0:3edb3708c8c5 2285 #endif
whismanoid 0:3edb3708c8c5 2286 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 2287 serialStream.printf(" 3");
whismanoid 0:3edb3708c8c5 2288 #endif
whismanoid 0:3edb3708c8c5 2289 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 2290 serialStream.printf(" 4");
whismanoid 0:3edb3708c8c5 2291 #endif
whismanoid 0:3edb3708c8c5 2292 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 2293 serialStream.printf(" 5");
whismanoid 0:3edb3708c8c5 2294 #endif
whismanoid 0:3edb3708c8c5 2295 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 2296 serialStream.printf(" 6");
whismanoid 0:3edb3708c8c5 2297 #endif
whismanoid 0:3edb3708c8c5 2298 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 2299 serialStream.printf(" 7");
whismanoid 0:3edb3708c8c5 2300 #endif
whismanoid 0:3edb3708c8c5 2301 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 2302 serialStream.printf(" 8");
whismanoid 0:3edb3708c8c5 2303 #endif
whismanoid 0:3edb3708c8c5 2304 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 2305 serialStream.printf(" 9");
whismanoid 0:3edb3708c8c5 2306 #endif
whismanoid 0:3edb3708c8c5 2307 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 2308 serialStream.printf(" 10");
whismanoid 0:3edb3708c8c5 2309 #endif
whismanoid 0:3edb3708c8c5 2310 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 2311 serialStream.printf(" 11");
whismanoid 0:3edb3708c8c5 2312 #endif
whismanoid 0:3edb3708c8c5 2313 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 2314 serialStream.printf(" 12");
whismanoid 0:3edb3708c8c5 2315 #endif
whismanoid 0:3edb3708c8c5 2316 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 2317 serialStream.printf(" 13");
whismanoid 0:3edb3708c8c5 2318 #endif
whismanoid 0:3edb3708c8c5 2319 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 2320 serialStream.printf(" 14");
whismanoid 0:3edb3708c8c5 2321 #endif
whismanoid 0:3edb3708c8c5 2322 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 2323 serialStream.printf(" 15");
whismanoid 0:3edb3708c8c5 2324 #endif
whismanoid 0:3edb3708c8c5 2325 #if HAS_digitalInOut16
whismanoid 0:3edb3708c8c5 2326 serialStream.printf(" 16");
whismanoid 0:3edb3708c8c5 2327 #endif
whismanoid 0:3edb3708c8c5 2328 #if HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 2329 serialStream.printf(" 17");
whismanoid 0:3edb3708c8c5 2330 #endif
whismanoid 0:3edb3708c8c5 2331 }
whismanoid 0:3edb3708c8c5 2332 #endif
whismanoid 0:3edb3708c8c5 2333
whismanoid 0:3edb3708c8c5 2334 // DigitalInOut pin resource: present?
whismanoid 0:3edb3708c8c5 2335 #if HAS_digitalInOuts
whismanoid 0:3edb3708c8c5 2336 bool has_digitalInOutPin(int cPinIndex)
whismanoid 0:3edb3708c8c5 2337 {
whismanoid 0:3edb3708c8c5 2338 switch (cPinIndex)
whismanoid 0:3edb3708c8c5 2339 {
whismanoid 0:3edb3708c8c5 2340 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 2341 case '0': case 0x00: return true;
whismanoid 0:3edb3708c8c5 2342 #endif
whismanoid 0:3edb3708c8c5 2343 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 2344 case '1': case 0x01: return true;
whismanoid 0:3edb3708c8c5 2345 #endif
whismanoid 0:3edb3708c8c5 2346 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 2347 case '2': case 0x02: return true;
whismanoid 0:3edb3708c8c5 2348 #endif
whismanoid 0:3edb3708c8c5 2349 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 2350 case '3': case 0x03: return true;
whismanoid 0:3edb3708c8c5 2351 #endif
whismanoid 0:3edb3708c8c5 2352 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 2353 case '4': case 0x04: return true;
whismanoid 0:3edb3708c8c5 2354 #endif
whismanoid 0:3edb3708c8c5 2355 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 2356 case '5': case 0x05: return true;
whismanoid 0:3edb3708c8c5 2357 #endif
whismanoid 0:3edb3708c8c5 2358 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 2359 case '6': case 0x06: return true;
whismanoid 0:3edb3708c8c5 2360 #endif
whismanoid 0:3edb3708c8c5 2361 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 2362 case '7': case 0x07: return true;
whismanoid 0:3edb3708c8c5 2363 #endif
whismanoid 0:3edb3708c8c5 2364 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 2365 case '8': case 0x08: return true;
whismanoid 0:3edb3708c8c5 2366 #endif
whismanoid 0:3edb3708c8c5 2367 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 2368 case '9': case 0x09: return true;
whismanoid 0:3edb3708c8c5 2369 #endif
whismanoid 0:3edb3708c8c5 2370 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 2371 case 'a': case 0x0a: return true;
whismanoid 0:3edb3708c8c5 2372 #endif
whismanoid 0:3edb3708c8c5 2373 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 2374 case 'b': case 0x0b: return true;
whismanoid 0:3edb3708c8c5 2375 #endif
whismanoid 0:3edb3708c8c5 2376 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 2377 case 'c': case 0x0c: return true;
whismanoid 0:3edb3708c8c5 2378 #endif
whismanoid 0:3edb3708c8c5 2379 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 2380 case 'd': case 0x0d: return true;
whismanoid 0:3edb3708c8c5 2381 #endif
whismanoid 0:3edb3708c8c5 2382 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 2383 case 'e': case 0x0e: return true;
whismanoid 0:3edb3708c8c5 2384 #endif
whismanoid 0:3edb3708c8c5 2385 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 2386 case 'f': case 0x0f: return true;
whismanoid 0:3edb3708c8c5 2387 #endif
whismanoid 0:3edb3708c8c5 2388 default:
whismanoid 0:3edb3708c8c5 2389 return false;
whismanoid 0:3edb3708c8c5 2390 }
whismanoid 0:3edb3708c8c5 2391 }
whismanoid 0:3edb3708c8c5 2392 #endif
whismanoid 0:3edb3708c8c5 2393
whismanoid 0:3edb3708c8c5 2394 // DigitalInOut pin resource: search index
whismanoid 0:3edb3708c8c5 2395 #if HAS_digitalInOuts
whismanoid 0:3edb3708c8c5 2396 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:3edb3708c8c5 2397 {
whismanoid 0:3edb3708c8c5 2398 switch (cPinIndex)
whismanoid 0:3edb3708c8c5 2399 {
whismanoid 0:3edb3708c8c5 2400 default: // default to the first defined digitalInOut pin
whismanoid 0:3edb3708c8c5 2401 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 2402 case '0': case 0x00: return digitalInOut0;
whismanoid 0:3edb3708c8c5 2403 #endif
whismanoid 0:3edb3708c8c5 2404 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 2405 case '1': case 0x01: return digitalInOut1;
whismanoid 0:3edb3708c8c5 2406 #endif
whismanoid 0:3edb3708c8c5 2407 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 2408 case '2': case 0x02: return digitalInOut2;
whismanoid 0:3edb3708c8c5 2409 #endif
whismanoid 0:3edb3708c8c5 2410 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 2411 case '3': case 0x03: return digitalInOut3;
whismanoid 0:3edb3708c8c5 2412 #endif
whismanoid 0:3edb3708c8c5 2413 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 2414 case '4': case 0x04: return digitalInOut4;
whismanoid 0:3edb3708c8c5 2415 #endif
whismanoid 0:3edb3708c8c5 2416 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 2417 case '5': case 0x05: return digitalInOut5;
whismanoid 0:3edb3708c8c5 2418 #endif
whismanoid 0:3edb3708c8c5 2419 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 2420 case '6': case 0x06: return digitalInOut6;
whismanoid 0:3edb3708c8c5 2421 #endif
whismanoid 0:3edb3708c8c5 2422 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 2423 case '7': case 0x07: return digitalInOut7;
whismanoid 0:3edb3708c8c5 2424 #endif
whismanoid 0:3edb3708c8c5 2425 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 2426 case '8': case 0x08: return digitalInOut8;
whismanoid 0:3edb3708c8c5 2427 #endif
whismanoid 0:3edb3708c8c5 2428 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 2429 case '9': case 0x09: return digitalInOut9;
whismanoid 0:3edb3708c8c5 2430 #endif
whismanoid 0:3edb3708c8c5 2431 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 2432 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:3edb3708c8c5 2433 #endif
whismanoid 0:3edb3708c8c5 2434 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 2435 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:3edb3708c8c5 2436 #endif
whismanoid 0:3edb3708c8c5 2437 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 2438 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:3edb3708c8c5 2439 #endif
whismanoid 0:3edb3708c8c5 2440 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 2441 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:3edb3708c8c5 2442 #endif
whismanoid 0:3edb3708c8c5 2443 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 2444 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:3edb3708c8c5 2445 #endif
whismanoid 0:3edb3708c8c5 2446 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 2447 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:3edb3708c8c5 2448 #endif
whismanoid 0:3edb3708c8c5 2449 #if HAS_digitalInOut16
whismanoid 0:3edb3708c8c5 2450 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:3edb3708c8c5 2451 #endif
whismanoid 0:3edb3708c8c5 2452 #if HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 2453 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:3edb3708c8c5 2454 #endif
whismanoid 0:3edb3708c8c5 2455 }
whismanoid 0:3edb3708c8c5 2456 }
whismanoid 0:3edb3708c8c5 2457 #endif
whismanoid 0:3edb3708c8c5 2458
whismanoid 8:132276960128 2459 // AnalogIn pin resource: print the pin index names to serial
whismanoid 0:3edb3708c8c5 2460 #if HAS_analogIns
whismanoid 0:3edb3708c8c5 2461 void list_analogInPins(Stream& serialStream)
whismanoid 0:3edb3708c8c5 2462 {
whismanoid 0:3edb3708c8c5 2463 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 2464 serialStream.printf(" 0");
whismanoid 0:3edb3708c8c5 2465 #endif
whismanoid 0:3edb3708c8c5 2466 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 2467 serialStream.printf(" 1");
whismanoid 0:3edb3708c8c5 2468 #endif
whismanoid 0:3edb3708c8c5 2469 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 2470 serialStream.printf(" 2");
whismanoid 0:3edb3708c8c5 2471 #endif
whismanoid 0:3edb3708c8c5 2472 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 2473 serialStream.printf(" 3");
whismanoid 0:3edb3708c8c5 2474 #endif
whismanoid 0:3edb3708c8c5 2475 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 2476 serialStream.printf(" 4");
whismanoid 0:3edb3708c8c5 2477 #endif
whismanoid 0:3edb3708c8c5 2478 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 2479 serialStream.printf(" 5");
whismanoid 0:3edb3708c8c5 2480 #endif
whismanoid 0:3edb3708c8c5 2481 #if HAS_analogIn6
whismanoid 0:3edb3708c8c5 2482 serialStream.printf(" 6");
whismanoid 0:3edb3708c8c5 2483 #endif
whismanoid 0:3edb3708c8c5 2484 #if HAS_analogIn7
whismanoid 0:3edb3708c8c5 2485 serialStream.printf(" 7");
whismanoid 0:3edb3708c8c5 2486 #endif
whismanoid 0:3edb3708c8c5 2487 #if HAS_analogIn8
whismanoid 0:3edb3708c8c5 2488 serialStream.printf(" 8");
whismanoid 0:3edb3708c8c5 2489 #endif
whismanoid 0:3edb3708c8c5 2490 #if HAS_analogIn9
whismanoid 0:3edb3708c8c5 2491 serialStream.printf(" 9");
whismanoid 0:3edb3708c8c5 2492 #endif
whismanoid 0:3edb3708c8c5 2493 #if HAS_analogIn10
whismanoid 0:3edb3708c8c5 2494 serialStream.printf(" a");
whismanoid 0:3edb3708c8c5 2495 #endif
whismanoid 0:3edb3708c8c5 2496 #if HAS_analogIn11
whismanoid 0:3edb3708c8c5 2497 serialStream.printf(" b");
whismanoid 0:3edb3708c8c5 2498 #endif
whismanoid 0:3edb3708c8c5 2499 #if HAS_analogIn12
whismanoid 0:3edb3708c8c5 2500 serialStream.printf(" c");
whismanoid 0:3edb3708c8c5 2501 #endif
whismanoid 0:3edb3708c8c5 2502 #if HAS_analogIn13
whismanoid 0:3edb3708c8c5 2503 serialStream.printf(" d");
whismanoid 0:3edb3708c8c5 2504 #endif
whismanoid 0:3edb3708c8c5 2505 #if HAS_analogIn14
whismanoid 0:3edb3708c8c5 2506 serialStream.printf(" e");
whismanoid 0:3edb3708c8c5 2507 #endif
whismanoid 0:3edb3708c8c5 2508 #if HAS_analogIn15
whismanoid 0:3edb3708c8c5 2509 serialStream.printf(" f");
whismanoid 0:3edb3708c8c5 2510 #endif
whismanoid 0:3edb3708c8c5 2511 }
whismanoid 0:3edb3708c8c5 2512 #endif
whismanoid 0:3edb3708c8c5 2513
whismanoid 0:3edb3708c8c5 2514 // AnalogIn pin resource: present?
whismanoid 0:3edb3708c8c5 2515 #if HAS_analogIns
whismanoid 0:3edb3708c8c5 2516 bool has_analogInPin(int cPinIndex)
whismanoid 0:3edb3708c8c5 2517 {
whismanoid 0:3edb3708c8c5 2518 switch (cPinIndex)
whismanoid 0:3edb3708c8c5 2519 {
whismanoid 0:3edb3708c8c5 2520 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 2521 case '0': case 0x00: return true;
whismanoid 0:3edb3708c8c5 2522 #endif
whismanoid 0:3edb3708c8c5 2523 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 2524 case '1': case 0x01: return true;
whismanoid 0:3edb3708c8c5 2525 #endif
whismanoid 0:3edb3708c8c5 2526 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 2527 case '2': case 0x02: return true;
whismanoid 0:3edb3708c8c5 2528 #endif
whismanoid 0:3edb3708c8c5 2529 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 2530 case '3': case 0x03: return true;
whismanoid 0:3edb3708c8c5 2531 #endif
whismanoid 0:3edb3708c8c5 2532 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 2533 case '4': case 0x04: return true;
whismanoid 0:3edb3708c8c5 2534 #endif
whismanoid 0:3edb3708c8c5 2535 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 2536 case '5': case 0x05: return true;
whismanoid 0:3edb3708c8c5 2537 #endif
whismanoid 0:3edb3708c8c5 2538 #if HAS_analogIn6
whismanoid 0:3edb3708c8c5 2539 case '6': case 0x06: return true;
whismanoid 0:3edb3708c8c5 2540 #endif
whismanoid 0:3edb3708c8c5 2541 #if HAS_analogIn7
whismanoid 0:3edb3708c8c5 2542 case '7': case 0x07: return true;
whismanoid 0:3edb3708c8c5 2543 #endif
whismanoid 0:3edb3708c8c5 2544 #if HAS_analogIn8
whismanoid 0:3edb3708c8c5 2545 case '8': case 0x08: return true;
whismanoid 0:3edb3708c8c5 2546 #endif
whismanoid 0:3edb3708c8c5 2547 #if HAS_analogIn9
whismanoid 0:3edb3708c8c5 2548 case '9': case 0x09: return true;
whismanoid 0:3edb3708c8c5 2549 #endif
whismanoid 0:3edb3708c8c5 2550 #if HAS_analogIn10
whismanoid 0:3edb3708c8c5 2551 case 'a': case 0x0a: return true;
whismanoid 0:3edb3708c8c5 2552 #endif
whismanoid 0:3edb3708c8c5 2553 #if HAS_analogIn11
whismanoid 0:3edb3708c8c5 2554 case 'b': case 0x0b: return true;
whismanoid 0:3edb3708c8c5 2555 #endif
whismanoid 0:3edb3708c8c5 2556 #if HAS_analogIn12
whismanoid 0:3edb3708c8c5 2557 case 'c': case 0x0c: return true;
whismanoid 0:3edb3708c8c5 2558 #endif
whismanoid 0:3edb3708c8c5 2559 #if HAS_analogIn13
whismanoid 0:3edb3708c8c5 2560 case 'd': case 0x0d: return true;
whismanoid 0:3edb3708c8c5 2561 #endif
whismanoid 0:3edb3708c8c5 2562 #if HAS_analogIn14
whismanoid 0:3edb3708c8c5 2563 case 'e': case 0x0e: return true;
whismanoid 0:3edb3708c8c5 2564 #endif
whismanoid 0:3edb3708c8c5 2565 #if HAS_analogIn15
whismanoid 0:3edb3708c8c5 2566 case 'f': case 0x0f: return true;
whismanoid 0:3edb3708c8c5 2567 #endif
whismanoid 0:3edb3708c8c5 2568 default:
whismanoid 0:3edb3708c8c5 2569 return false;
whismanoid 0:3edb3708c8c5 2570 }
whismanoid 0:3edb3708c8c5 2571 }
whismanoid 0:3edb3708c8c5 2572 #endif
whismanoid 0:3edb3708c8c5 2573
whismanoid 0:3edb3708c8c5 2574 // AnalogIn pin resource: search index
whismanoid 0:3edb3708c8c5 2575 #if HAS_analogIns
whismanoid 0:3edb3708c8c5 2576 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:3edb3708c8c5 2577 {
whismanoid 0:3edb3708c8c5 2578 switch (cPinIndex)
whismanoid 0:3edb3708c8c5 2579 {
whismanoid 0:3edb3708c8c5 2580 default: // default to the first defined analogIn pin
whismanoid 0:3edb3708c8c5 2581 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 2582 case '0': case 0x00: return analogIn0;
whismanoid 0:3edb3708c8c5 2583 #endif
whismanoid 0:3edb3708c8c5 2584 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 2585 case '1': case 0x01: return analogIn1;
whismanoid 0:3edb3708c8c5 2586 #endif
whismanoid 0:3edb3708c8c5 2587 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 2588 case '2': case 0x02: return analogIn2;
whismanoid 0:3edb3708c8c5 2589 #endif
whismanoid 0:3edb3708c8c5 2590 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 2591 case '3': case 0x03: return analogIn3;
whismanoid 0:3edb3708c8c5 2592 #endif
whismanoid 0:3edb3708c8c5 2593 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 2594 case '4': case 0x04: return analogIn4;
whismanoid 0:3edb3708c8c5 2595 #endif
whismanoid 0:3edb3708c8c5 2596 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 2597 case '5': case 0x05: return analogIn5;
whismanoid 0:3edb3708c8c5 2598 #endif
whismanoid 0:3edb3708c8c5 2599 #if HAS_analogIn6
whismanoid 0:3edb3708c8c5 2600 case '6': case 0x06: return analogIn6;
whismanoid 0:3edb3708c8c5 2601 #endif
whismanoid 0:3edb3708c8c5 2602 #if HAS_analogIn7
whismanoid 0:3edb3708c8c5 2603 case '7': case 0x07: return analogIn7;
whismanoid 0:3edb3708c8c5 2604 #endif
whismanoid 0:3edb3708c8c5 2605 #if HAS_analogIn8
whismanoid 0:3edb3708c8c5 2606 case '8': case 0x08: return analogIn8;
whismanoid 0:3edb3708c8c5 2607 #endif
whismanoid 0:3edb3708c8c5 2608 #if HAS_analogIn9
whismanoid 0:3edb3708c8c5 2609 case '9': case 0x09: return analogIn9;
whismanoid 0:3edb3708c8c5 2610 #endif
whismanoid 0:3edb3708c8c5 2611 #if HAS_analogIn10
whismanoid 0:3edb3708c8c5 2612 case 'a': case 0x0a: return analogIn10;
whismanoid 0:3edb3708c8c5 2613 #endif
whismanoid 0:3edb3708c8c5 2614 #if HAS_analogIn11
whismanoid 0:3edb3708c8c5 2615 case 'b': case 0x0b: return analogIn11;
whismanoid 0:3edb3708c8c5 2616 #endif
whismanoid 0:3edb3708c8c5 2617 #if HAS_analogIn12
whismanoid 0:3edb3708c8c5 2618 case 'c': case 0x0c: return analogIn12;
whismanoid 0:3edb3708c8c5 2619 #endif
whismanoid 0:3edb3708c8c5 2620 #if HAS_analogIn13
whismanoid 0:3edb3708c8c5 2621 case 'd': case 0x0d: return analogIn13;
whismanoid 0:3edb3708c8c5 2622 #endif
whismanoid 0:3edb3708c8c5 2623 #if HAS_analogIn14
whismanoid 0:3edb3708c8c5 2624 case 'e': case 0x0e: return analogIn14;
whismanoid 0:3edb3708c8c5 2625 #endif
whismanoid 0:3edb3708c8c5 2626 #if HAS_analogIn15
whismanoid 0:3edb3708c8c5 2627 case 'f': case 0x0f: return analogIn15;
whismanoid 0:3edb3708c8c5 2628 #endif
whismanoid 0:3edb3708c8c5 2629 }
whismanoid 0:3edb3708c8c5 2630 }
whismanoid 0:3edb3708c8c5 2631 #endif
whismanoid 0:3edb3708c8c5 2632
whismanoid 0:3edb3708c8c5 2633 #if HAS_analogIns
whismanoid 0:3edb3708c8c5 2634 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:3edb3708c8c5 2635 # if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 2636 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:3edb3708c8c5 2637 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:3edb3708c8c5 2638 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:3edb3708c8c5 2639 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:3edb3708c8c5 2640 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 2641 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 2642 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2643 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2644 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2645 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:3edb3708c8c5 2646 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:3edb3708c8c5 2647 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2648 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2649 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:3edb3708c8c5 2650 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:3edb3708c8c5 2651 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 17:c2f46173f6b2 2652 # elif defined(TARGET_MAX32620FTHR)
whismanoid 17:c2f46173f6b2 2653 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 17:c2f46173f6b2 2654 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 17:c2f46173f6b2 2655 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 17:c2f46173f6b2 2656 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 17:c2f46173f6b2 2657 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 17:c2f46173f6b2 2658 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 17:c2f46173f6b2 2659 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 17:c2f46173f6b2 2660 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 17:c2f46173f6b2 2661 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 17:c2f46173f6b2 2662 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 17:c2f46173f6b2 2663 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 17:c2f46173f6b2 2664 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 17:c2f46173f6b2 2665 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 17:c2f46173f6b2 2666 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 17:c2f46173f6b2 2667 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 17:c2f46173f6b2 2668 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 17:c2f46173f6b2 2669 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:3edb3708c8c5 2670 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 2671 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2672 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2673 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2674 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2675 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 2676 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 2677 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2678 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2679 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2680 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:3edb3708c8c5 2681 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:3edb3708c8c5 2682 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2683 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2684 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:3edb3708c8c5 2685 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:3edb3708c8c5 2686 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:3edb3708c8c5 2687 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 2688 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:3edb3708c8c5 2689 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:3edb3708c8c5 2690 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:3edb3708c8c5 2691 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:3edb3708c8c5 2692 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:3edb3708c8c5 2693 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:3edb3708c8c5 2694 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:3edb3708c8c5 2695 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:3edb3708c8c5 2696 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:3edb3708c8c5 2697 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:3edb3708c8c5 2698 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:3edb3708c8c5 2699 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:3edb3708c8c5 2700 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:3edb3708c8c5 2701 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:3edb3708c8c5 2702 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:3edb3708c8c5 2703 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:3edb3708c8c5 2704 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 2705 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:3edb3708c8c5 2706 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:3edb3708c8c5 2707 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:3edb3708c8c5 2708 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:3edb3708c8c5 2709 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:3edb3708c8c5 2710 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:3edb3708c8c5 2711 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:3edb3708c8c5 2712 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:3edb3708c8c5 2713 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:3edb3708c8c5 2714 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:3edb3708c8c5 2715 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:3edb3708c8c5 2716 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:3edb3708c8c5 2717 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:3edb3708c8c5 2718 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:3edb3708c8c5 2719 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:3edb3708c8c5 2720 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:3edb3708c8c5 2721 //#elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 2722 #else
whismanoid 0:3edb3708c8c5 2723 // unknown target
whismanoid 0:3edb3708c8c5 2724 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:3edb3708c8c5 2725 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:3edb3708c8c5 2726 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:3edb3708c8c5 2727 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:3edb3708c8c5 2728 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:3edb3708c8c5 2729 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:3edb3708c8c5 2730 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:3edb3708c8c5 2731 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:3edb3708c8c5 2732 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:3edb3708c8c5 2733 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:3edb3708c8c5 2734 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:3edb3708c8c5 2735 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:3edb3708c8c5 2736 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:3edb3708c8c5 2737 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:3edb3708c8c5 2738 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:3edb3708c8c5 2739 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:3edb3708c8c5 2740 # endif
whismanoid 0:3edb3708c8c5 2741 };
whismanoid 0:3edb3708c8c5 2742 #endif
whismanoid 0:3edb3708c8c5 2743
whismanoid 0:3edb3708c8c5 2744 #if HAS_I2C // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 2745 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2746 // Search I2C device address list
whismanoid 0:3edb3708c8c5 2747 //
whismanoid 0:3edb3708c8c5 2748 // @param[in] deviceAddress7First = I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified.
whismanoid 0:3edb3708c8c5 2749 // @param[in] deviceAddress7Last = I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified.
whismanoid 0:3edb3708c8c5 2750 // @param[in] numDevicesFoundLimit = maximum number of devices to detect before halting search; in case SCL stuck low or pullups missing.
whismanoid 0:3edb3708c8c5 2751 // @returns deviceAddress on success; 0 on failure
whismanoid 0:3edb3708c8c5 2752 // @post g_I2C_deviceAddress7 is updated with any device that did ACK
whismanoid 0:3edb3708c8c5 2753 //
whismanoid 0:3edb3708c8c5 2754 void HuntAttachedI2CDevices(CmdLine& cmdLine, uint8_t deviceAddress7First, uint8_t deviceAddress7Last,
whismanoid 0:3edb3708c8c5 2755 const uint8_t numDevicesFoundLimit = 20)
whismanoid 0:3edb3708c8c5 2756 {
whismanoid 0:3edb3708c8c5 2757 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 0:3edb3708c8c5 2758 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 2759 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 0:3edb3708c8c5 2760
whismanoid 0:3edb3708c8c5 2761 // %IP -- I2C probe
whismanoid 0:3edb3708c8c5 2762 // TODO: i2c transfer
whismanoid 0:3edb3708c8c5 2763 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 0:3edb3708c8c5 2764 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 0:3edb3708c8c5 2765 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 0:3edb3708c8c5 2766 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 0:3edb3708c8c5 2767 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 0:3edb3708c8c5 2768 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 0:3edb3708c8c5 2769 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 0:3edb3708c8c5 2770 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 0:3edb3708c8c5 2771 // /* 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 0:3edb3708c8c5 2772 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 0:3edb3708c8c5 2773
whismanoid 0:3edb3708c8c5 2774 //const char probeWriteData[] = { 0x00 };
whismanoid 0:3edb3708c8c5 2775 //int probeWriteDataLength = 1;
whismanoid 0:3edb3708c8c5 2776 //bool isRepeatedStart = false;
whismanoid 0:3edb3708c8c5 2777 cmdLine.serial().printf("I2C Probe {0x%2.2X (0x%2.2X >> 1) to 0x%2.2X (0x%2.2X >> 1)}, limit %d\r\n",
whismanoid 0:3edb3708c8c5 2778 deviceAddress7First,
whismanoid 0:3edb3708c8c5 2779 deviceAddress7First << 1,
whismanoid 0:3edb3708c8c5 2780 deviceAddress7Last,
whismanoid 0:3edb3708c8c5 2781 deviceAddress7Last << 1,
whismanoid 0:3edb3708c8c5 2782 numDevicesFoundLimit); // HuntAttachedI2CDevices
whismanoid 0:3edb3708c8c5 2783 //~ const int i2cFileDescriptor = i2c_open_adapter(1);
whismanoid 0:3edb3708c8c5 2784 uint8_t numDevicesFound = 0;
whismanoid 0:3edb3708c8c5 2785 uint8_t last_valid_deviceAddress7 = 0;
whismanoid 0:3edb3708c8c5 2786 for (uint8_t deviceAddress7 = deviceAddress7First; deviceAddress7 <= deviceAddress7Last; deviceAddress7++)
whismanoid 0:3edb3708c8c5 2787 {
whismanoid 0:3edb3708c8c5 2788 //cmdLine.serial().printf(" (0x%2.2X >> 1) ", (deviceAddress7 << 1));
whismanoid 0:3edb3708c8c5 2789 //if (i2c_ioctl_I2C_SLAVE_i2cDeviceAddress7bits(i2cFileDescriptor, deviceAddress7) == 0)
whismanoid 0:3edb3708c8c5 2790 int addr8bit = deviceAddress7 * 2;
whismanoid 0:3edb3708c8c5 2791 //
whismanoid 0:3edb3708c8c5 2792 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 0:3edb3708c8c5 2793 // Returns 0 on success (ack), nonzero on failure (nack)
whismanoid 0:3edb3708c8c5 2794 //bool gotACK = (i2cMaster.write (addr8bit, probeWriteData, probeWriteDataLength, isRepeatedStart) == 0);
whismanoid 0:3edb3708c8c5 2795 //
whismanoid 0:3edb3708c8c5 2796 // SMBusQuick test
whismanoid 0:3edb3708c8c5 2797 i2cMaster.start();
whismanoid 0:3edb3708c8c5 2798 // /** Write single byte out on the I2C bus
whismanoid 0:3edb3708c8c5 2799 // *
whismanoid 0:3edb3708c8c5 2800 // * @param data data to write out on bus
whismanoid 0:3edb3708c8c5 2801 // *
whismanoid 0:3edb3708c8c5 2802 // * @returns
whismanoid 0:3edb3708c8c5 2803 // * '0' - NAK was received
whismanoid 0:3edb3708c8c5 2804 // * '1' - ACK was received,
whismanoid 0:3edb3708c8c5 2805 // * '2' - timeout
whismanoid 0:3edb3708c8c5 2806 // */
whismanoid 0:3edb3708c8c5 2807 // int write(int data);
whismanoid 0:3edb3708c8c5 2808 int writeStatus = i2cMaster.write(addr8bit);
whismanoid 0:3edb3708c8c5 2809 i2cMaster.stop();
whismanoid 0:3edb3708c8c5 2810 bool gotACK = (writeStatus == 1); // ACK was received
whismanoid 0:3edb3708c8c5 2811 if (writeStatus == 2) // timeout
whismanoid 0:3edb3708c8c5 2812 {
whismanoid 0:3edb3708c8c5 2813 cmdLine.serial().printf("- timeout\r\n");
whismanoid 0:3edb3708c8c5 2814 }
whismanoid 0:3edb3708c8c5 2815 //
whismanoid 0:3edb3708c8c5 2816 if (gotACK)
whismanoid 0:3edb3708c8c5 2817 {
whismanoid 0:3edb3708c8c5 2818 // @return status; error if (fileDescriptor < 0)
whismanoid 0:3edb3708c8c5 2819 cmdLine.serial().printf("+ ADDR=0x%2.2X (0x%2.2X >> 1) ACK\r\n", deviceAddress7, (deviceAddress7 << 1));
whismanoid 0:3edb3708c8c5 2820 numDevicesFound++;
whismanoid 0:3edb3708c8c5 2821 last_valid_deviceAddress7 = deviceAddress7;
whismanoid 0:3edb3708c8c5 2822 if (numDevicesFound > numDevicesFoundLimit)
whismanoid 0:3edb3708c8c5 2823 {
whismanoid 0:3edb3708c8c5 2824 break;
whismanoid 0:3edb3708c8c5 2825 }
whismanoid 0:3edb3708c8c5 2826 continue;
whismanoid 0:3edb3708c8c5 2827 }
whismanoid 0:3edb3708c8c5 2828 }
whismanoid 0:3edb3708c8c5 2829 if (numDevicesFound == 0)
whismanoid 0:3edb3708c8c5 2830 {
whismanoid 0:3edb3708c8c5 2831 cmdLine.serial().printf("- No I2C devices found. Maybe SCL/SDA are swapped?\r\n");
whismanoid 0:3edb3708c8c5 2832 }
whismanoid 0:3edb3708c8c5 2833 else if (numDevicesFound > numDevicesFoundLimit)
whismanoid 0:3edb3708c8c5 2834 {
whismanoid 0:3edb3708c8c5 2835 cmdLine.serial().printf("- Many I2C devices found. SCL/SDA missing pullup resistors? SCL stuck low?\r\n");
whismanoid 0:3edb3708c8c5 2836 }
whismanoid 0:3edb3708c8c5 2837 else
whismanoid 0:3edb3708c8c5 2838 {
whismanoid 0:3edb3708c8c5 2839 //~ i2c_ioctl_I2C_SLAVE_i2cDeviceAddress7bits(i2cFileDescriptor, last_valid_deviceAddress7);
whismanoid 0:3edb3708c8c5 2840 g_I2C_deviceAddress7 = last_valid_deviceAddress7;
whismanoid 0:3edb3708c8c5 2841 }
whismanoid 0:3edb3708c8c5 2842 //~ i2c_close(i2cFileDescriptor);
whismanoid 0:3edb3708c8c5 2843 }
whismanoid 0:3edb3708c8c5 2844 #endif // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 2845
whismanoid 0:3edb3708c8c5 2846 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2847 // periodic interrupt timer onTimerTick handler triggered by Ticker
whismanoid 0:3edb3708c8c5 2848 // analogIn0 (MAX32630:AIN_4 = AIN0 / 5.0) controls angular speed
whismanoid 0:3edb3708c8c5 2849 // analogIn1 (MAX32630:AIN_5 = AIN1 / 5.0) controls PWM duty cycle
whismanoid 0:3edb3708c8c5 2850 // note: measured 500ns overhead for MAX32630FTHR digitalInOut1.write(0); digitalInOut1.write(1);
whismanoid 0:3edb3708c8c5 2851 #if USE_PERIODIC_TIMER
whismanoid 0:3edb3708c8c5 2852 void onTimerTick() {
whismanoid 0:3edb3708c8c5 2853 } // onTimerTick
whismanoid 0:3edb3708c8c5 2854 #endif
whismanoid 0:3edb3708c8c5 2855
whismanoid 0:3edb3708c8c5 2856 #if USE_PERIODIC_TIMER
whismanoid 0:3edb3708c8c5 2857 // periodic interrupt timer command handlers -- enable timer
whismanoid 0:3edb3708c8c5 2858 void cmd_TE()
whismanoid 0:3edb3708c8c5 2859 {
whismanoid 0:3edb3708c8c5 2860 //us_timestamp_t interval_usec = 100000; // 100ms
whismanoid 0:3edb3708c8c5 2861 periodicInterruptTimer_interval_usec = 100000; // 100ms
whismanoid 0:3edb3708c8c5 2862 # if HAS_DAPLINK_SERIAL
whismanoid 17:c2f46173f6b2 2863 DAPLINKserial.printf(" TE rate=%lluus -- Timer Enable\r\n", periodicInterruptTimer_interval_usec);
whismanoid 0:3edb3708c8c5 2864 # endif
whismanoid 17:c2f46173f6b2 2865 serial.printf(" TE rate=%lluus -- Timer Enable", periodicInterruptTimer_interval_usec);
whismanoid 17:c2f46173f6b2 2866 #if 1
whismanoid 17:c2f46173f6b2 2867 // mbed shared event queue run onTimerTick() in Thread context not Interrupt context
whismanoid 17:c2f46173f6b2 2868 periodicInterruptTimer.attach_us(mbed_event_queue()->event(onTimerTick),
whismanoid 17:c2f46173f6b2 2869 periodicInterruptTimer_interval_usec);
whismanoid 17:c2f46173f6b2 2870 // Works if rate=620Hz or less, Fails if rate=750Hz
whismanoid 17:c2f46173f6b2 2871 // MbedOS Error Info Error Status 0x80FF0144 code 324 module 255
whismanoid 17:c2f46173f6b2 2872 // Assertion failed; id location 0xBE6F mbed-os.lib/events/Event.h+158
whismanoid 17:c2f46173f6b2 2873 // Current thread main id 0x200036f8 entry 0xc22f stacksize 0x1000 stackmem 0x200026f8 sp 0x2007ff60
whismanoid 17:c2f46173f6b2 2874 // Seems not robust about overrun / sample rate too fast
whismanoid 17:c2f46173f6b2 2875 #else
whismanoid 0:3edb3708c8c5 2876 periodicInterruptTimer.attach_us(&onTimerTick, periodicInterruptTimer_interval_usec);
whismanoid 17:c2f46173f6b2 2877 #endif
whismanoid 0:3edb3708c8c5 2878 // -- periodicInterruptTimer.attach(&onTimerTick, interval_sec); // the address of the function to be attached (onTimerTick) and the interval (2 seconds)
whismanoid 0:3edb3708c8c5 2879 // -- periodicInterruptTimer.attach_us(&onTimerTick, interval_usec); // the address of the function to be attached (onTimerTick) and the interval (2 seconds)
whismanoid 0:3edb3708c8c5 2880 // -- periodicInterruptTimer.attach(Callback<void()> func, float t);
whismanoid 0:3edb3708c8c5 2881 // -- periodicInterruptTimer.attach_us(Callback<void()> func, us_timestamp_t t);
whismanoid 0:3edb3708c8c5 2882 // TODO1: cmd_T add cSubCommand to change interval of Ticker periodic interrupt timer
whismanoid 0:3edb3708c8c5 2883 }
whismanoid 0:3edb3708c8c5 2884 #endif
whismanoid 0:3edb3708c8c5 2885
whismanoid 0:3edb3708c8c5 2886 #if USE_PERIODIC_TIMER
whismanoid 0:3edb3708c8c5 2887 // periodic interrupt timer command handlers -- disable timer
whismanoid 0:3edb3708c8c5 2888 void cmd_TD()
whismanoid 0:3edb3708c8c5 2889 {
whismanoid 0:3edb3708c8c5 2890 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 2891 DAPLINKserial.printf(" Timer Disable\r\n");
whismanoid 0:3edb3708c8c5 2892 # endif
whismanoid 8:132276960128 2893 serial.printf(" Timer Disable ");
whismanoid 0:3edb3708c8c5 2894 periodicInterruptTimer.detach(); // Detach the function
whismanoid 0:3edb3708c8c5 2895 }
whismanoid 0:3edb3708c8c5 2896 #endif
whismanoid 0:3edb3708c8c5 2897
whismanoid 0:3edb3708c8c5 2898 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2899 // When user presses button BUTTON1, perform a demo configuration
whismanoid 0:3edb3708c8c5 2900 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 2901 void onButton1FallingEdge(void)
whismanoid 0:3edb3708c8c5 2902 {
whismanoid 0:3edb3708c8c5 2903 void SelfTest(CmdLine & cmdLine);
whismanoid 0:3edb3708c8c5 2904
whismanoid 8:132276960128 2905 SelfTest(cmdLine_serial);
whismanoid 0:3edb3708c8c5 2906
whismanoid 0:3edb3708c8c5 2907 #if 0 // APPLICATION_MAX5715 // onButton1FallingEdge BUTTON1 demo configuration MAX5715BOB
whismanoid 0:3edb3708c8c5 2908 //~ cmdLine.serial().printf("MAX5715_REF(REF_AlwaysOn_2V500)");
whismanoid 0:3edb3708c8c5 2909 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500);
whismanoid 0:3edb3708c8c5 2910
whismanoid 0:3edb3708c8c5 2911 uint16_t code = 4095;
whismanoid 0:3edb3708c8c5 2912 //~ cmdLine.serial().printf("CODEallLOADall code=%d", code);
whismanoid 0:3edb3708c8c5 2913 g_MAX5715_device.CODEallLOADall(code);
whismanoid 0:3edb3708c8c5 2914 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 2915
whismanoid 0:3edb3708c8c5 2916 }
whismanoid 0:3edb3708c8c5 2917 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 2918
whismanoid 0:3edb3708c8c5 2919 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2920 // When user presses button BUTTON2, perform a demo configuration
whismanoid 0:3edb3708c8c5 2921 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 2922 void onButton2FallingEdge(void)
whismanoid 0:3edb3708c8c5 2923 {
whismanoid 0:3edb3708c8c5 2924 // TODO1: BUTTON2 demo configuration LED blink
whismanoid 0:3edb3708c8c5 2925
whismanoid 0:3edb3708c8c5 2926 #if APPLICATION_MAX5715 // onButton2FallingEdge BUTTON2 demo configuration MAX5715BOB
whismanoid 0:3edb3708c8c5 2927 //~ cmdLine.serial().printf("MAX5715_REF(REF_AlwaysOn_2V048)");
whismanoid 0:3edb3708c8c5 2928 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048);
whismanoid 0:3edb3708c8c5 2929 //
whismanoid 0:3edb3708c8c5 2930 uint16_t ch = 0;
whismanoid 0:3edb3708c8c5 2931 uint16_t code = 0xccc;
whismanoid 0:3edb3708c8c5 2932 //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 2933 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2934 //
whismanoid 0:3edb3708c8c5 2935 ch = 1;
whismanoid 0:3edb3708c8c5 2936 code = 0x800;
whismanoid 0:3edb3708c8c5 2937 //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 2938 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2939 //
whismanoid 0:3edb3708c8c5 2940 ch = 2;
whismanoid 0:3edb3708c8c5 2941 code = 0x666;
whismanoid 0:3edb3708c8c5 2942 //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 2943 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2944 //
whismanoid 0:3edb3708c8c5 2945 ch = 3;
whismanoid 0:3edb3708c8c5 2946 code = 0xFFF;
whismanoid 0:3edb3708c8c5 2947 //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 2948 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2949 #elif APPLICATION_MAX11131 // onButton2FallingEdge BUTTON2 demo configuration MAX11131BOB
whismanoid 0:3edb3708c8c5 2950 // TODO1: demo
whismanoid 0:3edb3708c8c5 2951 // MAX11131 > 4
whismanoid 0:3edb3708c8c5 2952 // ScanStandardExternalClock ch=9 pm=0 id=1
whismanoid 0:3edb3708c8c5 2953 // ScanRead_nWords_chanID nWords=10
whismanoid 0:3edb3708c8c5 2954 // ch=0 xu=2964 = 0x0b94 = 1.8091V
whismanoid 0:3edb3708c8c5 2955 // ch=1 xu=2227 = 0x08b3 = 1.3593V
whismanoid 0:3edb3708c8c5 2956 // ch=2 xu=1570 = 0x0622 = 0.9583V
whismanoid 0:3edb3708c8c5 2957 // ch=3 xu=865 = 0x0361 = 0.5280V
whismanoid 0:3edb3708c8c5 2958 // ch=4 xu=630 = 0x0276 = 0.3845V
whismanoid 0:3edb3708c8c5 2959 // ch=5 xu=594 = 0x0252 = 0.3625V
whismanoid 0:3edb3708c8c5 2960 // ch=6 xu=461 = 0x01cd = 0.2814V
whismanoid 0:3edb3708c8c5 2961 // ch=7 xu=364 = 0x016c = 0.2222V
whismanoid 0:3edb3708c8c5 2962 // ch=8 xu=480 = 0x01e0 = 0.2930V
whismanoid 0:3edb3708c8c5 2963 // ch=9 xu=616 = 0x0268 = 0.3760V
whismanoid 0:3edb3708c8c5 2964 g_MAX11131_device.channelNumber_0_15 = 9;
whismanoid 0:3edb3708c8c5 2965 g_MAX11131_device.PowerManagement_0_2 = 0;
whismanoid 0:3edb3708c8c5 2966 g_MAX11131_device.chan_id_0_1 = 1;
whismanoid 0:3edb3708c8c5 2967 g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock();
whismanoid 0:3edb3708c8c5 2968 //
whismanoid 0:3edb3708c8c5 2969 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 2970 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 2971 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 2972 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 2973 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 2974 //
whismanoid 0:3edb3708c8c5 2975 // TODO: compare with mbed/Arduino AIN0-AIN3
whismanoid 0:3edb3708c8c5 2976 //
whismanoid 0:3edb3708c8c5 2977 #elif APPLICATION_MAX5171 // onButton2FallingEdge BUTTON2 demo configuration MAX5171BOB
whismanoid 0:3edb3708c8c5 2978 // TODO: demo
whismanoid 0:3edb3708c8c5 2979 uint16_t code = 0xccc;
whismanoid 0:3edb3708c8c5 2980 g_MAX5171_device.CODE(code);
whismanoid 0:3edb3708c8c5 2981 #elif APPLICATION_MAX11410 // onButton2FallingEdge BUTTON2 demo configuration MAX11410BOB
whismanoid 0:3edb3708c8c5 2982 // TODO: demo
whismanoid 0:3edb3708c8c5 2983 g_MAX11410_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2984 #elif APPLICATION_MAX12345 // onButton2FallingEdge BUTTON2 demo configuration MAX12345BOB
whismanoid 0:3edb3708c8c5 2985 // TODO: demo
whismanoid 0:3edb3708c8c5 2986 g_MAX12345_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2987 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 2988 rgb_led.blue(); // diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 2989
whismanoid 0:3edb3708c8c5 2990 }
whismanoid 0:3edb3708c8c5 2991 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 2992
whismanoid 0:3edb3708c8c5 2993 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2994 // TODO1: use MaximTinyTester encapsulate SelfTest support functions
whismanoid 0:3edb3708c8c5 2995 //--------------------------------------------------
whismanoid 2:b3a8a0ca0a94 2996 #if APPLICATION_MAX5715 // SelfTest
whismanoid 2:b3a8a0ca0a94 2997 //
whismanoid 2:b3a8a0ca0a94 2998 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 2:b3a8a0ca0a94 2999 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 2:b3a8a0ca0a94 3000 //
whismanoid 2:b3a8a0ca0a94 3001 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3002 // uint8_t MAX5715::Init(void)
whismanoid 2:b3a8a0ca0a94 3003 // uint8_t (*fn_MAX5715_Init)() = [](){ return g_MAX5715_device.Init(); };
whismanoid 2:b3a8a0ca0a94 3004 uint8_t fn_MAX5715_Init() { return g_MAX5715_device.Init(); };
whismanoid 2:b3a8a0ca0a94 3005 //
whismanoid 2:b3a8a0ca0a94 3006 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3007 // uint16_t MAX5715::DACCodeOfVoltage(double voltageV)
whismanoid 2:b3a8a0ca0a94 3008 // uint16_t (*fn_MAX5715_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5715_device.DACCodeOfVoltage(voltageV); };
whismanoid 2:b3a8a0ca0a94 3009 uint16_t fn_MAX5715_DACCodeOfVoltage(double voltageV) { return g_MAX5715_device.DACCodeOfVoltage(voltageV); };
whismanoid 2:b3a8a0ca0a94 3010 //
whismanoid 2:b3a8a0ca0a94 3011 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3012 // double MAX5715::VoltageOfCode(uint16_t value_u14)
whismanoid 2:b3a8a0ca0a94 3013 //double (*fn_MAX5715_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5715_device.VoltageOfCode(value_u14); };
whismanoid 2:b3a8a0ca0a94 3014 double fn_MAX5715_VoltageOfCode(uint16_t value_u14) { return g_MAX5715_device.VoltageOfCode(value_u14); };
whismanoid 2:b3a8a0ca0a94 3015 //
whismanoid 2:b3a8a0ca0a94 3016 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3017 // void MAX5715::CODEnLOADn(uint8_t channel_0_3, uint16_t dacCodeLsbs)
whismanoid 2:b3a8a0ca0a94 3018 // void (*fn_MAX5715_CODEnLOADn)(uint8_t channel_0_3, uint16_t dacCodeLsbs) = [](uint8_t channel_0_3, uint16_t dacCodeLsbs){ return g_MAX5715_device.CODEnLOADn(channel_0_3, dacCodeLsbs); };
whismanoid 2:b3a8a0ca0a94 3019 void fn_MAX5715_CODEnLOADn (uint8_t channel_0_3, uint16_t dacCodeLsbs) { return g_MAX5715_device.CODEnLOADn(channel_0_3, dacCodeLsbs); };
whismanoid 2:b3a8a0ca0a94 3020 //
whismanoid 2:b3a8a0ca0a94 3021 #endif // APPLICATION_MAX5715 // SelfTest
whismanoid 2:b3a8a0ca0a94 3022 //--------------------------------------------------
whismanoid 2:b3a8a0ca0a94 3023 #if APPLICATION_MAX11131 // SelfTest
whismanoid 2:b3a8a0ca0a94 3024 //
whismanoid 2:b3a8a0ca0a94 3025 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 2:b3a8a0ca0a94 3026 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 2:b3a8a0ca0a94 3027 //
whismanoid 2:b3a8a0ca0a94 3028 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3029 //
whismanoid 2:b3a8a0ca0a94 3030 #endif // APPLICATION_MAX11131 // SelfTest
whismanoid 2:b3a8a0ca0a94 3031 //--------------------------------------------------
whismanoid 2:b3a8a0ca0a94 3032 #if APPLICATION_MAX5171 // SelfTest
whismanoid 2:b3a8a0ca0a94 3033 //
whismanoid 2:b3a8a0ca0a94 3034 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 2:b3a8a0ca0a94 3035 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 2:b3a8a0ca0a94 3036 //
whismanoid 2:b3a8a0ca0a94 3037 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3038 // uint8_t MAX5171::Init(void)
whismanoid 2:b3a8a0ca0a94 3039 // uint8_t (*fn_MAX5171_Init)() = [](){ return g_MAX5171_device.Init(); };
whismanoid 2:b3a8a0ca0a94 3040 uint8_t fn_MAX5171_Init() { return g_MAX5171_device.Init(); };
whismanoid 2:b3a8a0ca0a94 3041 //
whismanoid 2:b3a8a0ca0a94 3042 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3043 // uint16_t MAX5171::DACCodeOfVoltage(double voltageV)
whismanoid 2:b3a8a0ca0a94 3044 // uint16_t (*fn_MAX5171_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5171_device.DACCodeOfVoltage(voltageV); };
whismanoid 2:b3a8a0ca0a94 3045 uint16_t fn_MAX5171_DACCodeOfVoltage(double voltageV) { return g_MAX5171_device.DACCodeOfVoltage(voltageV); };
whismanoid 2:b3a8a0ca0a94 3046 //
whismanoid 2:b3a8a0ca0a94 3047 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3048 // double MAX5171::VoltageOfCode(uint16_t value_u14)
whismanoid 2:b3a8a0ca0a94 3049 // double (*fn_MAX5171_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5171_device.VoltageOfCode(value_u14); };
whismanoid 2:b3a8a0ca0a94 3050 double fn_MAX5171_VoltageOfCode(uint16_t value_u14) { return g_MAX5171_device.VoltageOfCode(value_u14); };
whismanoid 2:b3a8a0ca0a94 3051 //
whismanoid 2:b3a8a0ca0a94 3052 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3053 // uint8_t MAX5171::CODE_LOAD(uint16_t dacCodeLsbs)
whismanoid 2:b3a8a0ca0a94 3054 // uint8_t (*fn_MAX5171_CODE_LOAD)(uint16_t dacCodeLsbs) = [](uint16_t dacCodeLsbs){ return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); };
whismanoid 2:b3a8a0ca0a94 3055 uint8_t fn_MAX5171_CODE_LOAD(uint16_t dacCodeLsbs) { return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); };
whismanoid 2:b3a8a0ca0a94 3056 //
whismanoid 2:b3a8a0ca0a94 3057 //
whismanoid 2:b3a8a0ca0a94 3058 #endif // APPLICATION_MAX5171 // SelfTest
whismanoid 2:b3a8a0ca0a94 3059 //--------------------------------------------------
whismanoid 2:b3a8a0ca0a94 3060 #if APPLICATION_MAX11410 // SelfTest
whismanoid 2:b3a8a0ca0a94 3061 //
whismanoid 2:b3a8a0ca0a94 3062 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 2:b3a8a0ca0a94 3063 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 2:b3a8a0ca0a94 3064 //
whismanoid 2:b3a8a0ca0a94 3065 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3066 //
whismanoid 2:b3a8a0ca0a94 3067 #endif // APPLICATION_MAX11410 // SelfTest
whismanoid 2:b3a8a0ca0a94 3068 //--------------------------------------------------
whismanoid 2:b3a8a0ca0a94 3069 #if APPLICATION_MAX12345 // SelfTest
whismanoid 2:b3a8a0ca0a94 3070 //
whismanoid 2:b3a8a0ca0a94 3071 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 2:b3a8a0ca0a94 3072 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 2:b3a8a0ca0a94 3073 //
whismanoid 2:b3a8a0ca0a94 3074 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 3075 //
whismanoid 2:b3a8a0ca0a94 3076 #endif // APPLICATION_MAX12345 // SelfTest
whismanoid 2:b3a8a0ca0a94 3077 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 3078 void SelfTest_print_DACCodeOfVoltage(CmdLine& cmdLine, double voltageV)
whismanoid 0:3edb3708c8c5 3079 {
whismanoid 0:3edb3708c8c5 3080 cmdLine.serial().printf("DACCodeOfVoltage(%6.4fV)", voltageV);
whismanoid 0:3edb3708c8c5 3081 // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001
whismanoid 0:3edb3708c8c5 3082 // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001
whismanoid 0:3edb3708c8c5 3083 //~ dtostrf(voltageV, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer
whismanoid 0:3edb3708c8c5 3084 //~ cmdLine.serial().printf(strOutLineBuffer);
whismanoid 0:3edb3708c8c5 3085 //~ cmdLine.serial().printf("V)");
whismanoid 0:3edb3708c8c5 3086 }
whismanoid 0:3edb3708c8c5 3087 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 3088 #if APPLICATION_MAX5171 // SelfTest
whismanoid 0:3edb3708c8c5 3089 void SelfTest_print_VoltageOfCode(CmdLine& cmdLine, uint16_t value_u14)
whismanoid 0:3edb3708c8c5 3090 {
whismanoid 0:3edb3708c8c5 3091 cmdLine.serial().printf("VoltageOfCode(%d)", value_u14);
whismanoid 0:3edb3708c8c5 3092 }
whismanoid 0:3edb3708c8c5 3093 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 3094 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 3095 #if APPLICATION_MAX5715 // SelfTest
whismanoid 0:3edb3708c8c5 3096 void SelfTest_print_Vref(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 3097 {
whismanoid 0:3edb3708c8c5 3098 cmdLine.serial().printf("VRef = %6.4fV LSB=%6.4fV", g_MAX5715_device.VRef, (g_MAX5715_device.VRef / 4095));
whismanoid 0:3edb3708c8c5 3099 //~ dtostrf(g_MAX5715_device.VRef, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer
whismanoid 0:3edb3708c8c5 3100 //~ cmdLine.serial().printf(strOutLineBuffer);
whismanoid 0:3edb3708c8c5 3101 //~ cmdLine.serial().printf("V LSB=");
whismanoid 0:3edb3708c8c5 3102 // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001
whismanoid 0:3edb3708c8c5 3103 // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001
whismanoid 0:3edb3708c8c5 3104 //~ dtostrf( (g_MAX5715_device.VRef / 4095), 6, 4, strOutLineBuffer); // value, width, precision, char* buffer
whismanoid 0:3edb3708c8c5 3105 //~ cmdLine.serial().printf(strOutLineBuffer);
whismanoid 0:3edb3708c8c5 3106 //~ cmdLine.serial().printf("V");
whismanoid 0:3edb3708c8c5 3107 }
whismanoid 0:3edb3708c8c5 3108 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 3109 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 3110 #if APPLICATION_MAX5171 // SelfTest
whismanoid 0:3edb3708c8c5 3111 void SelfTest_print_Vref(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 3112 {
whismanoid 0:3edb3708c8c5 3113 cmdLine.serial().printf("VRef = %7.5fV LSB=%7.5fV", g_MAX5171_device.VRef, (g_MAX5171_device.VRef / 16383));
whismanoid 0:3edb3708c8c5 3114 // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001
whismanoid 0:3edb3708c8c5 3115 // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001
whismanoid 0:3edb3708c8c5 3116 }
whismanoid 0:3edb3708c8c5 3117 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 3118 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 3119 #if HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 3120 MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 20:b156b328349d 3121 #endif // HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 3122 //--------------------------------------------------
whismanoid 20:b156b328349d 3123 #if HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 3124 bool SelfTest_MAX541_Voltage(CmdLine & cmdLine, MAX541 &max541, double voltageV)
whismanoid 0:3edb3708c8c5 3125 {
whismanoid 0:3edb3708c8c5 3126 max541.Set_Voltage(voltageV);
whismanoid 0:3edb3708c8c5 3127 // cmdLine.serial().printf("\r\n Test Fixture: MAX541 set output to %1.3fV = code 0x%4.4x", max541.Get_Voltage(), max541.Get_Code());
whismanoid 0:3edb3708c8c5 3128 cmdLine.serial().printf("\r\n Test Fixture: MAX541 set output to 0x%4.4x = %1.3fV",
whismanoid 0:3edb3708c8c5 3129 max541.Get_Code(), max541.Get_Voltage());
whismanoid 0:3edb3708c8c5 3130 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 0:3edb3708c8c5 3131 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 9:32f27a0857bf 3132 MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4, led1, led2, led3);
whismanoid 0:3edb3708c8c5 3133 tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support
whismanoid 0:3edb3708c8c5 3134 tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support
whismanoid 0:3edb3708c8c5 3135 tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support
whismanoid 0:3edb3708c8c5 3136 tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support
whismanoid 0:3edb3708c8c5 3137 tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support
whismanoid 0:3edb3708c8c5 3138 tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support
whismanoid 0:3edb3708c8c5 3139 // low range channels AIN0, AIN1, AIN2, AIN3
whismanoid 0:3edb3708c8c5 3140 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 0:3edb3708c8c5 3141 // Platform board uses simple analog inputs
whismanoid 9:32f27a0857bf 3142 MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5, led1, led2, led3);
whismanoid 0:3edb3708c8c5 3143 tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support
whismanoid 0:3edb3708c8c5 3144 tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support
whismanoid 0:3edb3708c8c5 3145 tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support
whismanoid 0:3edb3708c8c5 3146 tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support
whismanoid 0:3edb3708c8c5 3147 tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support
whismanoid 0:3edb3708c8c5 3148 tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support
whismanoid 0:3edb3708c8c5 3149 #endif
whismanoid 6:95367feb30e8 3150 tinyTester.Wait_Output_Settling(); // wait for MAX541 to settle
whismanoid 0:3edb3708c8c5 3151 // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3152 tinyTester.err_threshold = 0.100;
whismanoid 0:3edb3708c8c5 3153 return tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
whismanoid 0:3edb3708c8c5 3154 }
whismanoid 20:b156b328349d 3155 #endif // HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 3156 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 3157 void SelfTest(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 3158 {
whismanoid 0:3edb3708c8c5 3159 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 3160 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 0:3edb3708c8c5 3161 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 9:32f27a0857bf 3162 MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4, led1, led2, led3);
whismanoid 0:3edb3708c8c5 3163 tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support
whismanoid 0:3edb3708c8c5 3164 tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support
whismanoid 0:3edb3708c8c5 3165 tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support
whismanoid 0:3edb3708c8c5 3166 tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support
whismanoid 0:3edb3708c8c5 3167 tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support
whismanoid 0:3edb3708c8c5 3168 tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support
whismanoid 0:3edb3708c8c5 3169 // low range channels AIN0, AIN1, AIN2, AIN3
whismanoid 0:3edb3708c8c5 3170 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 0:3edb3708c8c5 3171 // Platform board uses simple analog inputs
whismanoid 9:32f27a0857bf 3172 MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5, led1, led2, led3);
whismanoid 0:3edb3708c8c5 3173 tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support
whismanoid 0:3edb3708c8c5 3174 tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support
whismanoid 0:3edb3708c8c5 3175 tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support
whismanoid 0:3edb3708c8c5 3176 tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support
whismanoid 0:3edb3708c8c5 3177 tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support
whismanoid 0:3edb3708c8c5 3178 tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support
whismanoid 0:3edb3708c8c5 3179 #endif
whismanoid 9:32f27a0857bf 3180 tinyTester.clear();
whismanoid 0:3edb3708c8c5 3181 #if APPLICATION_MAX5715 // SelfTest
whismanoid 0:3edb3708c8c5 3182 //
whismanoid 6:95367feb30e8 3183 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 0:3edb3708c8c5 3184 //
whismanoid 1:40369075c365 3185 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 1:40369075c365 3186 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 0:3edb3708c8c5 3187 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3188 // uint8_t MAX5715::Init(void)
whismanoid 2:b3a8a0ca0a94 3189 //uint8_t (*fn_MAX5715_Init)() = [](){ return g_MAX5715_device.Init(); };
whismanoid 0:3edb3708c8c5 3190 //
whismanoid 0:3edb3708c8c5 3191 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3192 // uint16_t MAX5715::DACCodeOfVoltage(double voltageV)
whismanoid 2:b3a8a0ca0a94 3193 //uint16_t (*fn_MAX5715_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5715_device.DACCodeOfVoltage(voltageV); };
whismanoid 0:3edb3708c8c5 3194 //
whismanoid 0:3edb3708c8c5 3195 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3196 // double MAX5715::VoltageOfCode(uint16_t value_u14)
whismanoid 2:b3a8a0ca0a94 3197 //double (*fn_MAX5715_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5715_device.VoltageOfCode(value_u14); };
whismanoid 0:3edb3708c8c5 3198 //
whismanoid 0:3edb3708c8c5 3199 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3200 // void MAX5715::CODEnLOADn(uint8_t channel_0_3, uint16_t dacCodeLsbs)
whismanoid 2:b3a8a0ca0a94 3201 //void (*fn_MAX5715_CODEnLOADn)(uint8_t channel_0_3, uint16_t dacCodeLsbs) = [](uint8_t channel_0_3, uint16_t dacCodeLsbs){ return g_MAX5715_device.CODEnLOADn(channel_0_3, dacCodeLsbs); };
whismanoid 0:3edb3708c8c5 3202 //
whismanoid 0:3edb3708c8c5 3203 //
whismanoid 0:3edb3708c8c5 3204 //
whismanoid 0:3edb3708c8c5 3205 //
whismanoid 0:3edb3708c8c5 3206 //
whismanoid 0:3edb3708c8c5 3207 //------------------------------------------------------------
whismanoid 0:3edb3708c8c5 3208 g_MAX5715_device.VRef = 4.096; // MAX5715 12-bit LSB = 0.0010V
whismanoid 0:3edb3708c8c5 3209 SelfTest_print_Vref(cmdLine);
whismanoid 0:3edb3708c8c5 3210 //~ cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3211 //
whismanoid 10:8bc22d5740d5 3212 tinyTester.blink_time_msec = 20; // quickly speed through the software verification
whismanoid 0:3edb3708c8c5 3213 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 0:3edb3708c8c5 3214 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS
whismanoid 0:3edb3708c8c5 3215 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0950, 0x0FFF);
whismanoid 0:3edb3708c8c5 3216 //
whismanoid 0:3edb3708c8c5 3217 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0945, 0x0FFF);
whismanoid 0:3edb3708c8c5 3218 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0944, 0x0FFE);
whismanoid 0:3edb3708c8c5 3219 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0943, 0x0FFE);
whismanoid 0:3edb3708c8c5 3220 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0942, 0x0FFE);
whismanoid 0:3edb3708c8c5 3221 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0941, 0x0FFE);
whismanoid 0:3edb3708c8c5 3222 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0940, 0x0FFE); // search for code transition
whismanoid 0:3edb3708c8c5 3223 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0939, 0x0FFE);
whismanoid 0:3edb3708c8c5 3224 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0938, 0x0FFE);
whismanoid 0:3edb3708c8c5 3225 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0937, 0x0FFE);
whismanoid 0:3edb3708c8c5 3226 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0936, 0x0FFE);
whismanoid 0:3edb3708c8c5 3227 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0935, 0x0FFD);
whismanoid 0:3edb3708c8c5 3228 //
whismanoid 0:3edb3708c8c5 3229 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0930, 0x0FFD);
whismanoid 0:3edb3708c8c5 3230 //
whismanoid 0:3edb3708c8c5 3231 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0480, 0x0800);
whismanoid 0:3edb3708c8c5 3232 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0470, 0x07FF);
whismanoid 0:3edb3708c8c5 3233 //
whismanoid 0:3edb3708c8c5 3234 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x03E8); // 1.0 volt
whismanoid 0:3edb3708c8c5 3235 //
whismanoid 0:3edb3708c8c5 3236 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0030, 0x0003);
whismanoid 0:3edb3708c8c5 3237 //
whismanoid 0:3edb3708c8c5 3238 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0020, 0x0002);
whismanoid 0:3edb3708c8c5 3239 //
whismanoid 0:3edb3708c8c5 3240 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0001);
whismanoid 0:3edb3708c8c5 3241 //
whismanoid 0:3edb3708c8c5 3242 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000);
whismanoid 0:3edb3708c8c5 3243 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3244 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3245 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3246 //
whismanoid 0:3edb3708c8c5 3247 // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect
whismanoid 0:3edb3708c8c5 3248 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 4.0950);
whismanoid 0:3edb3708c8c5 3249 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 4.0940);
whismanoid 0:3edb3708c8c5 3250 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 2.0480);
whismanoid 0:3edb3708c8c5 3251 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 2.0470);
whismanoid 0:3edb3708c8c5 3252 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x03E8, 1.0000); // 1.0 volt
whismanoid 0:3edb3708c8c5 3253 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0010);
whismanoid 0:3edb3708c8c5 3254 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000);
whismanoid 0:3edb3708c8c5 3255 //
whismanoid 0:3edb3708c8c5 3256 //------------------------------------------------------------
whismanoid 0:3edb3708c8c5 3257 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3258 g_MAX5715_device.VRef = 2.048; // 12-bit LSB = 0.0005V
whismanoid 0:3edb3708c8c5 3259 SelfTest_print_Vref(cmdLine);
whismanoid 0:3edb3708c8c5 3260 //~ cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3261 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 0:3edb3708c8c5 3262 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS
whismanoid 0:3edb3708c8c5 3263 //
whismanoid 0:3edb3708c8c5 3264 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0480, 0x0FFF);
whismanoid 0:3edb3708c8c5 3265 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0479, 0x0FFF);
whismanoid 0:3edb3708c8c5 3266 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0478, 0x0FFF);
whismanoid 0:3edb3708c8c5 3267 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0477, 0x0FFF);
whismanoid 0:3edb3708c8c5 3268 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0476, 0x0FFF);
whismanoid 0:3edb3708c8c5 3269 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0475, 0x0FFF);
whismanoid 0:3edb3708c8c5 3270 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0474, 0x0FFF);
whismanoid 0:3edb3708c8c5 3271 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0473, 0x0FFF);
whismanoid 0:3edb3708c8c5 3272 //
whismanoid 0:3edb3708c8c5 3273 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0472, 0x0FFE);
whismanoid 0:3edb3708c8c5 3274 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0471, 0x0FFE);
whismanoid 0:3edb3708c8c5 3275 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0470, 0x0FFE);
whismanoid 0:3edb3708c8c5 3276 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0469, 0x0FFE);
whismanoid 0:3edb3708c8c5 3277 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0468, 0x0FFE);
whismanoid 0:3edb3708c8c5 3278 //
whismanoid 0:3edb3708c8c5 3279 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0467, 0x0FFD);
whismanoid 0:3edb3708c8c5 3280 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0466, 0x0FFD);
whismanoid 0:3edb3708c8c5 3281 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0465, 0x0FFD);
whismanoid 0:3edb3708c8c5 3282 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0464, 0x0FFD);
whismanoid 0:3edb3708c8c5 3283 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0463, 0x0FFD);
whismanoid 0:3edb3708c8c5 3284 //
whismanoid 0:3edb3708c8c5 3285 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0240, 0x0800);
whismanoid 0:3edb3708c8c5 3286 //
whismanoid 0:3edb3708c8c5 3287 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0235, 0x07FF);
whismanoid 0:3edb3708c8c5 3288 //
whismanoid 0:3edb3708c8c5 3289 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x07D0); // 1.0 volt
whismanoid 0:3edb3708c8c5 3290 //
whismanoid 0:3edb3708c8c5 3291 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0017, 0x0003);
whismanoid 0:3edb3708c8c5 3292 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0016, 0x0003);
whismanoid 0:3edb3708c8c5 3293 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0015, 0x0003);
whismanoid 0:3edb3708c8c5 3294 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0014, 0x0003);
whismanoid 0:3edb3708c8c5 3295 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0013, 0x0003);
whismanoid 0:3edb3708c8c5 3296 //
whismanoid 0:3edb3708c8c5 3297 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0012, 0x0002);
whismanoid 0:3edb3708c8c5 3298 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0011, 0x0002);
whismanoid 0:3edb3708c8c5 3299 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0002);
whismanoid 0:3edb3708c8c5 3300 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0009, 0x0002);
whismanoid 0:3edb3708c8c5 3301 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0008, 0x0002);
whismanoid 0:3edb3708c8c5 3302 //
whismanoid 0:3edb3708c8c5 3303 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0007, 0x0001);
whismanoid 0:3edb3708c8c5 3304 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0006, 0x0001);
whismanoid 0:3edb3708c8c5 3305 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0005, 0x0001);
whismanoid 0:3edb3708c8c5 3306 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0004, 0x0001);
whismanoid 0:3edb3708c8c5 3307 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0003, 0x0001);
whismanoid 0:3edb3708c8c5 3308 //
whismanoid 0:3edb3708c8c5 3309 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0002, 0x0000);
whismanoid 0:3edb3708c8c5 3310 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0001, 0x0000);
whismanoid 0:3edb3708c8c5 3311 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000);
whismanoid 0:3edb3708c8c5 3312 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3313 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3314 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3315 // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect
whismanoid 0:3edb3708c8c5 3316 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 2.0475);
whismanoid 0:3edb3708c8c5 3317 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 2.0470);
whismanoid 0:3edb3708c8c5 3318 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFD, 2.0465);
whismanoid 0:3edb3708c8c5 3319 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 1.0240);
whismanoid 0:3edb3708c8c5 3320 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 1.0235);
whismanoid 0:3edb3708c8c5 3321 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07D0, 1.0000); // 1.0 volt
whismanoid 0:3edb3708c8c5 3322 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0002, 0.0010);
whismanoid 0:3edb3708c8c5 3323 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0005);
whismanoid 0:3edb3708c8c5 3324 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000);
whismanoid 0:3edb3708c8c5 3325 //
whismanoid 0:3edb3708c8c5 3326 //
whismanoid 0:3edb3708c8c5 3327 //------------------------------------------------------------
whismanoid 0:3edb3708c8c5 3328 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3329 g_MAX5715_device.VRef = 2.500; // 12-bit LSB = 0.0006105006105006105V
whismanoid 0:3edb3708c8c5 3330 SelfTest_print_Vref(cmdLine);
whismanoid 0:3edb3708c8c5 3331 //~ cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3332 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 0:3edb3708c8c5 3333 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS
whismanoid 0:3edb3708c8c5 3334 //
whismanoid 0:3edb3708c8c5 3335 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.5000, 0x0FFF);
whismanoid 0:3edb3708c8c5 3336 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4999, 0x0FFF);
whismanoid 0:3edb3708c8c5 3337 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4998, 0x0FFF);
whismanoid 0:3edb3708c8c5 3338 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4997, 0x0FFF);
whismanoid 0:3edb3708c8c5 3339 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4996, 0x0FFF);
whismanoid 0:3edb3708c8c5 3340 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4995, 0x0FFF);
whismanoid 0:3edb3708c8c5 3341 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4994, 0x0FFF);
whismanoid 0:3edb3708c8c5 3342 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4993, 0x0FFF);
whismanoid 0:3edb3708c8c5 3343 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4992, 0x0FFF);
whismanoid 0:3edb3708c8c5 3344 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4991, 0x0FFF);
whismanoid 0:3edb3708c8c5 3345 //
whismanoid 0:3edb3708c8c5 3346 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4990, 0x0FFE); // search for code transitions
whismanoid 0:3edb3708c8c5 3347 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4989, 0x0FFE);
whismanoid 0:3edb3708c8c5 3348 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4988, 0x0FFE);
whismanoid 0:3edb3708c8c5 3349 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4987, 0x0FFE);
whismanoid 0:3edb3708c8c5 3350 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4986, 0x0FFE);
whismanoid 0:3edb3708c8c5 3351 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4985, 0x0FFE);
whismanoid 0:3edb3708c8c5 3352 //
whismanoid 0:3edb3708c8c5 3353 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4984, 0x0FFD);
whismanoid 0:3edb3708c8c5 3354 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4983, 0x0FFD);
whismanoid 0:3edb3708c8c5 3355 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4982, 0x0FFD);
whismanoid 0:3edb3708c8c5 3356 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4981, 0x0FFD);
whismanoid 0:3edb3708c8c5 3357 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4980, 0x0FFD);
whismanoid 0:3edb3708c8c5 3358 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4979, 0x0FFD);
whismanoid 0:3edb3708c8c5 3359 //
whismanoid 0:3edb3708c8c5 3360 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4978, 0x0FFC);
whismanoid 0:3edb3708c8c5 3361 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4977, 0x0FFC);
whismanoid 0:3edb3708c8c5 3362 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4976, 0x0FFC);
whismanoid 0:3edb3708c8c5 3363 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4975, 0x0FFC);
whismanoid 0:3edb3708c8c5 3364 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4974, 0x0FFC);
whismanoid 0:3edb3708c8c5 3365 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4973, 0x0FFC);
whismanoid 0:3edb3708c8c5 3366 //
whismanoid 0:3edb3708c8c5 3367 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4972, 0x0FFB);
whismanoid 0:3edb3708c8c5 3368 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4971, 0x0FFB);
whismanoid 0:3edb3708c8c5 3369 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4970, 0x0FFB);
whismanoid 0:3edb3708c8c5 3370 //
whismanoid 0:3edb3708c8c5 3371 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.2500, 0x0800);
whismanoid 0:3edb3708c8c5 3372 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.2494, 0x07FF);
whismanoid 0:3edb3708c8c5 3373 //
whismanoid 0:3edb3708c8c5 3374 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x0666); // 1.0 volt
whismanoid 0:3edb3708c8c5 3375 //
whismanoid 0:3edb3708c8c5 3376 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0019, 0x0003); // search for code transitions
whismanoid 0:3edb3708c8c5 3377 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0018, 0x0003);
whismanoid 0:3edb3708c8c5 3378 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0017, 0x0003);
whismanoid 0:3edb3708c8c5 3379 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0016, 0x0003);
whismanoid 0:3edb3708c8c5 3380 //
whismanoid 0:3edb3708c8c5 3381 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0015, 0x0002);
whismanoid 0:3edb3708c8c5 3382 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0014, 0x0002);
whismanoid 0:3edb3708c8c5 3383 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0013, 0x0002);
whismanoid 0:3edb3708c8c5 3384 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0012, 0x0002);
whismanoid 0:3edb3708c8c5 3385 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0011, 0x0002);
whismanoid 0:3edb3708c8c5 3386 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0002);
whismanoid 0:3edb3708c8c5 3387 //
whismanoid 0:3edb3708c8c5 3388 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0009, 0x0001);
whismanoid 0:3edb3708c8c5 3389 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0008, 0x0001);
whismanoid 0:3edb3708c8c5 3390 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0007, 0x0001);
whismanoid 0:3edb3708c8c5 3391 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0006, 0x0001);
whismanoid 0:3edb3708c8c5 3392 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0005, 0x0001);
whismanoid 0:3edb3708c8c5 3393 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0004, 0x0001);
whismanoid 0:3edb3708c8c5 3394 //
whismanoid 0:3edb3708c8c5 3395 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0003, 0x0000);
whismanoid 0:3edb3708c8c5 3396 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0002, 0x0000);
whismanoid 0:3edb3708c8c5 3397 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0001, 0x0000);
whismanoid 0:3edb3708c8c5 3398 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000);
whismanoid 0:3edb3708c8c5 3399 //
whismanoid 0:3edb3708c8c5 3400 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3401 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3402 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3403 // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect
whismanoid 0:3edb3708c8c5 3404 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 2.5000);
whismanoid 0:3edb3708c8c5 3405 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 2.4988);
whismanoid 0:3edb3708c8c5 3406 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFD, 2.4976);
whismanoid 0:3edb3708c8c5 3407 //
whismanoid 0:3edb3708c8c5 3408 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 1.2500);
whismanoid 0:3edb3708c8c5 3409 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 1.2494);
whismanoid 0:3edb3708c8c5 3410 //
whismanoid 0:3edb3708c8c5 3411 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0667, 1.0000); // 1.0 volt
whismanoid 0:3edb3708c8c5 3412 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0666, 1.0000); // 1.0 volt
whismanoid 0:3edb3708c8c5 3413 //
whismanoid 0:3edb3708c8c5 3414 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0002, 0.0012);
whismanoid 0:3edb3708c8c5 3415 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0006);
whismanoid 0:3edb3708c8c5 3416 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000);
whismanoid 0:3edb3708c8c5 3417 //
whismanoid 0:3edb3708c8c5 3418 //
whismanoid 0:3edb3708c8c5 3419 // Device Testing: DAC commands, verify using on-board ADC inputs
whismanoid 0:3edb3708c8c5 3420 //
whismanoid 10:8bc22d5740d5 3421 tinyTester.blink_time_msec = 75;
whismanoid 0:3edb3708c8c5 3422 cmdLine.serial().printf("\r\n MAX5715.Init()");
whismanoid 0:3edb3708c8c5 3423 g_MAX5715_device.Init();
whismanoid 0:3edb3708c8c5 3424 //
whismanoid 0:3edb3708c8c5 3425 uint16_t ch = 0;
whismanoid 0:3edb3708c8c5 3426 uint16_t code = 0xfff;
whismanoid 0:3edb3708c8c5 3427 double voltageV = 0.5;
whismanoid 0:3edb3708c8c5 3428 //
whismanoid 0:3edb3708c8c5 3429 // full-scale output on ch0, test MAX5715 internal REF options
whismanoid 0:3edb3708c8c5 3430 ch = 0;
whismanoid 0:3edb3708c8c5 3431 cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 3432 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 3433 //
whismanoid 0:3edb3708c8c5 3434 cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_2V048)");
whismanoid 0:3edb3708c8c5 3435 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048);
whismanoid 6:95367feb30e8 3436 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3437 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3438 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3439 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3440 tinyTester.AnalogIn0_Read_Expect_voltageV(2.048);
whismanoid 0:3edb3708c8c5 3441 //
whismanoid 0:3edb3708c8c5 3442 cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_4V096)");
whismanoid 0:3edb3708c8c5 3443 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_4V096);
whismanoid 0:3edb3708c8c5 3444 // MAX32625MBED 4.096V may be as low as 3.3V supply
whismanoid 6:95367feb30e8 3445 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3446 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3447 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3448 tinyTester.err_threshold = 0.50; // 30mV
whismanoid 0:3edb3708c8c5 3449 tinyTester.AnalogIn0_Read_Expect_voltageV(3.750); // accept 3.25V to 4.25V
whismanoid 0:3edb3708c8c5 3450 //
whismanoid 0:3edb3708c8c5 3451 cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_2V500)");
whismanoid 0:3edb3708c8c5 3452 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500);
whismanoid 6:95367feb30e8 3453 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3454 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3455 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3456 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3457 tinyTester.AnalogIn0_Read_Expect_voltageV(2.500);
whismanoid 0:3edb3708c8c5 3458 //
whismanoid 0:3edb3708c8c5 3459 // test the individual channel outputs
whismanoid 0:3edb3708c8c5 3460 ch = 0;
whismanoid 0:3edb3708c8c5 3461 voltageV = 0.5;
whismanoid 0:3edb3708c8c5 3462 code = g_MAX5715_device.DACCodeOfVoltage(voltageV);
whismanoid 0:3edb3708c8c5 3463 cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 3464 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 6:95367feb30e8 3465 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3466 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3467 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3468 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3469 tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
whismanoid 0:3edb3708c8c5 3470 //
whismanoid 0:3edb3708c8c5 3471 ch = 1;
whismanoid 0:3edb3708c8c5 3472 voltageV = 0.2;
whismanoid 0:3edb3708c8c5 3473 code = g_MAX5715_device.DACCodeOfVoltage(voltageV);
whismanoid 0:3edb3708c8c5 3474 cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 3475 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 6:95367feb30e8 3476 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3477 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3478 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3479 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3480 tinyTester.AnalogIn1_Read_Expect_voltageV(voltageV);
whismanoid 0:3edb3708c8c5 3481 //
whismanoid 0:3edb3708c8c5 3482 ch = 2;
whismanoid 0:3edb3708c8c5 3483 voltageV = 0.4;
whismanoid 0:3edb3708c8c5 3484 code = g_MAX5715_device.DACCodeOfVoltage(voltageV);
whismanoid 0:3edb3708c8c5 3485 cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 3486 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 6:95367feb30e8 3487 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3488 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3489 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3490 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3491 tinyTester.AnalogIn2_Read_Expect_voltageV(voltageV);
whismanoid 0:3edb3708c8c5 3492 //
whismanoid 0:3edb3708c8c5 3493 ch = 3;
whismanoid 0:3edb3708c8c5 3494 voltageV = 0.25;
whismanoid 0:3edb3708c8c5 3495 code = g_MAX5715_device.DACCodeOfVoltage(voltageV);
whismanoid 0:3edb3708c8c5 3496 cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 3497 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 6:95367feb30e8 3498 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3499 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3500 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3501 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3502 tinyTester.AnalogIn3_Read_Expect_voltageV(voltageV);
whismanoid 0:3edb3708c8c5 3503 //
whismanoid 0:3edb3708c8c5 3504 // test that the channels are independent
whismanoid 0:3edb3708c8c5 3505 tinyTester.AnalogIn0_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[0]));
whismanoid 0:3edb3708c8c5 3506 tinyTester.AnalogIn1_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[1]));
whismanoid 0:3edb3708c8c5 3507 tinyTester.AnalogIn2_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[2]));
whismanoid 0:3edb3708c8c5 3508 tinyTester.AnalogIn3_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[3]));
whismanoid 0:3edb3708c8c5 3509 //
whismanoid 0:3edb3708c8c5 3510 #elif APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 3511 //
whismanoid 0:3edb3708c8c5 3512 // MAX11131BOB self-test functions
whismanoid 0:3edb3708c8c5 3513 //~ SelfTest_FAIL(cmdLine);
whismanoid 0:3edb3708c8c5 3514 //~ cmdLine.serial().printf("test program not implemented yet");
whismanoid 0:3edb3708c8c5 3515 int16_t value_u12;
whismanoid 0:3edb3708c8c5 3516 int channelId;
whismanoid 0:3edb3708c8c5 3517 double voltageV = 0.5;
whismanoid 0:3edb3708c8c5 3518 //
whismanoid 0:3edb3708c8c5 3519 //cmdLine.serial().printf("\r\n 0.0: MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3520 //g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3521 //
whismanoid 0:3edb3708c8c5 3522 // Device Testing: ADC commands, verify with on-board ADC and SPI framing
whismanoid 0:3edb3708c8c5 3523 //
whismanoid 10:8bc22d5740d5 3524 tinyTester.blink_time_msec = 75;
whismanoid 0:3edb3708c8c5 3525 // MAX11131 SelfTest: MAX11131 SPI connections (Power Supply and GND, SCLK, MOSI, MISO, CS)
whismanoid 0:3edb3708c8c5 3526 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3527 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 3528 "\r\n 1.0: Test SCAN_0100_StandardExt -- verify SPI (VDD, GND, SCLK, MOSI, MISO, CS)");
whismanoid 0:3edb3708c8c5 3529 cmdLine.serial().printf("\r\n MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3530 g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3531 // Send MOSI data Expect MISO data Description
whismanoid 0:3edb3708c8c5 3532 // 1000_0000_0000_0000 xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0
whismanoid 0:3edb3708c8c5 3533 // 0010_0111_1010_0100 xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL SCAN_0100_StandardExt CHSEL=15 RESET=1 CHANID=1
whismanoid 0:3edb3708c8c5 3534 // 0000_0000_0000_0000 0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0
whismanoid 0:3edb3708c8c5 3535 // 0000_0000_0000_0000 0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1
whismanoid 0:3edb3708c8c5 3536 // 0000_0000_0000_0000 0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2
whismanoid 0:3edb3708c8c5 3537 // 0000_0000_0000_0000 0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3
whismanoid 0:3edb3708c8c5 3538 //
whismanoid 0:3edb3708c8c5 3539 cmdLine.serial().printf("\r\n MOSI <-- 1000_0000_0000_0000 ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0");
whismanoid 0:3edb3708c8c5 3540 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3541 g_MAX11131_device.SPIwrite16bits(0x8000);
whismanoid 0:3edb3708c8c5 3542 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 0:3edb3708c8c5 3543 //
whismanoid 0:3edb3708c8c5 3544 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 3545 "\r\n MOSI <-- 0010_0111_1010_0100 ADC_MODE_CONTROL SCAN_0100_StandardExt CHSEL=15 RESET=1 CHANID=1");
whismanoid 0:3edb3708c8c5 3546 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3547 g_MAX11131_device.SPIwrite16bits(0x27a4);
whismanoid 0:3edb3708c8c5 3548 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 0:3edb3708c8c5 3549 //
whismanoid 0:3edb3708c8c5 3550 for (int channelIndex = 0; channelIndex < 16; channelIndex++) {
whismanoid 0:3edb3708c8c5 3551 //~ cmdLine.serial().printf("\r\n MISO --> expect 0000_xxxx_xxxx_xxxx");
whismanoid 0:3edb3708c8c5 3552 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3553 g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits();
whismanoid 0:3edb3708c8c5 3554 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 0:3edb3708c8c5 3555 int expect_channelId = channelIndex;
whismanoid 0:3edb3708c8c5 3556 int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F;
whismanoid 0:3edb3708c8c5 3557 if (actual_channelId != expect_channelId)
whismanoid 0:3edb3708c8c5 3558 {
whismanoid 3:8913cb4a8b9f 3559 tinyTester.FAIL();
whismanoid 0:3edb3708c8c5 3560 cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
whismanoid 0:3edb3708c8c5 3561 cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
whismanoid 0:3edb3708c8c5 3562 cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId);
whismanoid 0:3edb3708c8c5 3563 }
whismanoid 0:3edb3708c8c5 3564 else
whismanoid 0:3edb3708c8c5 3565 {
whismanoid 3:8913cb4a8b9f 3566 tinyTester.PASS();
whismanoid 0:3edb3708c8c5 3567 cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
whismanoid 0:3edb3708c8c5 3568 cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
whismanoid 0:3edb3708c8c5 3569 }
whismanoid 0:3edb3708c8c5 3570 }
whismanoid 0:3edb3708c8c5 3571 //
whismanoid 6:95367feb30e8 3572 // MAX11131 SelfTest: MAX11131 Supports Internal Clock Modes (CNVST, EOC)
whismanoid 0:3edb3708c8c5 3573 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3574 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 3575 "\r\n 1.1: Test SCAN_0011_StandardInt -- verify Internal Clock signals (CNVST, EOC)");
whismanoid 0:3edb3708c8c5 3576 cmdLine.serial().printf("\r\n MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3577 g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3578 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3579 g_MAX11131_device.RAW_misoData16[0] = g_MAX11131_device.SPIread16bits();
whismanoid 0:3edb3708c8c5 3580 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 3:8913cb4a8b9f 3581 //
whismanoid 6:95367feb30e8 3582 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
whismanoid 3:8913cb4a8b9f 3583 tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "initial value before sending commands");
whismanoid 3:8913cb4a8b9f 3584 //
whismanoid 0:3edb3708c8c5 3585 // Send MOSI data Expect MISO data Description
whismanoid 0:3edb3708c8c5 3586 // 1000_0000_0000_0000 xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0 No Averaging
whismanoid 0:3edb3708c8c5 3587 // 0001_1001_1010_0000 xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL SCAN_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0
whismanoid 0:3edb3708c8c5 3588 // 0000_0000_0000_0000 0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0
whismanoid 0:3edb3708c8c5 3589 // 0000_0000_0000_0000 0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1
whismanoid 0:3edb3708c8c5 3590 // 0000_0000_0000_0000 0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2
whismanoid 0:3edb3708c8c5 3591 // 0000_0000_0000_0000 0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3
whismanoid 0:3edb3708c8c5 3592 //
whismanoid 0:3edb3708c8c5 3593 cmdLine.serial().printf("\r\n MOSI <-- 1000_0000_0000_0000 ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0");
whismanoid 0:3edb3708c8c5 3594 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3595 g_MAX11131_device.SPIwrite16bits(0x8000);
whismanoid 0:3edb3708c8c5 3596 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 0:3edb3708c8c5 3597 //
whismanoid 0:3edb3708c8c5 3598 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 3599 "\r\n MOSI <-- 0001_1001_1010_0000 ADC_MODE_CONTROL SCAN_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0");
whismanoid 0:3edb3708c8c5 3600 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3601 g_MAX11131_device.SPIwrite16bits(0x19a0);
whismanoid 0:3edb3708c8c5 3602 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 0:3edb3708c8c5 3603 //
whismanoid 0:3edb3708c8c5 3604 for (int channelIndex = 0; channelIndex < 4; channelIndex++) {
whismanoid 0:3edb3708c8c5 3605 //~ cmdLine.serial().printf("\r\n MISO --> expect 0000_xxxx_xxxx_xxxx");
whismanoid 0:3edb3708c8c5 3606 //~ wait_ms(200); // delay
whismanoid 0:3edb3708c8c5 3607 g_MAX11131_device.CNVSToutputPulseLow();
whismanoid 0:3edb3708c8c5 3608 //~ g_MAX11131_device.CNVSToutputValue(0);
whismanoid 0:3edb3708c8c5 3609 //~ wait_ms(100); // delay
whismanoid 0:3edb3708c8c5 3610 //~ g_MAX11131_device.CNVSToutputValue(1);
whismanoid 0:3edb3708c8c5 3611 // g_MAX11131_device.EOCinputWaitUntilLow(); // infinite wait hazard, need to fail if timeout exceeded
whismanoid 6:95367feb30e8 3612 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
whismanoid 3:8913cb4a8b9f 3613 tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 0, "after CNVST pulse");
whismanoid 0:3edb3708c8c5 3614 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3615 g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits();
whismanoid 0:3edb3708c8c5 3616 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 6:95367feb30e8 3617 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
whismanoid 3:8913cb4a8b9f 3618 tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "after SPI read");
whismanoid 0:3edb3708c8c5 3619 int expect_channelId = channelIndex;
whismanoid 0:3edb3708c8c5 3620 int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F;
whismanoid 0:3edb3708c8c5 3621 if (actual_channelId != expect_channelId)
whismanoid 0:3edb3708c8c5 3622 {
whismanoid 3:8913cb4a8b9f 3623 tinyTester.FAIL();
whismanoid 0:3edb3708c8c5 3624 cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
whismanoid 0:3edb3708c8c5 3625 cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
whismanoid 0:3edb3708c8c5 3626 cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId);
whismanoid 0:3edb3708c8c5 3627 }
whismanoid 0:3edb3708c8c5 3628 else
whismanoid 0:3edb3708c8c5 3629 {
whismanoid 3:8913cb4a8b9f 3630 tinyTester.PASS();
whismanoid 0:3edb3708c8c5 3631 cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
whismanoid 0:3edb3708c8c5 3632 cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
whismanoid 0:3edb3708c8c5 3633 }
whismanoid 0:3edb3708c8c5 3634 }
whismanoid 0:3edb3708c8c5 3635 //
whismanoid 6:95367feb30e8 3636 // MAX11131 SelfTest: Test Fixture: MAX541ACPA+ to MAX32625MBED.AIN0/AIN4
whismanoid 0:3edb3708c8c5 3637 // Test Fixture: MAX541 connected to spi2
whismanoid 0:3edb3708c8c5 3638 // SPI spi2_max541(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 TARGET_MAX32635MBED: P2_5 P2_6 P2_4 Arduino 2x3-pin header; microSD
whismanoid 0:3edb3708c8c5 3639 // DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header
whismanoid 0:3edb3708c8c5 3640 // Test Fixture: MAX541 spi2 init
whismanoid 0:3edb3708c8c5 3641 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3642 cmdLine.serial().printf("\r\n 2.0: Test Fixture: MAX541 connected to spi2 (P2.4 P2.5 P2.7)?");
whismanoid 0:3edb3708c8c5 3643 bool SelfTest_has_max541 = false;
whismanoid 20:b156b328349d 3644 #if HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 3645 // Check actual MAX541 reference voltage
whismanoid 0:3edb3708c8c5 3646 cmdLine.serial().printf("\r\n Test Fixture: MAX541 midscale voltage measure with MAX32625MBED AIN0/4");
whismanoid 0:3edb3708c8c5 3647 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 6:95367feb30e8 3648 tinyTester.Wait_Output_Settling(); // wait for MAX541 to settle
whismanoid 6:95367feb30e8 3649 //
whismanoid 0:3edb3708c8c5 3650 double max541_midscale_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 3651 const int average_count = 100;
whismanoid 0:3edb3708c8c5 3652 const double average_K = 0.25;
whismanoid 0:3edb3708c8c5 3653 for (int count = 0; count < average_count; count++) {
whismanoid 0:3edb3708c8c5 3654 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 3655 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 0:3edb3708c8c5 3656 }
whismanoid 0:3edb3708c8c5 3657 if (max541_midscale_V > 1.0f) {
whismanoid 0:3edb3708c8c5 3658 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 0:3edb3708c8c5 3659 cmdLine.serial().printf("\r\n Test Fixture: MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 0:3edb3708c8c5 3660 max541_midscale_V, max541.VRef);
whismanoid 0:3edb3708c8c5 3661 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 0:3edb3708c8c5 3662 voltageV = 1.0f;
whismanoid 0:3edb3708c8c5 3663 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3664 }
whismanoid 0:3edb3708c8c5 3665 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3666 voltageV = 0.0f;
whismanoid 0:3edb3708c8c5 3667 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3668 }
whismanoid 0:3edb3708c8c5 3669 if (SelfTest_has_max541) {
whismanoid 6:95367feb30e8 3670 voltageV = 2.7f;
whismanoid 0:3edb3708c8c5 3671 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3672 }
whismanoid 0:3edb3708c8c5 3673 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3674 voltageV = 1.65f;
whismanoid 0:3edb3708c8c5 3675 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3676 }
whismanoid 0:3edb3708c8c5 3677 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3678 voltageV = 2.0f;
whismanoid 0:3edb3708c8c5 3679 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3680 }
whismanoid 0:3edb3708c8c5 3681 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3682 voltageV = 0.25f;
whismanoid 0:3edb3708c8c5 3683 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3684 }
whismanoid 0:3edb3708c8c5 3685 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3686 voltageV = 0.5f;
whismanoid 0:3edb3708c8c5 3687 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3688 }
whismanoid 0:3edb3708c8c5 3689 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3690 voltageV = 1.0f;
whismanoid 0:3edb3708c8c5 3691 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3692 }
whismanoid 20:b156b328349d 3693 #endif // HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 3694 if (SelfTest_has_max541 == false) {
whismanoid 0:3edb3708c8c5 3695 // don't fail just because we're missing the test fixture...
whismanoid 0:3edb3708c8c5 3696 cmdLine.serial().printf("\r\n Test Fixture: MAX541 not present");
whismanoid 0:3edb3708c8c5 3697 //~ g_SelfTest_nFail--;
whismanoid 0:3edb3708c8c5 3698 }
whismanoid 0:3edb3708c8c5 3699 //
whismanoid 0:3edb3708c8c5 3700 // TODO1: MAX11131 SelfTest: if Test Fixture: drive MAX541, compare MAX32625MBED.AIN0/AIN4 and MAX11131 AIN0
whismanoid 0:3edb3708c8c5 3701 // indirectly verify the reference voltage by reading a known input voltage
whismanoid 21:58de1593e2ca 3702 #if HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 3703 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3704 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3705 cmdLine.serial().printf("\r\n 2.1: TODO1: Check MAX11131 reference voltage using SCAN_0001_Manual");
whismanoid 0:3edb3708c8c5 3706 voltageV = 1.0f;
whismanoid 0:3edb3708c8c5 3707 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3708 cmdLine.serial().printf("\r\n MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3709 g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3710 // 1 ScanManual ch=0 pm=0 id=1
whismanoid 0:3edb3708c8c5 3711 g_MAX11131_device.channelNumber_0_15 = 0;
whismanoid 0:3edb3708c8c5 3712 g_MAX11131_device.PowerManagement_0_2 = 0;
whismanoid 0:3edb3708c8c5 3713 g_MAX11131_device.chan_id_0_1 = 1;
whismanoid 0:3edb3708c8c5 3714 cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15);
whismanoid 0:3edb3708c8c5 3715 cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2);
whismanoid 0:3edb3708c8c5 3716 cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1);
whismanoid 0:3edb3708c8c5 3717 g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
whismanoid 0:3edb3708c8c5 3718 cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d",
whismanoid 0:3edb3708c8c5 3719 g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3720 g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
whismanoid 0:3edb3708c8c5 3721 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 3722 cmdLine.serial().printf("\r\n MAX11131.ReadAINcode");
whismanoid 0:3edb3708c8c5 3723 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3724 //
whismanoid 0:3edb3708c8c5 3725 // 2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here?
whismanoid 0:3edb3708c8c5 3726 //
whismanoid 0:3edb3708c8c5 3727 cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d",
whismanoid 0:3edb3708c8c5 3728 g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3729 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 3730 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 3731 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 3732 cmdLine.serial().printf("\r\n MAX11131.ReadAINcode");
whismanoid 0:3edb3708c8c5 3733 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3734 //
whismanoid 0:3edb3708c8c5 3735 // 2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here?
whismanoid 0:3edb3708c8c5 3736 //
whismanoid 0:3edb3708c8c5 3737 // compare with mbed/Arduino AIN0-AIN3
whismanoid 0:3edb3708c8c5 3738 // MAX32625MBED.AIN4 = MAX11131.AIN0
whismanoid 0:3edb3708c8c5 3739 channelId = 0;
whismanoid 0:3edb3708c8c5 3740 value_u12 = g_MAX11131_device.AINcode[channelId];
whismanoid 0:3edb3708c8c5 3741 voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
whismanoid 3:8913cb4a8b9f 3742 //
whismanoid 6:95367feb30e8 3743 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 3:8913cb4a8b9f 3744 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3745 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 3:8913cb4a8b9f 3746 tinyTester.err_threshold = 0.100;
whismanoid 3:8913cb4a8b9f 3747 tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
whismanoid 3:8913cb4a8b9f 3748 //
whismanoid 0:3edb3708c8c5 3749 }
whismanoid 0:3edb3708c8c5 3750 //
whismanoid 0:3edb3708c8c5 3751 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3752 voltageV = 1.0f;
whismanoid 0:3edb3708c8c5 3753 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3754 }
whismanoid 21:58de1593e2ca 3755 #endif // HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 3756 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3757 cmdLine.serial().printf("\r\n 3.1: Test SCAN_0001_Manual");
whismanoid 0:3edb3708c8c5 3758 cmdLine.serial().printf("\r\n MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3759 g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3760 // 1 ScanManual ch=0 pm=0 id=1
whismanoid 0:3edb3708c8c5 3761 g_MAX11131_device.channelNumber_0_15 = 0;
whismanoid 0:3edb3708c8c5 3762 g_MAX11131_device.PowerManagement_0_2 = 0;
whismanoid 0:3edb3708c8c5 3763 g_MAX11131_device.chan_id_0_1 = 1;
whismanoid 0:3edb3708c8c5 3764 cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15);
whismanoid 0:3edb3708c8c5 3765 cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2);
whismanoid 0:3edb3708c8c5 3766 cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1);
whismanoid 0:3edb3708c8c5 3767 g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
whismanoid 0:3edb3708c8c5 3768 cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d",
whismanoid 0:3edb3708c8c5 3769 g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3770 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 3771 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 3772 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 3773 cmdLine.serial().printf("\r\n MAX11131.ReadAINcode");
whismanoid 0:3edb3708c8c5 3774 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3775 // compare with mbed/Arduino AIN0-AIN3
whismanoid 0:3edb3708c8c5 3776 // MAX32625MBED.AIN4 = MAX11131.AIN0
whismanoid 0:3edb3708c8c5 3777 channelId = 0;
whismanoid 0:3edb3708c8c5 3778 value_u12 = g_MAX11131_device.AINcode[channelId];
whismanoid 0:3edb3708c8c5 3779 voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
whismanoid 3:8913cb4a8b9f 3780 //
whismanoid 6:95367feb30e8 3781 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 3:8913cb4a8b9f 3782 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3783 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 3:8913cb4a8b9f 3784 tinyTester.err_threshold = 0.100;
whismanoid 3:8913cb4a8b9f 3785 tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
whismanoid 3:8913cb4a8b9f 3786 //
whismanoid 0:3edb3708c8c5 3787 //
whismanoid 0:3edb3708c8c5 3788 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3789 cmdLine.serial().printf("\r\n 3.4: Test SCAN_0100_StandardExternalClock");
whismanoid 0:3edb3708c8c5 3790 cmdLine.serial().printf("\r\n MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3791 g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3792 // MAX11131 > 4
whismanoid 0:3edb3708c8c5 3793 // ScanStandardExternalClock ch=9 pm=0 id=1
whismanoid 0:3edb3708c8c5 3794 // ScanRead_nWords_chanID nWords=10
whismanoid 0:3edb3708c8c5 3795 // ch=0 xu=2964 = 0x0b94 = 1.8091V
whismanoid 0:3edb3708c8c5 3796 // ch=1 xu=2227 = 0x08b3 = 1.3593V
whismanoid 0:3edb3708c8c5 3797 // ch=2 xu=1570 = 0x0622 = 0.9583V
whismanoid 0:3edb3708c8c5 3798 // ch=3 xu=865 = 0x0361 = 0.5280V
whismanoid 0:3edb3708c8c5 3799 // ch=4 xu=630 = 0x0276 = 0.3845V
whismanoid 0:3edb3708c8c5 3800 // ch=5 xu=594 = 0x0252 = 0.3625V
whismanoid 0:3edb3708c8c5 3801 // ch=6 xu=461 = 0x01cd = 0.2814V
whismanoid 0:3edb3708c8c5 3802 // ch=7 xu=364 = 0x016c = 0.2222V
whismanoid 0:3edb3708c8c5 3803 // ch=8 xu=480 = 0x01e0 = 0.2930V
whismanoid 0:3edb3708c8c5 3804 // ch=9 xu=616 = 0x0268 = 0.3760V
whismanoid 0:3edb3708c8c5 3805 g_MAX11131_device.channelNumber_0_15 = 9;
whismanoid 0:3edb3708c8c5 3806 g_MAX11131_device.PowerManagement_0_2 = 0;
whismanoid 0:3edb3708c8c5 3807 g_MAX11131_device.chan_id_0_1 = 1;
whismanoid 0:3edb3708c8c5 3808 cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15);
whismanoid 0:3edb3708c8c5 3809 cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2);
whismanoid 0:3edb3708c8c5 3810 cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1);
whismanoid 0:3edb3708c8c5 3811 g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock();
whismanoid 0:3edb3708c8c5 3812 cmdLine.serial().printf("\r\n MAX11131.ScanStandardExternalClock -- NumWords = %d",
whismanoid 0:3edb3708c8c5 3813 g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3814 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 3815 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 3816 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 3817 cmdLine.serial().printf("\r\n MAX11131.ReadAINcode");
whismanoid 0:3edb3708c8c5 3818 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 3819 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 6:95367feb30e8 3820 // expect g_MAX11131_device.NumWords == g_MAX11131_device.channelNumber_0_15 + 1;
whismanoid 6:95367feb30e8 3821 // expect RAW_misoData16[index] msnybble 0,1,2,3,...
whismanoid 0:3edb3708c8c5 3822 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 6:95367feb30e8 3823 // compare with mbed/Arduino AIN0-AIN3
whismanoid 0:3edb3708c8c5 3824 // MAX32625MBED.AIN4 = MAX11131.AIN0
whismanoid 0:3edb3708c8c5 3825 channelId = 0;
whismanoid 0:3edb3708c8c5 3826 value_u12 = g_MAX11131_device.AINcode[channelId];
whismanoid 0:3edb3708c8c5 3827 voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
whismanoid 6:95367feb30e8 3828 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 3:8913cb4a8b9f 3829 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3830 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 3:8913cb4a8b9f 3831 tinyTester.err_threshold = 0.100;
whismanoid 3:8913cb4a8b9f 3832 tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
whismanoid 6:95367feb30e8 3833 // compare MAX32625MBED.AIN5 = MAX11131.AIN1
whismanoid 0:3edb3708c8c5 3834 //channelId = 1;
whismanoid 0:3edb3708c8c5 3835 //value_u12 = g_MAX11131_device.AINcode[channelId];
whismanoid 0:3edb3708c8c5 3836 //voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
whismanoid 0:3edb3708c8c5 3837 //SelfTest_AnalogInput_Expect_ch_V(cmdLine, 5, voltageV, 0.100);
whismanoid 0:3edb3708c8c5 3838 //
whismanoid 0:3edb3708c8c5 3839 #elif APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 3840
whismanoid 6:95367feb30e8 3841 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 0:3edb3708c8c5 3842 //
whismanoid 1:40369075c365 3843 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 1:40369075c365 3844 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 0:3edb3708c8c5 3845 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3846 // uint8_t MAX5171::Init(void)
whismanoid 2:b3a8a0ca0a94 3847 //uint8_t (*fn_MAX5171_Init)() = [](){ return g_MAX5171_device.Init(); };
whismanoid 0:3edb3708c8c5 3848 //
whismanoid 0:3edb3708c8c5 3849 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3850 // uint16_t MAX5171::DACCodeOfVoltage(double voltageV)
whismanoid 2:b3a8a0ca0a94 3851 //uint16_t (*fn_MAX5171_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5171_device.DACCodeOfVoltage(voltageV); };
whismanoid 0:3edb3708c8c5 3852 //
whismanoid 0:3edb3708c8c5 3853 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3854 // double MAX5171::VoltageOfCode(uint16_t value_u14)
whismanoid 2:b3a8a0ca0a94 3855 //double (*fn_MAX5171_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5171_device.VoltageOfCode(value_u14); };
whismanoid 0:3edb3708c8c5 3856 //
whismanoid 0:3edb3708c8c5 3857 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3858 // uint8_t MAX5171::CODE_LOAD(uint16_t dacCodeLsbs)
whismanoid 2:b3a8a0ca0a94 3859 //uint8_t (*fn_MAX5171_CODE_LOAD)(uint16_t dacCodeLsbs) = [](uint16_t dacCodeLsbs){ return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); };
whismanoid 0:3edb3708c8c5 3860 //
whismanoid 0:3edb3708c8c5 3861 //double one_LSB = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS
whismanoid 6:95367feb30e8 3862 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3863 tinyTester.settle_time_msec = 250;
whismanoid 0:3edb3708c8c5 3864
whismanoid 0:3edb3708c8c5 3865 g_MAX5171_device.VRef = 2.500; // MAX5171 14-bit LSB = 0.00015V
whismanoid 0:3edb3708c8c5 3866 SelfTest_print_Vref(cmdLine);
whismanoid 9:32f27a0857bf 3867 tinyTester.err_threshold = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS
whismanoid 0:3edb3708c8c5 3868 //
whismanoid 6:95367feb30e8 3869 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 10:8bc22d5740d5 3870 tinyTester.blink_time_msec = 20; // quickly speed through the software verification
whismanoid 0:3edb3708c8c5 3871 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.499847412109375, 0x3FFF);
whismanoid 0:3edb3708c8c5 3872 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.49969482421875, 0x3FFE);
whismanoid 0:3edb3708c8c5 3873 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.499542236328125, 0x3FFD);
whismanoid 0:3edb3708c8c5 3874 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.4993896484375, 0x3FFC);
whismanoid 0:3edb3708c8c5 3875 //
whismanoid 0:3edb3708c8c5 3876 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.250152587890625, 0x2001);
whismanoid 0:3edb3708c8c5 3877 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.25, 0x2000);
whismanoid 0:3edb3708c8c5 3878 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.249847412109375, 0x1FFF);
whismanoid 0:3edb3708c8c5 3879 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.24969482421875, 0x1FFE);
whismanoid 0:3edb3708c8c5 3880 //
whismanoid 0:3edb3708c8c5 3881 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.000457763671875, 0x0003);
whismanoid 0:3edb3708c8c5 3882 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.00030517578125, 0x0002);
whismanoid 0:3edb3708c8c5 3883 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.000152587890625, 0x0001);
whismanoid 0:3edb3708c8c5 3884 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.00000, 0x0000);
whismanoid 0:3edb3708c8c5 3885 //
whismanoid 6:95367feb30e8 3886 // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect
whismanoid 0:3edb3708c8c5 3887 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFF, 2.499847412109375);
whismanoid 0:3edb3708c8c5 3888 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFE, 2.49969482421875);
whismanoid 0:3edb3708c8c5 3889 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFD, 2.499542236328125);
whismanoid 0:3edb3708c8c5 3890 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFC, 2.4993896484375);
whismanoid 0:3edb3708c8c5 3891 //
whismanoid 0:3edb3708c8c5 3892 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x2001, 1.250152587890625);
whismanoid 0:3edb3708c8c5 3893 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x2000, 1.25);
whismanoid 0:3edb3708c8c5 3894 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x1FFF, 1.249847412109375);
whismanoid 0:3edb3708c8c5 3895 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x1FFE, 1.24969482421875);
whismanoid 0:3edb3708c8c5 3896 //
whismanoid 0:3edb3708c8c5 3897 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0003, 0.000457763671875);
whismanoid 0:3edb3708c8c5 3898 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0002, 0.00030517578125);
whismanoid 0:3edb3708c8c5 3899 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0001, 0.000152587890625);
whismanoid 0:3edb3708c8c5 3900 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0000, 0.00000);
whismanoid 0:3edb3708c8c5 3901 //
whismanoid 0:3edb3708c8c5 3902 // Device Testing: DAC commands, verify using on-board ADC inputs
whismanoid 0:3edb3708c8c5 3903 //
whismanoid 10:8bc22d5740d5 3904 tinyTester.blink_time_msec = 75;
whismanoid 0:3edb3708c8c5 3905 cmdLine.serial().printf("\r\n MAX5171.Init()");
whismanoid 0:3edb3708c8c5 3906 g_MAX5171_device.Init();
whismanoid 0:3edb3708c8c5 3907 //
whismanoid 0:3edb3708c8c5 3908 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3909 uint16_t code = 0x3FFF;
whismanoid 0:3edb3708c8c5 3910 //~ double voltageV = 0.5;
whismanoid 0:3edb3708c8c5 3911 //
whismanoid 0:3edb3708c8c5 3912 cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code);
whismanoid 0:3edb3708c8c5 3913 g_MAX5171_device.CODE_LOAD(code);
whismanoid 6:95367feb30e8 3914 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3915 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3916 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3917 tinyTester.AnalogIn0_Read_Expect_voltageV(2.500);
whismanoid 0:3edb3708c8c5 3918 //
whismanoid 0:3edb3708c8c5 3919 code = 0x0000;
whismanoid 0:3edb3708c8c5 3920 cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code);
whismanoid 0:3edb3708c8c5 3921 g_MAX5171_device.CODE_LOAD(code);
whismanoid 6:95367feb30e8 3922 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3923 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3924 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3925 tinyTester.AnalogIn0_Read_Expect_voltageV(0.0000);
whismanoid 0:3edb3708c8c5 3926 //
whismanoid 0:3edb3708c8c5 3927 code = 0x1FFF;
whismanoid 0:3edb3708c8c5 3928 cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code);
whismanoid 0:3edb3708c8c5 3929 g_MAX5171_device.CODE_LOAD(code);
whismanoid 6:95367feb30e8 3930 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3931 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3932 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3933 tinyTester.AnalogIn0_Read_Expect_voltageV(1.2500);
whismanoid 0:3edb3708c8c5 3934 //
whismanoid 0:3edb3708c8c5 3935 // test UPO User Programmable Output, verify using digital input D2
whismanoid 0:3edb3708c8c5 3936 //
whismanoid 0:3edb3708c8c5 3937 cmdLine.serial().printf("\r\n MAX5171.UPO_HIGH");
whismanoid 0:3edb3708c8c5 3938 g_MAX5171_device.UPO_HIGH();
whismanoid 0:3edb3708c8c5 3939 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3940 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin
whismanoid 0:3edb3708c8c5 3941 tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command");
whismanoid 0:3edb3708c8c5 3942 //
whismanoid 0:3edb3708c8c5 3943 cmdLine.serial().printf("\r\n MAX5171.UPO_LOW");
whismanoid 0:3edb3708c8c5 3944 g_MAX5171_device.UPO_LOW();
whismanoid 0:3edb3708c8c5 3945 tinyTester.Wait_Output_Settling();
whismanoid 6:95367feb30e8 3946 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin
whismanoid 0:3edb3708c8c5 3947 tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 0, "UPO_pin is low after MAX5171 UPO_LOW command");
whismanoid 0:3edb3708c8c5 3948 //
whismanoid 0:3edb3708c8c5 3949 cmdLine.serial().printf("\r\n MAX5171.UPO_HIGH");
whismanoid 0:3edb3708c8c5 3950 g_MAX5171_device.UPO_HIGH();
whismanoid 0:3edb3708c8c5 3951 tinyTester.Wait_Output_Settling(); // wait_ms(100); // delay
whismanoid 6:95367feb30e8 3952 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin
whismanoid 0:3edb3708c8c5 3953 tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command");
whismanoid 0:3edb3708c8c5 3954 //
whismanoid 0:3edb3708c8c5 3955 #elif APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 3956 //
whismanoid 0:3edb3708c8c5 3957 // TODO: placeholder for self-test functions
whismanoid 16:09f10869b638 3958 tinyTester.FAIL();
whismanoid 0:3edb3708c8c5 3959 cmdLine.serial().printf("test program not implemented yet");
whismanoid 0:3edb3708c8c5 3960 //
whismanoid 0:3edb3708c8c5 3961 #elif APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 3962 //
whismanoid 0:3edb3708c8c5 3963 // TODO: placeholder for self-test functions
whismanoid 16:09f10869b638 3964 tinyTester.FAIL();
whismanoid 0:3edb3708c8c5 3965 cmdLine.serial().printf("test program not implemented yet");
whismanoid 0:3edb3708c8c5 3966 //
whismanoid 0:3edb3708c8c5 3967 #else // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 3968 // TODO: placeholder for self-test functions
whismanoid 0:3edb3708c8c5 3969 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 3970 //
whismanoid 9:32f27a0857bf 3971 #if INJECT_SELFTEST_FAIL
whismanoid 0:3edb3708c8c5 3972 // Test of the pass/fail report mechanism
whismanoid 16:09f10869b638 3973 tinyTester.FAIL();
whismanoid 0:3edb3708c8c5 3974 cmdLine.serial().printf("injecting one false failure for test reporting");
whismanoid 0:3edb3708c8c5 3975 #endif
whismanoid 0:3edb3708c8c5 3976 //
whismanoid 0:3edb3708c8c5 3977 // Report number of pass and number of fail test results
whismanoid 0:3edb3708c8c5 3978 tinyTester.Report_Summary();
whismanoid 0:3edb3708c8c5 3979 }
whismanoid 0:3edb3708c8c5 3980
whismanoid 0:3edb3708c8c5 3981
whismanoid 0:3edb3708c8c5 3982 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 3983 void main_menu_status(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 3984 {
whismanoid 0:3edb3708c8c5 3985 cmdLine.serial().printf("\r\nMain menu");
whismanoid 0:3edb3708c8c5 3986 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 0:3edb3708c8c5 3987 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 0:3edb3708c8c5 3988 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 0:3edb3708c8c5 3989 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 0:3edb3708c8c5 3990 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 0:3edb3708c8c5 3991 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 0:3edb3708c8c5 3992 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 0:3edb3708c8c5 3993 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 0:3edb3708c8c5 3994 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 0:3edb3708c8c5 3995 cmdLine.serial().printf(" MAX12345");
whismanoid 0:3edb3708c8c5 3996 #else
whismanoid 0:3edb3708c8c5 3997 //cmdLine.serial().printf(" ");
whismanoid 0:3edb3708c8c5 3998 #endif
whismanoid 0:3edb3708c8c5 3999 cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 0:3edb3708c8c5 4000 if (cmdLine.nameStr())
whismanoid 0:3edb3708c8c5 4001 {
whismanoid 0:3edb3708c8c5 4002 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 0:3edb3708c8c5 4003 }
whismanoid 0:3edb3708c8c5 4004 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 4005 cmdLine.serial().printf(" [Button1=DemoConfig1]");
whismanoid 0:3edb3708c8c5 4006 #endif
whismanoid 0:3edb3708c8c5 4007 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 4008 cmdLine.serial().printf(" [Button2=DemoConfig2]");
whismanoid 0:3edb3708c8c5 4009 #endif
whismanoid 0:3edb3708c8c5 4010 #if HAS_BUTTON1_DEMO
whismanoid 0:3edb3708c8c5 4011 // print BUTTON1 status
whismanoid 0:3edb3708c8c5 4012 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 0:3edb3708c8c5 4013 #endif
whismanoid 0:3edb3708c8c5 4014 #if HAS_BUTTON2_DEMO
whismanoid 0:3edb3708c8c5 4015 // print BUTTON1 status
whismanoid 0:3edb3708c8c5 4016 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 0:3edb3708c8c5 4017 #endif
whismanoid 0:3edb3708c8c5 4018 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 0:3edb3708c8c5 4019 }
whismanoid 0:3edb3708c8c5 4020
whismanoid 0:3edb3708c8c5 4021 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 4022 void main_menu_help(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 4023 {
whismanoid 0:3edb3708c8c5 4024 // ? -- help
whismanoid 0:3edb3708c8c5 4025 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 0:3edb3708c8c5 4026 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 0:3edb3708c8c5 4027 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 0:3edb3708c8c5 4028 //cmdLine.serial().printf("\r\n ! -- Initial Configuration");
whismanoid 0:3edb3708c8c5 4029 //
whismanoid 0:3edb3708c8c5 4030 // % standardize diagnostic commands
whismanoid 0:3edb3708c8c5 4031 // %Hpin -- digital output high
whismanoid 0:3edb3708c8c5 4032 // %Lpin -- digital output low
whismanoid 0:3edb3708c8c5 4033 // %?pin -- digital input
whismanoid 0:3edb3708c8c5 4034 // %A %Apin -- analog input
whismanoid 0:3edb3708c8c5 4035 // %Ppin df=xx -- pwm output
whismanoid 0:3edb3708c8c5 4036 // %Wpin -- measure high pulsewidth input in usec
whismanoid 0:3edb3708c8c5 4037 // %wpin -- measure low pulsewidth input in usec
whismanoid 0:3edb3708c8c5 4038 // %I... -- I2C diagnostics
whismanoid 0:3edb3708c8c5 4039 // %IP -- I2C probe
whismanoid 0:3edb3708c8c5 4040 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 0:3edb3708c8c5 4041 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 0:3edb3708c8c5 4042 // %IR ADDR=? RD=? -- read
whismanoid 0:3edb3708c8c5 4043 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 0:3edb3708c8c5 4044 // %S... -- SPI diagnostics
whismanoid 0:3edb3708c8c5 4045 // %SC sclk=1Mhz -- SPI configure
whismanoid 0:3edb3708c8c5 4046 // %SW -- write (write and read)
whismanoid 0:3edb3708c8c5 4047 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 0:3edb3708c8c5 4048 // A-Z,a-z,0-9 reserved for application use
whismanoid 0:3edb3708c8c5 4049 //
whismanoid 0:3edb3708c8c5 4050 #if HAS_digitalInOuts
whismanoid 0:3edb3708c8c5 4051 // %Hpin -- digital output high
whismanoid 0:3edb3708c8c5 4052 // %Lpin -- digital output low
whismanoid 0:3edb3708c8c5 4053 // %?pin -- digital input
whismanoid 0:3edb3708c8c5 4054 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 0:3edb3708c8c5 4055 list_digitalInOutPins(cmdLine.serial());
whismanoid 0:3edb3708c8c5 4056 cmdLine.serial().printf("} -- High Output");
whismanoid 0:3edb3708c8c5 4057 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 0:3edb3708c8c5 4058 list_digitalInOutPins(cmdLine.serial());
whismanoid 0:3edb3708c8c5 4059 cmdLine.serial().printf("} -- Low Output");
whismanoid 0:3edb3708c8c5 4060 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 0:3edb3708c8c5 4061 list_digitalInOutPins(cmdLine.serial());
whismanoid 0:3edb3708c8c5 4062 cmdLine.serial().printf("} -- Input");
whismanoid 0:3edb3708c8c5 4063 #endif
whismanoid 0:3edb3708c8c5 4064
whismanoid 0:3edb3708c8c5 4065 #if HAS_analogIns
whismanoid 0:3edb3708c8c5 4066 // Menu A) analogRead A0..7
whismanoid 0:3edb3708c8c5 4067 // %A %Apin -- analog input
whismanoid 0:3edb3708c8c5 4068 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 0:3edb3708c8c5 4069 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 0:3edb3708c8c5 4070 #endif
whismanoid 0:3edb3708c8c5 4071
whismanoid 0:3edb3708c8c5 4072 #if HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 4073 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 0:3edb3708c8c5 4074 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 0:3edb3708c8c5 4075 #endif
whismanoid 0:3edb3708c8c5 4076
whismanoid 0:3edb3708c8c5 4077 #if HAS_I2C // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 4078 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 4079 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 0:3edb3708c8c5 4080 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 0:3edb3708c8c5 4081 // %I... -- I2C diagnostics
whismanoid 0:3edb3708c8c5 4082 // %IP -- I2C probe
whismanoid 0:3edb3708c8c5 4083 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 0:3edb3708c8c5 4084 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 0:3edb3708c8c5 4085 // %IR ADDR=? RD=? -- read
whismanoid 0:3edb3708c8c5 4086 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 0:3edb3708c8c5 4087 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 0:3edb3708c8c5 4088 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 0:3edb3708c8c5 4089 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 0:3edb3708c8c5 4090 (g_I2C_SCL_Hz / 1000.));
whismanoid 0:3edb3708c8c5 4091 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 0:3edb3708c8c5 4092 g_I2C_deviceAddress7);
whismanoid 0:3edb3708c8c5 4093 //
whismanoid 0:3edb3708c8c5 4094 #if SUPPORT_I2C
whismanoid 0:3edb3708c8c5 4095 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 0:3edb3708c8c5 4096 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 0:3edb3708c8c5 4097 // test low-level I2C i2c_smbus_read_word_data
whismanoid 0:3edb3708c8c5 4098 #endif // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 4099 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 0:3edb3708c8c5 4100 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 0:3edb3708c8c5 4101 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 0:3edb3708c8c5 4102 #endif // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 4103
whismanoid 0:3edb3708c8c5 4104 #if HAS_SPI // SUPPORT_SPI
whismanoid 0:3edb3708c8c5 4105 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 0:3edb3708c8c5 4106 // SPI test command S (mosiData)+
whismanoid 0:3edb3708c8c5 4107 // %S... -- SPI diagnostics
whismanoid 0:3edb3708c8c5 4108 // %SC sclk=1Mhz -- SPI configure
whismanoid 0:3edb3708c8c5 4109 // %SW -- write (write and read)
whismanoid 0:3edb3708c8c5 4110 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 0:3edb3708c8c5 4111 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 0:3edb3708c8c5 4112 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 0:3edb3708c8c5 4113 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 0:3edb3708c8c5 4114 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 0:3edb3708c8c5 4115 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 0:3edb3708c8c5 4116 // mode | POL PHA
whismanoid 0:3edb3708c8c5 4117 // -----+--------
whismanoid 0:3edb3708c8c5 4118 // 0 | 0 0
whismanoid 0:3edb3708c8c5 4119 // 1 | 0 1
whismanoid 0:3edb3708c8c5 4120 // 2 | 1 0
whismanoid 0:3edb3708c8c5 4121 // 3 | 1 1
whismanoid 0:3edb3708c8c5 4122 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 0:3edb3708c8c5 4123 // 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 0:3edb3708c8c5 4124 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 0:3edb3708c8c5 4125 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 0:3edb3708c8c5 4126 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 0:3edb3708c8c5 4127 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 0:3edb3708c8c5 4128 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 0:3edb3708c8c5 4129 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 0:3edb3708c8c5 4130 #endif // SUPPORT_SPI
whismanoid 0:3edb3708c8c5 4131 //
whismanoid 0:3edb3708c8c5 4132 // Application-specific commands (help text) here
whismanoid 0:3edb3708c8c5 4133 //
whismanoid 0:3edb3708c8c5 4134 #if APPLICATION_ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 4135 # if APPLICATION_MAX5715 // main_menu_help
whismanoid 0:3edb3708c8c5 4136 # elif APPLICATION_MAX11131 // main_menu_help
whismanoid 0:3edb3708c8c5 4137 # elif APPLICATION_MAX5171 // main_menu_help
whismanoid 0:3edb3708c8c5 4138 # elif APPLICATION_MAX11410 // main_menu_help
whismanoid 0:3edb3708c8c5 4139 # elif APPLICATION_MAX12345 // main_menu_help
whismanoid 0:3edb3708c8c5 4140 # else
whismanoid 0:3edb3708c8c5 4141 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 4142 # endif
whismanoid 0:3edb3708c8c5 4143 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 4144 //
whismanoid 0:3edb3708c8c5 4145 #if APPLICATION_MAX5715 // main_menu_help
whismanoid 0:3edb3708c8c5 4146 cmdLine.serial().printf("\r\n 0 ch=? code=? -- CODEn");
whismanoid 0:3edb3708c8c5 4147 cmdLine.serial().printf("\r\n 1 ch=? -- LOADn");
whismanoid 0:3edb3708c8c5 4148 cmdLine.serial().printf("\r\n 2 ch=? code=? -- CODEnLOADall");
whismanoid 0:3edb3708c8c5 4149 cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn");
whismanoid 0:3edb3708c8c5 4150 cmdLine.serial().printf("\r\n 40 ch=? -- POWERn_Normal");
whismanoid 0:3edb3708c8c5 4151 cmdLine.serial().printf("\r\n 41 ch=? -- POWERn_PD1k");
whismanoid 0:3edb3708c8c5 4152 cmdLine.serial().printf("\r\n 42 ch=? -- POWERn_PD100k");
whismanoid 0:3edb3708c8c5 4153 cmdLine.serial().printf("\r\n 43 ch=? -- POWERn_PDHiZ");
whismanoid 0:3edb3708c8c5 4154 cmdLine.serial().printf("\r\n 50 -- SW_CLEAR");
whismanoid 0:3edb3708c8c5 4155 cmdLine.serial().printf("\r\n 51 -- SW_RESET");
whismanoid 0:3edb3708c8c5 4156 cmdLine.serial().printf("\r\n 60 ch=? -- CONFIGn_LATCHED");
whismanoid 0:3edb3708c8c5 4157 cmdLine.serial().printf("\r\n 61 ch=? -- CONFIGn_TRANSPARENT");
whismanoid 0:3edb3708c8c5 4158 cmdLine.serial().printf("\r\n 68 -- CONFIGall_LATCHED");
whismanoid 0:3edb3708c8c5 4159 cmdLine.serial().printf("\r\n 69 -- CONFIGall_TRANSPARENT");
whismanoid 0:3edb3708c8c5 4160 cmdLine.serial().printf("\r\n 70 -- REF_EXT");
whismanoid 0:3edb3708c8c5 4161 cmdLine.serial().printf("\r\n 71 -- REF_2V500");
whismanoid 0:3edb3708c8c5 4162 cmdLine.serial().printf("\r\n 72 -- REF_2V048");
whismanoid 0:3edb3708c8c5 4163 cmdLine.serial().printf("\r\n 73 -- REF_4V096");
whismanoid 0:3edb3708c8c5 4164 cmdLine.serial().printf("\r\n 74 -- REF_AlwaysOn_EXT");
whismanoid 0:3edb3708c8c5 4165 cmdLine.serial().printf("\r\n 75 -- REF_AlwaysOn_2V500");
whismanoid 0:3edb3708c8c5 4166 cmdLine.serial().printf("\r\n 76 -- REF_AlwaysOn_2V048");
whismanoid 0:3edb3708c8c5 4167 cmdLine.serial().printf("\r\n 77 -- REF_AlwaysOn_4V096");
whismanoid 0:3edb3708c8c5 4168 cmdLine.serial().printf("\r\n 80 code=? -- CODEall");
whismanoid 0:3edb3708c8c5 4169 cmdLine.serial().printf("\r\n 81 -- LOADall");
whismanoid 0:3edb3708c8c5 4170 cmdLine.serial().printf("\r\n 82 code=? -- CODEallLOADall");
whismanoid 0:3edb3708c8c5 4171 //cmdLine.serial().printf("\r\n 83 code=? -- CODEallLOADall");
whismanoid 0:3edb3708c8c5 4172 //
whismanoid 0:3edb3708c8c5 4173 // Menu @ -- print device configuration
whismanoid 0:3edb3708c8c5 4174 cmdLine.serial().printf("\r\n @ -- print MAX5715 configuration");
whismanoid 0:3edb3708c8c5 4175 //
whismanoid 0:3edb3708c8c5 4176 // MAX5717 menu function to drive MAX5717_LDACb_Pin LDAC#
whismanoid 0:3edb3708c8c5 4177 // Note: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 4178 cmdLine.serial().printf("\r\n L -- LDAC# pulse LH high LL low");
whismanoid 0:3edb3708c8c5 4179 // MAX5717 menu function to drive MAX5717_CLRb_Pin CLR#
whismanoid 0:3edb3708c8c5 4180 cmdLine.serial().printf("\r\n C -- CLR# pulse CH high CL low");
whismanoid 0:3edb3708c8c5 4181 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 4182 //
whismanoid 0:3edb3708c8c5 4183 #if APPLICATION_MAX11131 // main_menu_help
whismanoid 0:3edb3708c8c5 4184 // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void);
whismanoid 0:3edb3708c8c5 4185 cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead");
whismanoid 0:3edb3708c8c5 4186 // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 4187 cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual");
whismanoid 0:3edb3708c8c5 4188 // VERIFY: console menu command 2 int MAX11131_ScanRepeat(uint8_t channelNumber_0_15, uint8_t average_0_4_8_16_32, uint8_t nscan_4_8_12_16, uint8_t PowerManagement_0_2, uint8_t swcnv_0_1);
whismanoid 0:3edb3708c8c5 4189 cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat");
whismanoid 0:3edb3708c8c5 4190 // VERIFY: console menu command 3 MAX11131_ScanStandardInternalClock(int channelNumber_0_15, int average_0_4_8_16_32, int PowerManagement_0_2, int swcnv_0_1);
whismanoid 0:3edb3708c8c5 4191 cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock");
whismanoid 0:3edb3708c8c5 4192 // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 4193 cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock");
whismanoid 0:3edb3708c8c5 4194 // VERIFY: console menu command 5 MAX11131_ScanUpperInternalClock(int channelNumber_0_15, int average_0_4_8_16_32, int PowerManagement_0_2, int swcnv_0_1);
whismanoid 0:3edb3708c8c5 4195 cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock");
whismanoid 0:3edb3708c8c5 4196 // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 4197 cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock");
whismanoid 0:3edb3708c8c5 4198 // VERIFY: console menu command 7 MAX11131_ScanCustomInternalClock(int16_t enabledChannelsMask, int average_0_4_8_16_32, int PowerManagement_0_2, int swcnv_0_1);
whismanoid 0:3edb3708c8c5 4199 cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock");
whismanoid 0:3edb3708c8c5 4200 // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 4201 cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock");
whismanoid 0:3edb3708c8c5 4202 // VERIFY: console menu command 9 MAX11131_ScanSampleSetExternalClock(uint8_t enabledChannelsPatternLength_1_256, int16_t enabledChannelsPattern[], int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 4203 cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock");
whismanoid 0:3edb3708c8c5 4204 cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration");
whismanoid 0:3edb3708c8c5 4205 cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range");
whismanoid 0:3edb3708c8c5 4206 // cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual");
whismanoid 0:3edb3708c8c5 4207 // Note: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 4208 #endif // APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 4209 //
whismanoid 0:3edb3708c8c5 4210 #if APPLICATION_MAX5171 // main_menu_help
whismanoid 0:3edb3708c8c5 4211 // TODO1: MAX5171 main_menu_help
whismanoid 0:3edb3708c8c5 4212 cmdLine.serial().printf("\r\n 0 code=? -- CODE");
whismanoid 0:3edb3708c8c5 4213 cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD");
whismanoid 0:3edb3708c8c5 4214 cmdLine.serial().printf("\r\n 8 -- LOAD");
whismanoid 0:3edb3708c8c5 4215 cmdLine.serial().printf("\r\n c -- NOP");
whismanoid 0:3edb3708c8c5 4216 cmdLine.serial().printf("\r\n d -- SHUTDOWN");
whismanoid 0:3edb3708c8c5 4217 cmdLine.serial().printf("\r\n e0 -- UPO_LOW");
whismanoid 0:3edb3708c8c5 4218 cmdLine.serial().printf("\r\n e8 -- UPO_HIGH");
whismanoid 0:3edb3708c8c5 4219 cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE");
whismanoid 0:3edb3708c8c5 4220 cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE");
whismanoid 0:3edb3708c8c5 4221 // Note: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 4222 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 4223 //
whismanoid 0:3edb3708c8c5 4224 #if APPLICATION_MAX11410 // main_menu_help
whismanoid 0:3edb3708c8c5 4225 // TODO1: MAX11410 main_menu_help
whismanoid 0:3edb3708c8c5 4226 cmdLine.serial().printf("\r\n w reg=? data=? -- write register");
whismanoid 0:3edb3708c8c5 4227 cmdLine.serial().printf("\r\n r reg=? -- read register");
whismanoid 0:3edb3708c8c5 4228 cmdLine.serial().printf("\r\n TC -- thermocouple config");
whismanoid 0:3edb3708c8c5 4229 cmdLine.serial().printf("\r\n T -- RTD measurement");
whismanoid 0:3edb3708c8c5 4230 cmdLine.serial().printf("\r\n RC -- thermocouple config");
whismanoid 0:3edb3708c8c5 4231 cmdLine.serial().printf("\r\n R -- RTD measurement");
whismanoid 0:3edb3708c8c5 4232 // Note: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 4233 #endif // APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 4234 //
whismanoid 0:3edb3708c8c5 4235 #if APPLICATION_MAX12345 // main_menu_help
whismanoid 0:3edb3708c8c5 4236 cmdLine.serial().printf("\r\n 0 -- something");
whismanoid 0:3edb3708c8c5 4237 cmdLine.serial().printf("\r\n 1 -- something");
whismanoid 0:3edb3708c8c5 4238 cmdLine.serial().printf("\r\n 2 -- something");
whismanoid 0:3edb3708c8c5 4239 cmdLine.serial().printf("\r\n A -- something");
whismanoid 0:3edb3708c8c5 4240 cmdLine.serial().printf("\r\n B -- something");
whismanoid 0:3edb3708c8c5 4241 cmdLine.serial().printf("\r\n C -- something");
whismanoid 0:3edb3708c8c5 4242 // Note: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 4243 #endif // APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 4244 //
whismanoid 0:3edb3708c8c5 4245 }
whismanoid 0:3edb3708c8c5 4246
whismanoid 0:3edb3708c8c5 4247 //--------------------------------------------------
whismanoid 11:38b95a59de02 4248 // diagnostic commands submenu
whismanoid 11:38b95a59de02 4249 // invoked by main_menu_onEOLcommandParser case '%'
whismanoid 11:38b95a59de02 4250 void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 4251 {
whismanoid 11:38b95a59de02 4252 // % diagnostic commands submenu
whismanoid 11:38b95a59de02 4253 // %Hpin -- digital output high
whismanoid 11:38b95a59de02 4254 // %Lpin -- digital output low
whismanoid 11:38b95a59de02 4255 // %?pin -- digital input
whismanoid 11:38b95a59de02 4256 // %A %Apin -- analog input
whismanoid 11:38b95a59de02 4257 // %Ppin df=xx -- pwm output
whismanoid 11:38b95a59de02 4258 // %Wpin -- measure high pulsewidth input in usec
whismanoid 11:38b95a59de02 4259 // %wpin -- measure low pulsewidth input in usec
whismanoid 11:38b95a59de02 4260 // %I... -- I2C diagnostics
whismanoid 11:38b95a59de02 4261 // %IP -- I2C probe
whismanoid 11:38b95a59de02 4262 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 11:38b95a59de02 4263 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 11:38b95a59de02 4264 // %IR ADDR=? RD=? -- read
whismanoid 11:38b95a59de02 4265 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 11:38b95a59de02 4266 // %S... -- SPI diagnostics
whismanoid 11:38b95a59de02 4267 // %SC sclk=1Mhz -- SPI configure
whismanoid 11:38b95a59de02 4268 // %SW -- write (write and read)
whismanoid 11:38b95a59de02 4269 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 11:38b95a59de02 4270 // A-Z,a-z,0-9 reserved for application use
whismanoid 11:38b95a59de02 4271 //
whismanoid 11:38b95a59de02 4272 // get pinIndex from cmdLine[2]
whismanoid 11:38b95a59de02 4273 //int pinIndex = cmdLine[2];
whismanoid 11:38b95a59de02 4274 // *** warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
whismanoid 11:38b95a59de02 4275 //int pinIndex = strtoul((char *)((void *)(cmdLine.str()) + 2), NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 11:38b95a59de02 4276 // ^
whismanoid 11:38b95a59de02 4277 char strPinIndex[3];
whismanoid 11:38b95a59de02 4278 strPinIndex[0] = cmdLine[2];
whismanoid 11:38b95a59de02 4279 strPinIndex[1] = cmdLine[3];
whismanoid 11:38b95a59de02 4280 strPinIndex[2] = '\0';
whismanoid 11:38b95a59de02 4281 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 11:38b95a59de02 4282 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 0:3edb3708c8c5 4283 //
whismanoid 11:38b95a59de02 4284 // get next character
whismanoid 11:38b95a59de02 4285 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4286 {
whismanoid 11:38b95a59de02 4287 #if HAS_digitalInOuts
whismanoid 11:38b95a59de02 4288 case 'H': case 'h':
whismanoid 11:38b95a59de02 4289 {
whismanoid 11:38b95a59de02 4290 // %Hpin -- digital output high
whismanoid 11:38b95a59de02 4291 #if ARDUINO_STYLE
whismanoid 11:38b95a59de02 4292 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 11:38b95a59de02 4293 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 11:38b95a59de02 4294 #else
whismanoid 11:38b95a59de02 4295 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 11:38b95a59de02 4296 digitalInOutPin.output();
whismanoid 11:38b95a59de02 4297 digitalInOutPin.write(1);
whismanoid 11:38b95a59de02 4298 #endif
whismanoid 11:38b95a59de02 4299 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 11:38b95a59de02 4300 }
whismanoid 11:38b95a59de02 4301 break;
whismanoid 11:38b95a59de02 4302 case 'L': case 'l':
whismanoid 11:38b95a59de02 4303 {
whismanoid 11:38b95a59de02 4304 // %Lpin -- digital output low
whismanoid 11:38b95a59de02 4305 #if ARDUINO_STYLE
whismanoid 11:38b95a59de02 4306 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 11:38b95a59de02 4307 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 11:38b95a59de02 4308 #else
whismanoid 11:38b95a59de02 4309 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 11:38b95a59de02 4310 digitalInOutPin.output();
whismanoid 11:38b95a59de02 4311 digitalInOutPin.write(0);
whismanoid 11:38b95a59de02 4312 #endif
whismanoid 11:38b95a59de02 4313 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 11:38b95a59de02 4314 }
whismanoid 11:38b95a59de02 4315 break;
whismanoid 0:3edb3708c8c5 4316 case '?':
whismanoid 0:3edb3708c8c5 4317 {
whismanoid 11:38b95a59de02 4318 // %?pin -- digital input
whismanoid 11:38b95a59de02 4319 #if ARDUINO_STYLE
whismanoid 11:38b95a59de02 4320 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 11:38b95a59de02 4321 #else
whismanoid 11:38b95a59de02 4322 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 11:38b95a59de02 4323 digitalInOutPin.input();
whismanoid 11:38b95a59de02 4324 #endif
whismanoid 11:38b95a59de02 4325 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 11:38b95a59de02 4326 #if ARDUINO_STYLE
whismanoid 11:38b95a59de02 4327 int value = digitalRead(pinIndex);
whismanoid 11:38b95a59de02 4328 #else
whismanoid 11:38b95a59de02 4329 int value = digitalInOutPin.read();
whismanoid 11:38b95a59de02 4330 #endif
whismanoid 11:38b95a59de02 4331 cmdLine.serial().printf("%d ", value);
whismanoid 0:3edb3708c8c5 4332 }
whismanoid 0:3edb3708c8c5 4333 break;
whismanoid 11:38b95a59de02 4334 #endif
whismanoid 11:38b95a59de02 4335 //
whismanoid 11:38b95a59de02 4336 #if HAS_analogIns
whismanoid 11:38b95a59de02 4337 case 'A': case 'a':
whismanoid 0:3edb3708c8c5 4338 {
whismanoid 0:3edb3708c8c5 4339 // %A %Apin -- analog input
whismanoid 11:38b95a59de02 4340 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 11:38b95a59de02 4341 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 11:38b95a59de02 4342 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 11:38b95a59de02 4343 {
whismanoid 11:38b95a59de02 4344 int cPinIndex = '0' + pinIndex;
whismanoid 11:38b95a59de02 4345 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 11:38b95a59de02 4346 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 11:38b95a59de02 4347 float normValue_0_1 = analogInPin.read();
whismanoid 11:38b95a59de02 4348 //
whismanoid 11:38b95a59de02 4349 int pinIndexH = pinIndex + 4;
whismanoid 11:38b95a59de02 4350 int cPinIndexH = '0' + pinIndexH;
whismanoid 11:38b95a59de02 4351 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 11:38b95a59de02 4352 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 11:38b95a59de02 4353 float normValueH_0_1 = analogInPinH.read();
whismanoid 11:38b95a59de02 4354 //
whismanoid 11:38b95a59de02 4355 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV \r\n",
whismanoid 11:38b95a59de02 4356 cPinIndex,
whismanoid 11:38b95a59de02 4357 normValue_0_1 * 100.0,
whismanoid 11:38b95a59de02 4358 normValue_0_1 * adc_full_scale_voltage,
whismanoid 11:38b95a59de02 4359 cPinIndexH,
whismanoid 11:38b95a59de02 4360 normValueH_0_1 * 100.0,
whismanoid 11:38b95a59de02 4361 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 11:38b95a59de02 4362 );
whismanoid 11:38b95a59de02 4363 }
whismanoid 11:38b95a59de02 4364 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 11:38b95a59de02 4365 {
whismanoid 11:38b95a59de02 4366 int cPinIndex = '0' + pinIndex;
whismanoid 11:38b95a59de02 4367 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 11:38b95a59de02 4368 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 11:38b95a59de02 4369 float normValue_0_1 = analogInPin.read();
whismanoid 11:38b95a59de02 4370 //
whismanoid 11:38b95a59de02 4371 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 11:38b95a59de02 4372 cPinIndex,
whismanoid 11:38b95a59de02 4373 normValue_0_1 * 100.0,
whismanoid 11:38b95a59de02 4374 normValue_0_1 * adc_full_scale_voltage
whismanoid 11:38b95a59de02 4375 );
whismanoid 11:38b95a59de02 4376 }
whismanoid 11:38b95a59de02 4377 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 11:38b95a59de02 4378 // Platform board uses simple analog inputs
whismanoid 11:38b95a59de02 4379 // assume standard Arduino analog inputs A0-A5
whismanoid 11:38b95a59de02 4380 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 11:38b95a59de02 4381 {
whismanoid 11:38b95a59de02 4382 int cPinIndex = '0' + pinIndex;
whismanoid 11:38b95a59de02 4383 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 11:38b95a59de02 4384 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 11:38b95a59de02 4385 float normValue_0_1 = analogInPin.read();
whismanoid 11:38b95a59de02 4386 //
whismanoid 11:38b95a59de02 4387 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 11:38b95a59de02 4388 cPinIndex,
whismanoid 11:38b95a59de02 4389 normValue_0_1 * 100.0,
whismanoid 11:38b95a59de02 4390 normValue_0_1 * adc_full_scale_voltage
whismanoid 11:38b95a59de02 4391 );
whismanoid 11:38b95a59de02 4392 }
whismanoid 11:38b95a59de02 4393 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 11:38b95a59de02 4394 }
whismanoid 11:38b95a59de02 4395 break;
whismanoid 11:38b95a59de02 4396 #endif
whismanoid 11:38b95a59de02 4397 //
whismanoid 11:38b95a59de02 4398 #if HAS_SPI2_MAX541
whismanoid 11:38b95a59de02 4399 case 'D': case 'd':
whismanoid 11:38b95a59de02 4400 {
whismanoid 11:38b95a59de02 4401 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 11:38b95a59de02 4402 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 11:38b95a59de02 4403 float voltageV = max541.Get_Voltage();
whismanoid 11:38b95a59de02 4404 // if (cmdLine[2] == '+') {
whismanoid 11:38b95a59de02 4405 // // %D+
whismanoid 11:38b95a59de02 4406 // voltageV = voltageV * 1.25f;
whismanoid 11:38b95a59de02 4407 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 11:38b95a59de02 4408 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 11:38b95a59de02 4409 // }
whismanoid 11:38b95a59de02 4410 // else if (cmdLine[2] == '-') {
whismanoid 11:38b95a59de02 4411 // // %D-
whismanoid 11:38b95a59de02 4412 // voltageV = voltageV * 0.75f;
whismanoid 11:38b95a59de02 4413 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 11:38b95a59de02 4414 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 11:38b95a59de02 4415 // }
whismanoid 11:38b95a59de02 4416 if (cmdLine.parse_float("V", voltageV))
whismanoid 11:38b95a59de02 4417 {
whismanoid 11:38b95a59de02 4418 // %D V=1.234 -- set voltage
whismanoid 11:38b95a59de02 4419 max541.Set_Voltage(voltageV);
whismanoid 11:38b95a59de02 4420 }
whismanoid 11:38b95a59de02 4421 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 11:38b95a59de02 4422 {
whismanoid 11:38b95a59de02 4423 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 11:38b95a59de02 4424 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 11:38b95a59de02 4425 }
whismanoid 11:38b95a59de02 4426 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 11:38b95a59de02 4427 {
whismanoid 11:38b95a59de02 4428 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 11:38b95a59de02 4429
whismanoid 11:38b95a59de02 4430 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 11:38b95a59de02 4431 double max541_midscale_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 11:38b95a59de02 4432 const int average_count = 100;
whismanoid 11:38b95a59de02 4433 const double average_K = 0.25;
whismanoid 11:38b95a59de02 4434 for (int count = 0; count < average_count; count++) {
whismanoid 11:38b95a59de02 4435 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 11:38b95a59de02 4436 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 11:38b95a59de02 4437 }
whismanoid 11:38b95a59de02 4438 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 11:38b95a59de02 4439 cmdLine.serial().printf(
whismanoid 11:38b95a59de02 4440 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 11:38b95a59de02 4441 max541_midscale_V, max541.VRef);
whismanoid 11:38b95a59de02 4442 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 11:38b95a59de02 4443 voltageV = 1.0f;
whismanoid 11:38b95a59de02 4444 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 11:38b95a59de02 4445 }
whismanoid 11:38b95a59de02 4446 else {
whismanoid 11:38b95a59de02 4447 // %D -- print MAX541 DAC status
whismanoid 11:38b95a59de02 4448 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 11:38b95a59de02 4449 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 11:38b95a59de02 4450 }
whismanoid 11:38b95a59de02 4451 }
whismanoid 11:38b95a59de02 4452 break;
whismanoid 11:38b95a59de02 4453 #endif
whismanoid 11:38b95a59de02 4454
whismanoid 11:38b95a59de02 4455 //
whismanoid 11:38b95a59de02 4456 #if HAS_I2C // SUPPORT_I2C
whismanoid 11:38b95a59de02 4457 case 'I': case 'i':
whismanoid 0:3edb3708c8c5 4458 // %I... -- I2C diagnostics
whismanoid 0:3edb3708c8c5 4459 // %IP -- I2C probe
whismanoid 0:3edb3708c8c5 4460 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 0:3edb3708c8c5 4461 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 0:3edb3708c8c5 4462 // %IR ADDR=? RD=? -- read
whismanoid 0:3edb3708c8c5 4463 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 11:38b95a59de02 4464 // get next character
whismanoid 11:38b95a59de02 4465 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 11:38b95a59de02 4466 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 11:38b95a59de02 4467 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 11:38b95a59de02 4468 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 11:38b95a59de02 4469 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 11:38b95a59de02 4470 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 11:38b95a59de02 4471 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 11:38b95a59de02 4472 switch (cmdLine[2])
whismanoid 11:38b95a59de02 4473 {
whismanoid 11:38b95a59de02 4474 case 'P': case 'p':
whismanoid 11:38b95a59de02 4475 {
whismanoid 11:38b95a59de02 4476 // %IP -- I2C probe
whismanoid 11:38b95a59de02 4477 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 11:38b95a59de02 4478 }
whismanoid 11:38b95a59de02 4479 break;
whismanoid 11:38b95a59de02 4480 case 'C': case 'c':
whismanoid 11:38b95a59de02 4481 {
whismanoid 11:38b95a59de02 4482 bool isUpdatedI2CConfig = false;
whismanoid 11:38b95a59de02 4483 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 11:38b95a59de02 4484 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 11:38b95a59de02 4485 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 11:38b95a59de02 4486 {
whismanoid 11:38b95a59de02 4487 isUpdatedI2CConfig = true;
whismanoid 11:38b95a59de02 4488 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 11:38b95a59de02 4489 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 11:38b95a59de02 4490 {
whismanoid 11:38b95a59de02 4491 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 11:38b95a59de02 4492 }
whismanoid 11:38b95a59de02 4493 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 11:38b95a59de02 4494 {
whismanoid 11:38b95a59de02 4495 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 11:38b95a59de02 4496 }
whismanoid 11:38b95a59de02 4497 }
whismanoid 11:38b95a59de02 4498 if (isUpdatedI2CConfig)
whismanoid 11:38b95a59de02 4499 {
whismanoid 11:38b95a59de02 4500 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 11:38b95a59de02 4501 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 11:38b95a59de02 4502 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 11:38b95a59de02 4503 i2cMaster.start();
whismanoid 11:38b95a59de02 4504 i2cMaster.stop();
whismanoid 11:38b95a59de02 4505 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 11:38b95a59de02 4506 cmdLine.serial().printf(
whismanoid 11:38b95a59de02 4507 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 11:38b95a59de02 4508 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 11:38b95a59de02 4509 (g_I2C_SCL_Hz / 1000.));
whismanoid 11:38b95a59de02 4510 i2cMaster.start();
whismanoid 11:38b95a59de02 4511 i2cMaster.stop();
whismanoid 11:38b95a59de02 4512 }
whismanoid 11:38b95a59de02 4513 }
whismanoid 11:38b95a59de02 4514 break;
whismanoid 11:38b95a59de02 4515 case 'W': case 'w':
whismanoid 11:38b95a59de02 4516 {
whismanoid 11:38b95a59de02 4517 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 11:38b95a59de02 4518 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 11:38b95a59de02 4519 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 11:38b95a59de02 4520 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 11:38b95a59de02 4521 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 11:38b95a59de02 4522 #define MAX_I2C_BYTE_COUNT 32
whismanoid 11:38b95a59de02 4523 size_t byteCount = byteCount;
whismanoid 11:38b95a59de02 4524 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 11:38b95a59de02 4525 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 11:38b95a59de02 4526 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 11:38b95a59de02 4527 MAX_I2C_BYTE_COUNT))
whismanoid 11:38b95a59de02 4528 {
whismanoid 11:38b95a59de02 4529 // hex dump mosiData[0..byteCount-1]
whismanoid 11:38b95a59de02 4530 cmdLine.serial().printf(
whismanoid 11:38b95a59de02 4531 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 11:38b95a59de02 4532 g_I2C_deviceAddress7,
whismanoid 11:38b95a59de02 4533 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 11:38b95a59de02 4534 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 11:38b95a59de02 4535 {
whismanoid 11:38b95a59de02 4536 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 11:38b95a59de02 4537 }
whismanoid 11:38b95a59de02 4538 //
whismanoid 11:38b95a59de02 4539 // TODO: i2c transfer
whismanoid 11:38b95a59de02 4540 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 11:38b95a59de02 4541 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 11:38b95a59de02 4542 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 11:38b95a59de02 4543 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 11:38b95a59de02 4544 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 11:38b95a59de02 4545 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 11:38b95a59de02 4546 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 11:38b95a59de02 4547 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 11:38b95a59de02 4548 // /* 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 11:38b95a59de02 4549 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 11:38b95a59de02 4550 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 11:38b95a59de02 4551 unsigned int misoLength = 0;
whismanoid 11:38b95a59de02 4552 bool repeated = (g_I2C_read_count > 0);
whismanoid 11:38b95a59de02 4553 //
whismanoid 11:38b95a59de02 4554 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 11:38b95a59de02 4555 switch (writeStatus)
whismanoid 11:38b95a59de02 4556 {
whismanoid 11:38b95a59de02 4557 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 11:38b95a59de02 4558 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 11:38b95a59de02 4559 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 11:38b95a59de02 4560 writeStatus);
whismanoid 11:38b95a59de02 4561 }
whismanoid 11:38b95a59de02 4562 if (repeated)
whismanoid 11:38b95a59de02 4563 {
whismanoid 11:38b95a59de02 4564 int readStatus =
whismanoid 11:38b95a59de02 4565 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 11:38b95a59de02 4566 switch (readStatus)
whismanoid 11:38b95a59de02 4567 {
whismanoid 11:38b95a59de02 4568 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 11:38b95a59de02 4569 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 11:38b95a59de02 4570 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 11:38b95a59de02 4571 readStatus);
whismanoid 11:38b95a59de02 4572 }
whismanoid 11:38b95a59de02 4573 }
whismanoid 11:38b95a59de02 4574 //
whismanoid 11:38b95a59de02 4575 if (misoLength > 0)
whismanoid 11:38b95a59de02 4576 {
whismanoid 11:38b95a59de02 4577 // hex dump misoData[0..byteCount-1]
whismanoid 11:38b95a59de02 4578 cmdLine.serial().printf(" MISO<-");
whismanoid 11:38b95a59de02 4579 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 11:38b95a59de02 4580 byteIndex++)
whismanoid 11:38b95a59de02 4581 {
whismanoid 11:38b95a59de02 4582 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 11:38b95a59de02 4583 }
whismanoid 11:38b95a59de02 4584 }
whismanoid 11:38b95a59de02 4585 cmdLine.serial().printf(" ");
whismanoid 11:38b95a59de02 4586 }
whismanoid 11:38b95a59de02 4587 }
whismanoid 11:38b95a59de02 4588 break;
whismanoid 11:38b95a59de02 4589 case 'R': case 'r':
whismanoid 11:38b95a59de02 4590 {
whismanoid 11:38b95a59de02 4591 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 11:38b95a59de02 4592 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 11:38b95a59de02 4593 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 11:38b95a59de02 4594 // %IR ADDR=? RD=? -- read
whismanoid 11:38b95a59de02 4595 // TODO: i2c transfer
whismanoid 11:38b95a59de02 4596 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 11:38b95a59de02 4597 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 11:38b95a59de02 4598 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 11:38b95a59de02 4599 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 11:38b95a59de02 4600 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 11:38b95a59de02 4601 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 11:38b95a59de02 4602 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 11:38b95a59de02 4603 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 11:38b95a59de02 4604 // /* 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 11:38b95a59de02 4605 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 11:38b95a59de02 4606 }
whismanoid 11:38b95a59de02 4607 break;
whismanoid 11:38b95a59de02 4608 case '^':
whismanoid 11:38b95a59de02 4609 {
whismanoid 11:38b95a59de02 4610 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 11:38b95a59de02 4611 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 11:38b95a59de02 4612 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 11:38b95a59de02 4613 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 11:38b95a59de02 4614 // TODO: i2c transfer
whismanoid 11:38b95a59de02 4615 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 11:38b95a59de02 4616 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 11:38b95a59de02 4617 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 11:38b95a59de02 4618 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 11:38b95a59de02 4619 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 11:38b95a59de02 4620 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 11:38b95a59de02 4621 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 11:38b95a59de02 4622 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 11:38b95a59de02 4623 // /* 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 11:38b95a59de02 4624 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 11:38b95a59de02 4625 }
whismanoid 11:38b95a59de02 4626 break;
whismanoid 11:38b95a59de02 4627 } // switch(cmdLine[2])
whismanoid 11:38b95a59de02 4628 break;
whismanoid 11:38b95a59de02 4629 #endif
whismanoid 11:38b95a59de02 4630 //
whismanoid 11:38b95a59de02 4631 #if HAS_SPI // SUPPORT_SPI
whismanoid 11:38b95a59de02 4632 case 'S': case 's':
whismanoid 11:38b95a59de02 4633 {
whismanoid 0:3edb3708c8c5 4634 // %S... -- SPI diagnostics
whismanoid 0:3edb3708c8c5 4635 // %SC sclk=1Mhz -- SPI configure
whismanoid 0:3edb3708c8c5 4636 // %SW -- write (write and read)
whismanoid 0:3edb3708c8c5 4637 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 0:3edb3708c8c5 4638 //
whismanoid 11:38b95a59de02 4639 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 11:38b95a59de02 4640 bool isUpdatedSPIConfig = false;
whismanoid 11:38b95a59de02 4641 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 11:38b95a59de02 4642 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 11:38b95a59de02 4643 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 11:38b95a59de02 4644 {
whismanoid 11:38b95a59de02 4645 isUpdatedSPIConfig = true;
whismanoid 11:38b95a59de02 4646 }
whismanoid 11:38b95a59de02 4647 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 0:3edb3708c8c5 4648 {
whismanoid 11:38b95a59de02 4649 isUpdatedSPIConfig = true;
whismanoid 11:38b95a59de02 4650 }
whismanoid 11:38b95a59de02 4651 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 11:38b95a59de02 4652 {
whismanoid 11:38b95a59de02 4653 isUpdatedSPIConfig = true;
whismanoid 11:38b95a59de02 4654 }
whismanoid 11:38b95a59de02 4655 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 11:38b95a59de02 4656 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 11:38b95a59de02 4657 {
whismanoid 11:38b95a59de02 4658 isUpdatedSPIConfig = true;
whismanoid 11:38b95a59de02 4659 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 11:38b95a59de02 4660 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 0:3edb3708c8c5 4661 {
whismanoid 11:38b95a59de02 4662 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 0:3edb3708c8c5 4663 }
whismanoid 11:38b95a59de02 4664 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 0:3edb3708c8c5 4665 {
whismanoid 11:38b95a59de02 4666 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 11:38b95a59de02 4667 }
whismanoid 11:38b95a59de02 4668 }
whismanoid 11:38b95a59de02 4669 // Update SPI configuration
whismanoid 11:38b95a59de02 4670 if (isUpdatedSPIConfig)
whismanoid 11:38b95a59de02 4671 {
whismanoid 11:38b95a59de02 4672 // %SC sclk=1Mhz -- SPI configure
whismanoid 11:38b95a59de02 4673 spi_cs = g_SPI_cs_state;
whismanoid 11:38b95a59de02 4674 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 11:38b95a59de02 4675 #if APPLICATION_MAX5715
whismanoid 11:38b95a59de02 4676 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 11:38b95a59de02 4677 #elif APPLICATION_MAX11131
whismanoid 11:38b95a59de02 4678 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 11:38b95a59de02 4679 #elif APPLICATION_MAX5171
whismanoid 11:38b95a59de02 4680 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 11:38b95a59de02 4681 #elif APPLICATION_MAX11410
whismanoid 11:38b95a59de02 4682 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 11:38b95a59de02 4683 #elif APPLICATION_MAX12345
whismanoid 11:38b95a59de02 4684 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 0:3edb3708c8c5 4685 #else
whismanoid 11:38b95a59de02 4686 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 0:3edb3708c8c5 4687 #endif
whismanoid 0:3edb3708c8c5 4688 //
whismanoid 11:38b95a59de02 4689 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 11:38b95a59de02 4690 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 11:38b95a59de02 4691 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 11:38b95a59de02 4692 //
whismanoid 11:38b95a59de02 4693 // 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 11:38b95a59de02 4694 cmdLine.serial().printf(
whismanoid 11:38b95a59de02 4695 "\r\n %%SC CPOL=%d CPHA=%d CS=%d SCLK=%ld=%1.3fMHz (%1.1fMHz/%1.2f = actual %1.3fMHz) -- SPI config",
whismanoid 11:38b95a59de02 4696 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 11:38b95a59de02 4697 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 11:38b95a59de02 4698 g_SPI_cs_state,
whismanoid 11:38b95a59de02 4699 g_SPI_SCLK_Hz,
whismanoid 11:38b95a59de02 4700 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 11:38b95a59de02 4701 ((double)(SystemCoreClock / 1000000.)),
whismanoid 11:38b95a59de02 4702 ideal_divisor,
whismanoid 11:38b95a59de02 4703 (actual_SCLK_Hz / 1000000.)
whismanoid 11:38b95a59de02 4704 );
whismanoid 11:38b95a59de02 4705 }
whismanoid 11:38b95a59de02 4706 // get next character
whismanoid 11:38b95a59de02 4707 switch (cmdLine[2])
whismanoid 11:38b95a59de02 4708 {
whismanoid 11:38b95a59de02 4709 case 'C': case 's':
whismanoid 11:38b95a59de02 4710 // %SC sclk=1Mhz -- SPI configure
whismanoid 11:38b95a59de02 4711 break;
whismanoid 11:38b95a59de02 4712 case 'W': case 'R': case 'w': case 'r':
whismanoid 0:3edb3708c8c5 4713 {
whismanoid 11:38b95a59de02 4714 // %SW -- write (write and read)
whismanoid 11:38b95a59de02 4715 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 11:38b95a59de02 4716 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 11:38b95a59de02 4717 #define MAX_SPI_BYTE_COUNT 32
whismanoid 11:38b95a59de02 4718 size_t byteCount = byteCount;
whismanoid 11:38b95a59de02 4719 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 11:38b95a59de02 4720 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 11:38b95a59de02 4721 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 11:38b95a59de02 4722 MAX_SPI_BYTE_COUNT))
whismanoid 0:3edb3708c8c5 4723 {
whismanoid 11:38b95a59de02 4724 // hex dump mosiData[0..byteCount-1]
whismanoid 11:38b95a59de02 4725 cmdLine.serial().printf("\r\nSPI");
whismanoid 11:38b95a59de02 4726 if (byteCount > 7) {
whismanoid 11:38b95a59de02 4727 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 11:38b95a59de02 4728 }
whismanoid 11:38b95a59de02 4729 cmdLine.serial().printf(" MOSI->");
whismanoid 11:38b95a59de02 4730 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 11:38b95a59de02 4731 {
whismanoid 11:38b95a59de02 4732 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 0:3edb3708c8c5 4733 }
whismanoid 11:38b95a59de02 4734 spi_cs = 0;
whismanoid 11:38b95a59de02 4735 unsigned int numBytesTransferred =
whismanoid 11:38b95a59de02 4736 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 11:38b95a59de02 4737 spi_cs = 1;
whismanoid 11:38b95a59de02 4738 // hex dump misoData[0..byteCount-1]
whismanoid 11:38b95a59de02 4739 cmdLine.serial().printf(" MISO<-");
whismanoid 11:38b95a59de02 4740 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 11:38b95a59de02 4741 byteIndex++)
whismanoid 11:38b95a59de02 4742 {
whismanoid 11:38b95a59de02 4743 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 11:38b95a59de02 4744 }
whismanoid 11:38b95a59de02 4745 cmdLine.serial().printf(" ");
whismanoid 0:3edb3708c8c5 4746 }
whismanoid 0:3edb3708c8c5 4747 }
whismanoid 0:3edb3708c8c5 4748 break;
whismanoid 11:38b95a59de02 4749 } // switch(cmdLine[2])
whismanoid 11:38b95a59de02 4750 } // case 'S': // %S... -- SPI diagnostics
whismanoid 11:38b95a59de02 4751 break;
whismanoid 11:38b95a59de02 4752 #endif
whismanoid 11:38b95a59de02 4753 //
whismanoid 11:38b95a59de02 4754 // A-Z,a-z,0-9 reserved for application use
whismanoid 11:38b95a59de02 4755 } // switch(cmdLine[1])
whismanoid 11:38b95a59de02 4756 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 4757
whismanoid 0:3edb3708c8c5 4758
whismanoid 11:38b95a59de02 4759 //--------------------------------------------------
whismanoid 11:38b95a59de02 4760 #if 0 // APPLICATION_MAX5715 // MAX5715_menu_onEOLcommandParser moved to Test_Menu_MAX5715.cpp
whismanoid 11:38b95a59de02 4761 bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 4762 {
whismanoid 11:38b95a59de02 4763 switch (cmdLine[0])
whismanoid 11:38b95a59de02 4764 {
whismanoid 0:3edb3708c8c5 4765 case '0':
whismanoid 0:3edb3708c8c5 4766 {
whismanoid 0:3edb3708c8c5 4767 // recommended for hex command codes 00..0F
whismanoid 0:3edb3708c8c5 4768 // TODO: cmdLine.serial().printf("\r\n 0 ch=? code=? -- CODEn");
whismanoid 0:3edb3708c8c5 4769 // Menu 0 ch=? code=?) CODEn
whismanoid 0:3edb3708c8c5 4770 // MAX5715_CODEn(uint8_t channel, uint16_t dacCodeLsbs);
whismanoid 0:3edb3708c8c5 4771 // VERIFY: parse strCommandArgs for additional arguments including key=value pairs
whismanoid 0:3edb3708c8c5 4772 // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 4773 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 4774 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 4775 {
whismanoid 0:3edb3708c8c5 4776 }
whismanoid 0:3edb3708c8c5 4777 uint16_t code = g_MAX5715_device.CODE[ch];
whismanoid 0:3edb3708c8c5 4778 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 4779 {
whismanoid 0:3edb3708c8c5 4780 }
whismanoid 0:3edb3708c8c5 4781 cmdLine.serial().printf("CODEn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 4782 g_MAX5715_device.CODEn(ch, code);
whismanoid 11:38b95a59de02 4783 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4784 }
whismanoid 0:3edb3708c8c5 4785 break;
whismanoid 0:3edb3708c8c5 4786 case '1':
whismanoid 0:3edb3708c8c5 4787 {
whismanoid 0:3edb3708c8c5 4788 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 4789 // TODO: cmdLine.serial().printf("\r\n 1 ch=? -- LOADn");
whismanoid 0:3edb3708c8c5 4790 // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 4791 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 4792 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 4793 {
whismanoid 0:3edb3708c8c5 4794 }
whismanoid 0:3edb3708c8c5 4795 cmdLine.serial().printf("LOADn ch=%d", ch);
whismanoid 0:3edb3708c8c5 4796 g_MAX5715_device.LOADn(ch);
whismanoid 11:38b95a59de02 4797 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4798 }
whismanoid 0:3edb3708c8c5 4799 break;
whismanoid 0:3edb3708c8c5 4800 case '2':
whismanoid 0:3edb3708c8c5 4801 {
whismanoid 0:3edb3708c8c5 4802 // recommended for hex command codes 20..2F
whismanoid 0:3edb3708c8c5 4803 // TODO: cmdLine.serial().printf("\r\n 2 ch=? code=? -- CODEnLOADall");
whismanoid 0:3edb3708c8c5 4804 // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 4805 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 4806 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 4807 {
whismanoid 0:3edb3708c8c5 4808 }
whismanoid 0:3edb3708c8c5 4809 uint16_t code = g_MAX5715_device.CODE[ch];
whismanoid 0:3edb3708c8c5 4810 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 4811 {
whismanoid 0:3edb3708c8c5 4812 }
whismanoid 0:3edb3708c8c5 4813 cmdLine.serial().printf("CODEnLOADall ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 4814 g_MAX5715_device.CODEnLOADall(ch, code);
whismanoid 11:38b95a59de02 4815 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4816 }
whismanoid 0:3edb3708c8c5 4817 break;
whismanoid 0:3edb3708c8c5 4818 case '3':
whismanoid 0:3edb3708c8c5 4819 {
whismanoid 0:3edb3708c8c5 4820 // recommended for hex command codes 30..3F
whismanoid 0:3edb3708c8c5 4821 // TODO: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn");
whismanoid 0:3edb3708c8c5 4822 // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 4823 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 4824 uint16_t code;
whismanoid 0:3edb3708c8c5 4825 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 4826 {
whismanoid 0:3edb3708c8c5 4827 }
whismanoid 0:3edb3708c8c5 4828 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 4829 {
whismanoid 0:3edb3708c8c5 4830 }
whismanoid 0:3edb3708c8c5 4831 cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 4832 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 11:38b95a59de02 4833 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4834 }
whismanoid 0:3edb3708c8c5 4835 break;
whismanoid 0:3edb3708c8c5 4836 case '4':
whismanoid 0:3edb3708c8c5 4837 {
whismanoid 0:3edb3708c8c5 4838 // recommended for hex command codes 40..4F
whismanoid 0:3edb3708c8c5 4839 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4840 {
whismanoid 0:3edb3708c8c5 4841 case '0':
whismanoid 0:3edb3708c8c5 4842 {
whismanoid 0:3edb3708c8c5 4843 // cmdLine.serial().printf("\r\n 40 ch=? -- POWERn_Normal");
whismanoid 0:3edb3708c8c5 4844 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4845 "channel_dcba=%d, POWERn_Normal)",
whismanoid 0:3edb3708c8c5 4846 g_MAX5715_device.channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4847 g_MAX5715_device.POWER(g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4848 channels_bitmask_DCBA,
whismanoid 0:3edb3708c8c5 4849 MAX5715::POWERn_Normal);
whismanoid 11:38b95a59de02 4850 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4851 }
whismanoid 0:3edb3708c8c5 4852 break;
whismanoid 0:3edb3708c8c5 4853 case '1':
whismanoid 0:3edb3708c8c5 4854 {
whismanoid 0:3edb3708c8c5 4855 // cmdLine.serial().printf("\r\n 41 ch=? -- POWERn_PD1k");
whismanoid 0:3edb3708c8c5 4856 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4857 "channel_dcba=%d, POWERn_PD1k)",
whismanoid 0:3edb3708c8c5 4858 g_MAX5715_device.channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4859 g_MAX5715_device.POWER(g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4860 channels_bitmask_DCBA,
whismanoid 0:3edb3708c8c5 4861 MAX5715::POWERn_PD1k);
whismanoid 11:38b95a59de02 4862 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4863 }
whismanoid 0:3edb3708c8c5 4864 break;
whismanoid 0:3edb3708c8c5 4865 case '2':
whismanoid 0:3edb3708c8c5 4866 {
whismanoid 0:3edb3708c8c5 4867 // cmdLine.serial().printf("\r\n 42 ch=? -- POWERn_PD100k");
whismanoid 0:3edb3708c8c5 4868 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4869 "channel_dcba=%d, POWERn_PD100k)",
whismanoid 0:3edb3708c8c5 4870 g_MAX5715_device.channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4871 g_MAX5715_device.POWER(g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4872 channels_bitmask_DCBA,
whismanoid 0:3edb3708c8c5 4873 MAX5715::POWERn_PD100k);
whismanoid 11:38b95a59de02 4874 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4875 }
whismanoid 0:3edb3708c8c5 4876 break;
whismanoid 0:3edb3708c8c5 4877 case '3':
whismanoid 0:3edb3708c8c5 4878 {
whismanoid 0:3edb3708c8c5 4879 // cmdLine.serial().printf("\r\n 43 ch=? -- POWERn_PDHiZ");
whismanoid 0:3edb3708c8c5 4880 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4881 "channel_dcba=%d, POWERn_PDHiZ)",
whismanoid 0:3edb3708c8c5 4882 g_MAX5715_device.channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4883 g_MAX5715_device.POWER(g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4884 channels_bitmask_DCBA,
whismanoid 0:3edb3708c8c5 4885 MAX5715::POWERn_PDHiZ);
whismanoid 11:38b95a59de02 4886 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4887 }
whismanoid 0:3edb3708c8c5 4888 break;
whismanoid 0:3edb3708c8c5 4889 }
whismanoid 0:3edb3708c8c5 4890 break;
whismanoid 0:3edb3708c8c5 4891 }
whismanoid 0:3edb3708c8c5 4892 break;
whismanoid 0:3edb3708c8c5 4893 case '5':
whismanoid 0:3edb3708c8c5 4894 {
whismanoid 0:3edb3708c8c5 4895 // recommended for hex command codes 50..5F
whismanoid 0:3edb3708c8c5 4896 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4897 {
whismanoid 0:3edb3708c8c5 4898 case '0':
whismanoid 0:3edb3708c8c5 4899 {
whismanoid 0:3edb3708c8c5 4900 // cmdLine.serial().printf("\r\n 50 -- SW_CLEAR");
whismanoid 0:3edb3708c8c5 4901 cmdLine.serial().printf("SW_CLEAR");
whismanoid 0:3edb3708c8c5 4902 g_MAX5715_device.SW_CLEAR();
whismanoid 11:38b95a59de02 4903 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4904 }
whismanoid 0:3edb3708c8c5 4905 break;
whismanoid 0:3edb3708c8c5 4906 case '1':
whismanoid 0:3edb3708c8c5 4907 {
whismanoid 0:3edb3708c8c5 4908 // cmdLine.serial().printf("\r\n 51 -- SW_RESET");
whismanoid 0:3edb3708c8c5 4909 cmdLine.serial().printf("SW_RESET");
whismanoid 0:3edb3708c8c5 4910 g_MAX5715_device.SW_RESET();
whismanoid 11:38b95a59de02 4911 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4912 }
whismanoid 0:3edb3708c8c5 4913 break;
whismanoid 0:3edb3708c8c5 4914 }
whismanoid 0:3edb3708c8c5 4915 }
whismanoid 0:3edb3708c8c5 4916 break;
whismanoid 0:3edb3708c8c5 4917 case '6':
whismanoid 0:3edb3708c8c5 4918 {
whismanoid 0:3edb3708c8c5 4919 // recommended for hex command codes 60..6F
whismanoid 0:3edb3708c8c5 4920 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4921 {
whismanoid 0:3edb3708c8c5 4922 case '0':
whismanoid 0:3edb3708c8c5 4923 {
whismanoid 0:3edb3708c8c5 4924 // cmdLine.serial().printf("\r\n 60 ch=? -- CONFIGn_LATCHED");
whismanoid 0:3edb3708c8c5 4925 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4926 "MAX5715_CONFIGn_LATCHED(channel_dcba=%d)",
whismanoid 0:3edb3708c8c5 4927 g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4928 channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4929 g_MAX5715_device.CONFIGn_LATCHED(g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4930 channels_bitmask_DCBA);
whismanoid 11:38b95a59de02 4931 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4932 }
whismanoid 0:3edb3708c8c5 4933 break;
whismanoid 0:3edb3708c8c5 4934 case '1':
whismanoid 0:3edb3708c8c5 4935 {
whismanoid 0:3edb3708c8c5 4936 // cmdLine.serial().printf("\r\n 61 ch=? -- CONFIGn_TRANSPARENT");
whismanoid 0:3edb3708c8c5 4937 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4938 "MAX5715_CONFIGn_TRANSPARENT(channel_dcba=%d)",
whismanoid 0:3edb3708c8c5 4939 g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4940 channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4941 g_MAX5715_device.CONFIGn_TRANSPARENT(
whismanoid 0:3edb3708c8c5 4942 g_MAX5715_device.channels_bitmask_DCBA);
whismanoid 11:38b95a59de02 4943 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4944 }
whismanoid 0:3edb3708c8c5 4945 break;
whismanoid 0:3edb3708c8c5 4946 case '8':
whismanoid 0:3edb3708c8c5 4947 {
whismanoid 0:3edb3708c8c5 4948 // cmdLine.serial().printf("\r\n 68 -- CONFIGall_LATCHED");
whismanoid 0:3edb3708c8c5 4949 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4950 "MAX5715_CONFIGall_LATCHED()");
whismanoid 0:3edb3708c8c5 4951 g_MAX5715_device.CONFIGall_LATCHED();
whismanoid 11:38b95a59de02 4952 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4953 }
whismanoid 0:3edb3708c8c5 4954 break;
whismanoid 0:3edb3708c8c5 4955 case '9':
whismanoid 0:3edb3708c8c5 4956 {
whismanoid 0:3edb3708c8c5 4957 // cmdLine.serial().printf("\r\n 69 -- CONFIGall_TRANSPARENT");
whismanoid 0:3edb3708c8c5 4958 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4959 "MAX5715_CONFIGall_TRANSPARENT()");
whismanoid 0:3edb3708c8c5 4960 g_MAX5715_device.CONFIGall_TRANSPARENT();
whismanoid 11:38b95a59de02 4961 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4962 }
whismanoid 0:3edb3708c8c5 4963 break;
whismanoid 0:3edb3708c8c5 4964 }
whismanoid 0:3edb3708c8c5 4965 }
whismanoid 0:3edb3708c8c5 4966 break;
whismanoid 0:3edb3708c8c5 4967 case '7':
whismanoid 0:3edb3708c8c5 4968 {
whismanoid 0:3edb3708c8c5 4969 // recommended for hex command codes 70..7F
whismanoid 0:3edb3708c8c5 4970 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4971 {
whismanoid 0:3edb3708c8c5 4972 case '0':
whismanoid 0:3edb3708c8c5 4973 {
whismanoid 0:3edb3708c8c5 4974 // cmdLine.serial().printf("\r\n 70 -- REF_EXT");
whismanoid 0:3edb3708c8c5 4975 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4976 "MAX5715_REF(REF_EXT)");
whismanoid 0:3edb3708c8c5 4977 g_MAX5715_device.REF(MAX5715::REF_EXT);
whismanoid 11:38b95a59de02 4978 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4979 }
whismanoid 0:3edb3708c8c5 4980 break;
whismanoid 0:3edb3708c8c5 4981 case '1':
whismanoid 0:3edb3708c8c5 4982 {
whismanoid 0:3edb3708c8c5 4983 // cmdLine.serial().printf("\r\n 71 -- REF_2V500");
whismanoid 0:3edb3708c8c5 4984 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4985 "MAX5715_REF(REF_2V500)");
whismanoid 0:3edb3708c8c5 4986 g_MAX5715_device.REF(MAX5715::REF_2V500);
whismanoid 11:38b95a59de02 4987 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4988 }
whismanoid 0:3edb3708c8c5 4989 break;
whismanoid 0:3edb3708c8c5 4990 case '2':
whismanoid 0:3edb3708c8c5 4991 {
whismanoid 0:3edb3708c8c5 4992 // cmdLine.serial().printf("\r\n 72 -- REF_2V048");
whismanoid 0:3edb3708c8c5 4993 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4994 "MAX5715_REF(REF_2V048)");
whismanoid 0:3edb3708c8c5 4995 g_MAX5715_device.REF(MAX5715::REF_2V048);
whismanoid 11:38b95a59de02 4996 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4997 }
whismanoid 0:3edb3708c8c5 4998 break;
whismanoid 0:3edb3708c8c5 4999 case '3':
whismanoid 0:3edb3708c8c5 5000 {
whismanoid 0:3edb3708c8c5 5001 // cmdLine.serial().printf("\r\n 73 -- REF_4V096");
whismanoid 0:3edb3708c8c5 5002 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 5003 "MAX5715_REF(REF_4V096)");
whismanoid 0:3edb3708c8c5 5004 g_MAX5715_device.REF(MAX5715::REF_4V096);
whismanoid 11:38b95a59de02 5005 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5006 }
whismanoid 0:3edb3708c8c5 5007 break;
whismanoid 0:3edb3708c8c5 5008 case '4':
whismanoid 0:3edb3708c8c5 5009 {
whismanoid 0:3edb3708c8c5 5010 // cmdLine.serial().printf("\r\n 74 -- REF_AlwaysOn_EXT");
whismanoid 0:3edb3708c8c5 5011 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 5012 "MAX5715_REF(REF_AlwaysOn_EXT)");
whismanoid 0:3edb3708c8c5 5013 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_EXT);
whismanoid 11:38b95a59de02 5014 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5015 }
whismanoid 0:3edb3708c8c5 5016 break;
whismanoid 0:3edb3708c8c5 5017 case '5':
whismanoid 0:3edb3708c8c5 5018 {
whismanoid 0:3edb3708c8c5 5019 // cmdLine.serial().printf("\r\n 75 -- REF_AlwaysOn_2V500");
whismanoid 0:3edb3708c8c5 5020 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 5021 "MAX5715_REF(REF_AlwaysOn_2V500)");
whismanoid 0:3edb3708c8c5 5022 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500);
whismanoid 11:38b95a59de02 5023 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5024 }
whismanoid 0:3edb3708c8c5 5025 break;
whismanoid 0:3edb3708c8c5 5026 case '6':
whismanoid 0:3edb3708c8c5 5027 {
whismanoid 0:3edb3708c8c5 5028 // cmdLine.serial().printf("\r\n 76 -- REF_AlwaysOn_2V048");
whismanoid 0:3edb3708c8c5 5029 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 5030 "MAX5715_REF(REF_AlwaysOn_2V048)");
whismanoid 0:3edb3708c8c5 5031 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048);
whismanoid 11:38b95a59de02 5032 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5033 }
whismanoid 0:3edb3708c8c5 5034 break;
whismanoid 0:3edb3708c8c5 5035 case '7':
whismanoid 0:3edb3708c8c5 5036 {
whismanoid 0:3edb3708c8c5 5037 // cmdLine.serial().printf("\r\n 77 -- REF_AlwaysOn_4V096");
whismanoid 0:3edb3708c8c5 5038 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 5039 "MAX5715_REF(REF_AlwaysOn_4V096)");
whismanoid 0:3edb3708c8c5 5040 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_4V096);
whismanoid 11:38b95a59de02 5041 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5042 }
whismanoid 0:3edb3708c8c5 5043 break;
whismanoid 0:3edb3708c8c5 5044 }
whismanoid 0:3edb3708c8c5 5045 }
whismanoid 0:3edb3708c8c5 5046 break;
whismanoid 0:3edb3708c8c5 5047 case '8':
whismanoid 0:3edb3708c8c5 5048 {
whismanoid 0:3edb3708c8c5 5049 // recommended for hex command codes 80..8F
whismanoid 0:3edb3708c8c5 5050 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5051 {
whismanoid 0:3edb3708c8c5 5052 case '0':
whismanoid 0:3edb3708c8c5 5053 {
whismanoid 0:3edb3708c8c5 5054 // TODO: cmdLine.serial().printf("\r\n 80 code=? -- CODEall");
whismanoid 0:3edb3708c8c5 5055 // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 5056 g_MAX5715_device.channels_bitmask_DCBA = 0xFF; // store g_MAX5715_device.CODE[allChannels]
whismanoid 0:3edb3708c8c5 5057 uint16_t code = g_MAX5715_device.CODE[0];
whismanoid 0:3edb3708c8c5 5058 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 5059 {
whismanoid 0:3edb3708c8c5 5060 }
whismanoid 0:3edb3708c8c5 5061 cmdLine.serial().printf("CODEall code=%d", code);
whismanoid 0:3edb3708c8c5 5062 g_MAX5715_device.CODEall(code);
whismanoid 11:38b95a59de02 5063 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5064 }
whismanoid 0:3edb3708c8c5 5065 break;
whismanoid 0:3edb3708c8c5 5066 case '1':
whismanoid 0:3edb3708c8c5 5067 {
whismanoid 0:3edb3708c8c5 5068 // TODO: cmdLine.serial().printf("\r\n 81 -- LOADall");
whismanoid 0:3edb3708c8c5 5069 cmdLine.serial().printf("LOADall");
whismanoid 0:3edb3708c8c5 5070 g_MAX5715_device.LOADall();
whismanoid 11:38b95a59de02 5071 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5072 }
whismanoid 0:3edb3708c8c5 5073 break;
whismanoid 0:3edb3708c8c5 5074 case '2':
whismanoid 0:3edb3708c8c5 5075 {
whismanoid 0:3edb3708c8c5 5076 // TODO: cmdLine.serial().printf("\r\n 82 code=? -- CODEallLOADall");
whismanoid 0:3edb3708c8c5 5077 uint16_t code = g_MAX5715_device.CODE[0];
whismanoid 0:3edb3708c8c5 5078 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 5079 {
whismanoid 0:3edb3708c8c5 5080 }
whismanoid 0:3edb3708c8c5 5081 cmdLine.serial().printf("CODEallLOADall code=%d", code);
whismanoid 0:3edb3708c8c5 5082 g_MAX5715_device.CODEallLOADall(code);
whismanoid 11:38b95a59de02 5083 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5084 }
whismanoid 0:3edb3708c8c5 5085 break;
whismanoid 0:3edb3708c8c5 5086 }
whismanoid 0:3edb3708c8c5 5087 }
whismanoid 0:3edb3708c8c5 5088 break;
whismanoid 0:3edb3708c8c5 5089 case '9':
whismanoid 0:3edb3708c8c5 5090 {
whismanoid 0:3edb3708c8c5 5091 // recommended for hex command codes 90..9F
whismanoid 0:3edb3708c8c5 5092 }
whismanoid 0:3edb3708c8c5 5093 break;
whismanoid 0:3edb3708c8c5 5094 case 'a': case 'A':
whismanoid 0:3edb3708c8c5 5095 {
whismanoid 0:3edb3708c8c5 5096 // recommended for hex command codes A0..AF
whismanoid 0:3edb3708c8c5 5097 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5098 {
whismanoid 0:3edb3708c8c5 5099 case 't': case 'T':
whismanoid 0:3edb3708c8c5 5100 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5101 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5102 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5103 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5104 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 11:38b95a59de02 5105 return false; // command not handled
whismanoid 0:3edb3708c8c5 5106 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5107 }
whismanoid 0:3edb3708c8c5 5108 }
whismanoid 0:3edb3708c8c5 5109 break;
whismanoid 0:3edb3708c8c5 5110 case 'b': case 'B':
whismanoid 0:3edb3708c8c5 5111 {
whismanoid 0:3edb3708c8c5 5112 // recommended for hex command codes B0..BF
whismanoid 0:3edb3708c8c5 5113 }
whismanoid 0:3edb3708c8c5 5114 break;
whismanoid 0:3edb3708c8c5 5115 case 'c': case 'C':
whismanoid 0:3edb3708c8c5 5116 {
whismanoid 0:3edb3708c8c5 5117 // recommended for hex command codes C0..CF
whismanoid 0:3edb3708c8c5 5118 // // MAX5717 menu function to drive MAX5717_CLRb_Pin CLR#
whismanoid 0:3edb3708c8c5 5119 // cmdLine.serial().printf("\r\n C -- CLR# pulse CH high CL low");
whismanoid 0:3edb3708c8c5 5120 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5121 {
whismanoid 0:3edb3708c8c5 5122 default:
whismanoid 0:3edb3708c8c5 5123 // g_MAX5715_device.CLRboutputPulseLow();
whismanoid 0:3edb3708c8c5 5124 g_MAX5715_device.CLRboutputValue(1);
whismanoid 0:3edb3708c8c5 5125 g_MAX5715_device.CLRboutputValue(0);
whismanoid 0:3edb3708c8c5 5126 g_MAX5715_device.CLRboutputValue(1);
whismanoid 0:3edb3708c8c5 5127 break;
whismanoid 0:3edb3708c8c5 5128 case 'H': case 'h': case '1':
whismanoid 0:3edb3708c8c5 5129 g_MAX5715_device.CLRboutputValue(1); // GPIOoutputCLRb(int isLogicHigh);
whismanoid 0:3edb3708c8c5 5130 break;
whismanoid 0:3edb3708c8c5 5131 case 'L': case 'l': case '0':
whismanoid 0:3edb3708c8c5 5132 g_MAX5715_device.CLRboutputValue(0); // GPIOoutputCLRb(int isLogicHigh);
whismanoid 0:3edb3708c8c5 5133 break;
whismanoid 0:3edb3708c8c5 5134 }
whismanoid 11:38b95a59de02 5135 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5136 }
whismanoid 0:3edb3708c8c5 5137 break;
whismanoid 0:3edb3708c8c5 5138 case 'd': case 'D':
whismanoid 0:3edb3708c8c5 5139 {
whismanoid 0:3edb3708c8c5 5140 // recommended for hex command codes D0..DF
whismanoid 0:3edb3708c8c5 5141 }
whismanoid 0:3edb3708c8c5 5142 break;
whismanoid 0:3edb3708c8c5 5143 case 'e': case 'E':
whismanoid 0:3edb3708c8c5 5144 {
whismanoid 0:3edb3708c8c5 5145 // recommended for hex command codes E0..EF
whismanoid 0:3edb3708c8c5 5146 }
whismanoid 0:3edb3708c8c5 5147 break;
whismanoid 0:3edb3708c8c5 5148 case 'f': case 'F':
whismanoid 0:3edb3708c8c5 5149 {
whismanoid 0:3edb3708c8c5 5150 // recommended for hex command codes F0..FF
whismanoid 0:3edb3708c8c5 5151 }
whismanoid 0:3edb3708c8c5 5152 break;
whismanoid 0:3edb3708c8c5 5153 case 'l': case 'L':
whismanoid 0:3edb3708c8c5 5154 {
whismanoid 0:3edb3708c8c5 5155 // // MAX5717 menu function to drive MAX5717_LDACb_Pin LDAC#
whismanoid 0:3edb3708c8c5 5156 // cmdLine.serial().printf("\r\n L -- LDAC# pulse LH high LL low");
whismanoid 0:3edb3708c8c5 5157 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5158 {
whismanoid 0:3edb3708c8c5 5159 default:
whismanoid 0:3edb3708c8c5 5160 // g_MAX5715_device.LDACboutputPulseLow();
whismanoid 0:3edb3708c8c5 5161 g_MAX5715_device.LDACboutputValue(1);
whismanoid 0:3edb3708c8c5 5162 g_MAX5715_device.LDACboutputValue(0);
whismanoid 0:3edb3708c8c5 5163 g_MAX5715_device.LDACboutputValue(1);
whismanoid 0:3edb3708c8c5 5164 break;
whismanoid 0:3edb3708c8c5 5165 case 'H': case 'h': case '1':
whismanoid 0:3edb3708c8c5 5166 g_MAX5715_device.LDACboutputValue(1); // GPIOoutputLDACb(int isLogicHigh);
whismanoid 0:3edb3708c8c5 5167 break;
whismanoid 0:3edb3708c8c5 5168 case 'L': case 'l': case '0':
whismanoid 0:3edb3708c8c5 5169 g_MAX5715_device.LDACboutputValue(0); // GPIOoutputLDACb(int isLogicHigh);
whismanoid 0:3edb3708c8c5 5170 break;
whismanoid 0:3edb3708c8c5 5171 }
whismanoid 11:38b95a59de02 5172 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5173 }
whismanoid 0:3edb3708c8c5 5174 break;
whismanoid 0:3edb3708c8c5 5175 case 'x': case 'X':
whismanoid 0:3edb3708c8c5 5176 {
whismanoid 0:3edb3708c8c5 5177 }
whismanoid 0:3edb3708c8c5 5178 break;
whismanoid 0:3edb3708c8c5 5179 case 'y': case 'Y':
whismanoid 0:3edb3708c8c5 5180 {
whismanoid 0:3edb3708c8c5 5181 }
whismanoid 0:3edb3708c8c5 5182 break;
whismanoid 0:3edb3708c8c5 5183 case 'z': case 'Z':
whismanoid 0:3edb3708c8c5 5184 {
whismanoid 0:3edb3708c8c5 5185 }
whismanoid 0:3edb3708c8c5 5186 break;
whismanoid 0:3edb3708c8c5 5187 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 0:3edb3708c8c5 5188 {
whismanoid 0:3edb3708c8c5 5189 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 5190 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5191 {
whismanoid 0:3edb3708c8c5 5192 default:
whismanoid 0:3edb3708c8c5 5193 {
whismanoid 0:3edb3708c8c5 5194 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5195 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5196 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n",
whismanoid 0:3edb3708c8c5 5197 cmdLine.str());
whismanoid 0:3edb3708c8c5 5198 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5199 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5200 }
whismanoid 0:3edb3708c8c5 5201 }
whismanoid 0:3edb3708c8c5 5202 }
whismanoid 0:3edb3708c8c5 5203 break;
whismanoid 0:3edb3708c8c5 5204 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 0:3edb3708c8c5 5205 {
whismanoid 0:3edb3708c8c5 5206 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5207 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5208 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5209 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5210 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5211 }
whismanoid 0:3edb3708c8c5 5212 break;
whismanoid 0:3edb3708c8c5 5213 case '@':
whismanoid 0:3edb3708c8c5 5214 {
whismanoid 0:3edb3708c8c5 5215 // //
whismanoid 0:3edb3708c8c5 5216 // // Menu @ -- print device configuration
whismanoid 0:3edb3708c8c5 5217 // TODO: cmdLine.serial().printf("\r\n @ -- print MAX5715 configuration");
whismanoid 0:3edb3708c8c5 5218 // //
whismanoid 0:3edb3708c8c5 5219 // print shadow register configuration
whismanoid 0:3edb3708c8c5 5220 //
whismanoid 0:3edb3708c8c5 5221 // shadow of write-only register CODE dddd_dddd_dddd_0000
whismanoid 0:3edb3708c8c5 5222 //~ int16_t CMD_1000_CODE;
whismanoid 0:3edb3708c8c5 5223 int index = 0;
whismanoid 0:3edb3708c8c5 5224 for (index = 0; index < 4; index++)
whismanoid 0:3edb3708c8c5 5225 {
whismanoid 0:3edb3708c8c5 5226 cmdLine.serial().printf("CODE %c=0x%4.4x MAX5715_VoltageOfCode(%d)=%5.3fV\r\n",
whismanoid 0:3edb3708c8c5 5227 (char)('A' + index),
whismanoid 0:3edb3708c8c5 5228 (g_MAX5715_device.Shadow_0010_nnnn_CODE[index] & 0xFFFF),
whismanoid 0:3edb3708c8c5 5229 g_MAX5715_device.CODE[index],
whismanoid 0:3edb3708c8c5 5230 g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[index])
whismanoid 0:3edb3708c8c5 5231 );
whismanoid 0:3edb3708c8c5 5232 }
whismanoid 0:3edb3708c8c5 5233 //
whismanoid 0:3edb3708c8c5 5234 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 5235 //
whismanoid 0:3edb3708c8c5 5236 //
whismanoid 0:3edb3708c8c5 5237 // Menu @) print MAX5715 configuration AND g_MAX5715_device globals
whismanoid 0:3edb3708c8c5 5238 //
whismanoid 0:3edb3708c8c5 5239 #if 1 // SUPPORT_CHANNELS
whismanoid 0:3edb3708c8c5 5240 cmdLine.serial().printf("channelNumber_0_3=%d channels_bitmask_DCBA=%d\r\n",
whismanoid 0:3edb3708c8c5 5241 (g_MAX5715_device.channelNumber_0_3 & 0xFFFF),
whismanoid 0:3edb3708c8c5 5242 (g_MAX5715_device.channels_bitmask_DCBA & 0xFFFF));
whismanoid 0:3edb3708c8c5 5243 #endif // SUPPORT_CHANNELS
whismanoid 0:3edb3708c8c5 5244 //
whismanoid 0:3edb3708c8c5 5245 cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX5715_device.VRef);
whismanoid 0:3edb3708c8c5 5246 // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB
whismanoid 11:38b95a59de02 5247 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 5248 }
whismanoid 0:3edb3708c8c5 5249 break;
whismanoid 11:38b95a59de02 5250 } // end switch (cmdLine[0])
whismanoid 11:38b95a59de02 5251 return false; // command not handled by MAX5715
whismanoid 11:38b95a59de02 5252 } // end bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 5253 #endif
whismanoid 0:3edb3708c8c5 5254
whismanoid 11:38b95a59de02 5255 //--------------------------------------------------
whismanoid 11:38b95a59de02 5256 #if 0 // APPLICATION_MAX11131 // MAX11131_menu_onEOLcommandParser moved to Test_Menu_MAX11131.cpp
whismanoid 11:38b95a59de02 5257 bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 5258 {
whismanoid 11:38b95a59de02 5259 switch (cmdLine[0])
whismanoid 11:38b95a59de02 5260 {
whismanoid 0:3edb3708c8c5 5261 case '0':
whismanoid 0:3edb3708c8c5 5262 {
whismanoid 0:3edb3708c8c5 5263 // recommended for hex command codes 00..0F
whismanoid 0:3edb3708c8c5 5264 // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void);
whismanoid 0:3edb3708c8c5 5265 // TODO: cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead");
whismanoid 0:3edb3708c8c5 5266 if (cmdLine.parse_uint16_dec("n", g_MAX11131_device.NumWords))
whismanoid 0:3edb3708c8c5 5267 {
whismanoid 0:3edb3708c8c5 5268 }
whismanoid 0:3edb3708c8c5 5269 cmdLine.serial().printf("ScanRead NumWords=%d", g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 5270 if (g_MAX11131_device.isExternalClock)
whismanoid 0:3edb3708c8c5 5271 {
whismanoid 0:3edb3708c8c5 5272 cmdLine.serial().printf(" External Clock");
whismanoid 0:3edb3708c8c5 5273 //
whismanoid 0:3edb3708c8c5 5274 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5275 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5276 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5277 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5278 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5279 //
whismanoid 0:3edb3708c8c5 5280 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 5281 }
whismanoid 0:3edb3708c8c5 5282 else
whismanoid 0:3edb3708c8c5 5283 {
whismanoid 0:3edb3708c8c5 5284 cmdLine.serial().printf(" Internal Clock");
whismanoid 0:3edb3708c8c5 5285 //
whismanoid 0:3edb3708c8c5 5286 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5287 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5288 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5289 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5290 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5291 //
whismanoid 0:3edb3708c8c5 5292 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 5293 }
whismanoid 11:38b95a59de02 5294 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5295 }
whismanoid 0:3edb3708c8c5 5296 break;
whismanoid 0:3edb3708c8c5 5297 case '1':
whismanoid 0:3edb3708c8c5 5298 {
whismanoid 0:3edb3708c8c5 5299 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5300 // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 5301 // TODO: cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual");
whismanoid 0:3edb3708c8c5 5302 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5303 {
whismanoid 0:3edb3708c8c5 5304 }
whismanoid 0:3edb3708c8c5 5305 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5306 {
whismanoid 0:3edb3708c8c5 5307 }
whismanoid 0:3edb3708c8c5 5308 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 0:3edb3708c8c5 5309 {
whismanoid 0:3edb3708c8c5 5310 }
whismanoid 0:3edb3708c8c5 5311 cmdLine.serial().printf("ScanManual ch=%d pm=%d id=%d\r\n",
whismanoid 0:3edb3708c8c5 5312 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5313 g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5314 g_MAX11131_device.chan_id_0_1);
whismanoid 0:3edb3708c8c5 5315 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5316 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 0:3edb3708c8c5 5317 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5318 g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
whismanoid 0:3edb3708c8c5 5319 //
whismanoid 0:3edb3708c8c5 5320 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5321 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5322 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5323 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5324 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5325 //
whismanoid 0:3edb3708c8c5 5326 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 5327 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5328 }
whismanoid 0:3edb3708c8c5 5329 break;
whismanoid 0:3edb3708c8c5 5330 case '2':
whismanoid 0:3edb3708c8c5 5331 {
whismanoid 0:3edb3708c8c5 5332 // recommended for hex command codes 20..2F
whismanoid 0:3edb3708c8c5 5333 // VERIFY: console menu command 2 int MAX11131_ScanRepeat(uint8_t channelNumber_0_15, uint8_t average_0_4_8_16_32, uint8_t nscan_4_8_12_16, uint8_t PowerManagement_0_2, uint8_t swcnv_0_1);
whismanoid 0:3edb3708c8c5 5334 // TODO: cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat");
whismanoid 0:3edb3708c8c5 5335 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 0:3edb3708c8c5 5336 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5337 // VERIFY: update value of g_MAX11131_device.nscan_4_8_12_16 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5338 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5339 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5340 // VERIFY: parse strCommandArgs for additional arguments including key=value pairs
whismanoid 0:3edb3708c8c5 5341 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5342 {
whismanoid 0:3edb3708c8c5 5343 }
whismanoid 0:3edb3708c8c5 5344 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 0:3edb3708c8c5 5345 {
whismanoid 0:3edb3708c8c5 5346 }
whismanoid 0:3edb3708c8c5 5347 if (cmdLine.parse_byte_dec("n", g_MAX11131_device.nscan_4_8_12_16))
whismanoid 0:3edb3708c8c5 5348 {
whismanoid 0:3edb3708c8c5 5349 }
whismanoid 0:3edb3708c8c5 5350 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 0:3edb3708c8c5 5351 {
whismanoid 0:3edb3708c8c5 5352 }
whismanoid 0:3edb3708c8c5 5353 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5354 {
whismanoid 0:3edb3708c8c5 5355 }
whismanoid 0:3edb3708c8c5 5356 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 5357 "ScanRepeat ch=%d average_0_4_8_16_32:%d nscan_4_8_12_16:%d swcnv=%d pm=%d\r\n",
whismanoid 0:3edb3708c8c5 5358 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5359 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 0:3edb3708c8c5 5360 g_MAX11131_device.nscan_4_8_12_16,
whismanoid 0:3edb3708c8c5 5361 g_MAX11131_device.swcnv_0_1,
whismanoid 0:3edb3708c8c5 5362 g_MAX11131_device.PowerManagement_0_2);
whismanoid 0:3edb3708c8c5 5363 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5364 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 0:3edb3708c8c5 5365 // VERIFY: replace argument with driver global; g_MAX11131_device.nscan_4_8_12_16 replaces nscan_4_8_12_16
whismanoid 0:3edb3708c8c5 5366 // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32
whismanoid 0:3edb3708c8c5 5367 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5368 g_MAX11131_device.NumWords = g_MAX11131_device.ScanRepeat();
whismanoid 0:3edb3708c8c5 5369 //
whismanoid 0:3edb3708c8c5 5370 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5371 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5372 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5373 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5374 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5375 //
whismanoid 0:3edb3708c8c5 5376 AINcode_print_value_chanID_mean(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 5377 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5378 }
whismanoid 0:3edb3708c8c5 5379 break;
whismanoid 0:3edb3708c8c5 5380 case '3':
whismanoid 0:3edb3708c8c5 5381 {
whismanoid 0:3edb3708c8c5 5382 // recommended for hex command codes 30..3F
whismanoid 0:3edb3708c8c5 5383 // VERIFY: console menu command 3 MAX11131_ScanStandardInternalClock(int channelNumber_0_15, int average_0_4_8_16_32, int PowerManagement_0_2, int swcnv_0_1);
whismanoid 0:3edb3708c8c5 5384 // TODO: cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock");
whismanoid 0:3edb3708c8c5 5385 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 0:3edb3708c8c5 5386 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5387 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5388 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5389 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5390 {
whismanoid 0:3edb3708c8c5 5391 }
whismanoid 0:3edb3708c8c5 5392 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 0:3edb3708c8c5 5393 {
whismanoid 0:3edb3708c8c5 5394 }
whismanoid 0:3edb3708c8c5 5395 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5396 {
whismanoid 0:3edb3708c8c5 5397 }
whismanoid 0:3edb3708c8c5 5398 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 0:3edb3708c8c5 5399 {
whismanoid 0:3edb3708c8c5 5400 }
whismanoid 0:3edb3708c8c5 5401 cmdLine.serial().printf("ScanStandardInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n",
whismanoid 0:3edb3708c8c5 5402 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5403 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 0:3edb3708c8c5 5404 g_MAX11131_device.swcnv_0_1,
whismanoid 0:3edb3708c8c5 5405 g_MAX11131_device.PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5406 );
whismanoid 0:3edb3708c8c5 5407 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5408 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 0:3edb3708c8c5 5409 // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32
whismanoid 0:3edb3708c8c5 5410 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5411 g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardInternalClock();
whismanoid 0:3edb3708c8c5 5412 //
whismanoid 0:3edb3708c8c5 5413 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5414 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5415 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5416 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5417 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5418 //
whismanoid 0:3edb3708c8c5 5419 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 5420 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5421 }
whismanoid 0:3edb3708c8c5 5422 break;
whismanoid 0:3edb3708c8c5 5423 case '4':
whismanoid 0:3edb3708c8c5 5424 {
whismanoid 0:3edb3708c8c5 5425 // recommended for hex command codes 40..4F
whismanoid 0:3edb3708c8c5 5426 // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 5427 // TODO: cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock");
whismanoid 0:3edb3708c8c5 5428 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 0:3edb3708c8c5 5429 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5430 // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5431 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5432 {
whismanoid 0:3edb3708c8c5 5433 }
whismanoid 0:3edb3708c8c5 5434 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5435 {
whismanoid 0:3edb3708c8c5 5436 }
whismanoid 0:3edb3708c8c5 5437 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 0:3edb3708c8c5 5438 {
whismanoid 0:3edb3708c8c5 5439 }
whismanoid 0:3edb3708c8c5 5440 cmdLine.serial().printf("ScanStandardExternalClock ch=%d pm=%d id=%d\r\n",
whismanoid 0:3edb3708c8c5 5441 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5442 g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5443 g_MAX11131_device.chan_id_0_1
whismanoid 0:3edb3708c8c5 5444 );
whismanoid 0:3edb3708c8c5 5445 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5446 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 0:3edb3708c8c5 5447 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5448 g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock();
whismanoid 0:3edb3708c8c5 5449 //
whismanoid 0:3edb3708c8c5 5450 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5451 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5452 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5453 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5454 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5455 //
whismanoid 0:3edb3708c8c5 5456 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 5457 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5458 }
whismanoid 0:3edb3708c8c5 5459 break;
whismanoid 0:3edb3708c8c5 5460 case '5':
whismanoid 0:3edb3708c8c5 5461 {
whismanoid 0:3edb3708c8c5 5462 // recommended for hex command codes 50..5F
whismanoid 0:3edb3708c8c5 5463 // VERIFY: console menu command 5 MAX11131_ScanUpperInternalClock(int channelNumber_0_15, int average_0_4_8_16_32, int PowerManagement_0_2, int swcnv_0_1);
whismanoid 0:3edb3708c8c5 5464 // TODO: cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock");
whismanoid 0:3edb3708c8c5 5465 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 0:3edb3708c8c5 5466 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5467 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5468 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5469 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5470 {
whismanoid 0:3edb3708c8c5 5471 }
whismanoid 0:3edb3708c8c5 5472 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 0:3edb3708c8c5 5473 {
whismanoid 0:3edb3708c8c5 5474 }
whismanoid 0:3edb3708c8c5 5475 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5476 {
whismanoid 0:3edb3708c8c5 5477 }
whismanoid 0:3edb3708c8c5 5478 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 0:3edb3708c8c5 5479 {
whismanoid 0:3edb3708c8c5 5480 }
whismanoid 0:3edb3708c8c5 5481 cmdLine.serial().printf("ScanUpperInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n",
whismanoid 0:3edb3708c8c5 5482 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5483 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 0:3edb3708c8c5 5484 g_MAX11131_device.swcnv_0_1,
whismanoid 0:3edb3708c8c5 5485 g_MAX11131_device.PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5486 );
whismanoid 0:3edb3708c8c5 5487 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5488 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 0:3edb3708c8c5 5489 // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32
whismanoid 0:3edb3708c8c5 5490 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5491 g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperInternalClock();
whismanoid 0:3edb3708c8c5 5492 //
whismanoid 0:3edb3708c8c5 5493 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5494 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5495 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5496 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5497 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5498 //
whismanoid 0:3edb3708c8c5 5499 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 5500 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5501 }
whismanoid 0:3edb3708c8c5 5502 break;
whismanoid 0:3edb3708c8c5 5503 case '6':
whismanoid 0:3edb3708c8c5 5504 {
whismanoid 0:3edb3708c8c5 5505 // recommended for hex command codes 60..6F
whismanoid 0:3edb3708c8c5 5506 // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 5507 // TODO: cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock");
whismanoid 0:3edb3708c8c5 5508 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 0:3edb3708c8c5 5509 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5510 // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5511 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5512 {
whismanoid 0:3edb3708c8c5 5513 }
whismanoid 0:3edb3708c8c5 5514 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5515 {
whismanoid 0:3edb3708c8c5 5516 }
whismanoid 0:3edb3708c8c5 5517 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 0:3edb3708c8c5 5518 {
whismanoid 0:3edb3708c8c5 5519 }
whismanoid 0:3edb3708c8c5 5520 cmdLine.serial().printf("ScanUpperExternalClock ch=%d pm=%d id=%d\r\n",
whismanoid 0:3edb3708c8c5 5521 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5522 g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5523 g_MAX11131_device.chan_id_0_1
whismanoid 0:3edb3708c8c5 5524 );
whismanoid 0:3edb3708c8c5 5525 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5526 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 0:3edb3708c8c5 5527 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5528 g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperExternalClock();
whismanoid 0:3edb3708c8c5 5529 //
whismanoid 0:3edb3708c8c5 5530 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5531 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5532 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5533 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5534 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5535 //
whismanoid 0:3edb3708c8c5 5536 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 5537 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5538 }
whismanoid 0:3edb3708c8c5 5539 break;
whismanoid 0:3edb3708c8c5 5540 case '7':
whismanoid 0:3edb3708c8c5 5541 {
whismanoid 0:3edb3708c8c5 5542 // recommended for hex command codes 70..7F
whismanoid 0:3edb3708c8c5 5543 // VERIFY: console menu command 7 MAX11131_ScanCustomInternalClock(int16_t enabledChannelsMask, int average_0_4_8_16_32, int PowerManagement_0_2, int swcnv_0_1);
whismanoid 0:3edb3708c8c5 5544 // TODO: cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock");
whismanoid 0:3edb3708c8c5 5545 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5546 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5547 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5548 if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask))
whismanoid 0:3edb3708c8c5 5549 {
whismanoid 0:3edb3708c8c5 5550 // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs
whismanoid 0:3edb3708c8c5 5551 }
whismanoid 0:3edb3708c8c5 5552 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 0:3edb3708c8c5 5553 {
whismanoid 0:3edb3708c8c5 5554 }
whismanoid 0:3edb3708c8c5 5555 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5556 {
whismanoid 0:3edb3708c8c5 5557 }
whismanoid 0:3edb3708c8c5 5558 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 0:3edb3708c8c5 5559 {
whismanoid 0:3edb3708c8c5 5560 }
whismanoid 0:3edb3708c8c5 5561 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 5562 "ScanCustomInternalClock enabledChannelsMask:0x%4.4x average_0_4_8_16_32:%d pm=%d swcnv=%d\r\n",
whismanoid 0:3edb3708c8c5 5563 (g_MAX11131_device.enabledChannelsMask & 0xFFFF),
whismanoid 0:3edb3708c8c5 5564 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 0:3edb3708c8c5 5565 g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5566 g_MAX11131_device.swcnv_0_1
whismanoid 0:3edb3708c8c5 5567 );
whismanoid 0:3edb3708c8c5 5568 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5569 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 0:3edb3708c8c5 5570 // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32
whismanoid 0:3edb3708c8c5 5571 // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask
whismanoid 0:3edb3708c8c5 5572 g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomInternalClock();
whismanoid 0:3edb3708c8c5 5573 //
whismanoid 0:3edb3708c8c5 5574 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5575 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5576 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5577 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5578 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5579 //
whismanoid 0:3edb3708c8c5 5580 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 5581 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5582 }
whismanoid 0:3edb3708c8c5 5583 break;
whismanoid 0:3edb3708c8c5 5584 case '8':
whismanoid 0:3edb3708c8c5 5585 {
whismanoid 0:3edb3708c8c5 5586 // recommended for hex command codes 80..8F
whismanoid 0:3edb3708c8c5 5587 // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 5588 // TODO: cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock");
whismanoid 0:3edb3708c8c5 5589 if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask))
whismanoid 0:3edb3708c8c5 5590 {
whismanoid 0:3edb3708c8c5 5591 // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs
whismanoid 0:3edb3708c8c5 5592 }
whismanoid 0:3edb3708c8c5 5593 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5594 {
whismanoid 0:3edb3708c8c5 5595 }
whismanoid 0:3edb3708c8c5 5596 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 0:3edb3708c8c5 5597 {
whismanoid 0:3edb3708c8c5 5598 }
whismanoid 0:3edb3708c8c5 5599 cmdLine.serial().printf("ScanCustomExternalClock enabledChannelsMask:0x%4.4x pm=%d id=%d\r\n",
whismanoid 0:3edb3708c8c5 5600 (g_MAX11131_device.enabledChannelsMask & 0xFFFF),
whismanoid 0:3edb3708c8c5 5601 g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5602 g_MAX11131_device.chan_id_0_1
whismanoid 0:3edb3708c8c5 5603 );
whismanoid 0:3edb3708c8c5 5604 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5605 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 0:3edb3708c8c5 5606 // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask
whismanoid 0:3edb3708c8c5 5607 g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomExternalClock();
whismanoid 0:3edb3708c8c5 5608 //
whismanoid 0:3edb3708c8c5 5609 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5610 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5611 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5612 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5613 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5614 //
whismanoid 0:3edb3708c8c5 5615 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 5616 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5617 }
whismanoid 0:3edb3708c8c5 5618 break;
whismanoid 0:3edb3708c8c5 5619 case '9':
whismanoid 0:3edb3708c8c5 5620 {
whismanoid 0:3edb3708c8c5 5621 // recommended for hex command codes 90..9F
whismanoid 0:3edb3708c8c5 5622 // VERIFY: console menu command 9 MAX11131_ScanSampleSetExternalClock(uint8_t enabledChannelsPatternLength_1_256, int16_t enabledChannelsPattern[], int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 5623 // TODO: cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock");
whismanoid 0:3edb3708c8c5 5624 //
whismanoid 0:3edb3708c8c5 5625 // get MAX11131 Sampleset channel selection pattern parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 5626 // cmdLine.parse_byteCount_byteList_dec(byteCount, mosiData, MAX_SPI_BYTE_COUNT)
whismanoid 0:3edb3708c8c5 5627 // into g_MAX11131_device.enabledChannelsPatternLength_1_256
whismanoid 0:3edb3708c8c5 5628 // into g_MAX11131_device.enabledChannelsPattern[0..255]
whismanoid 0:3edb3708c8c5 5629 size_t numValues;
whismanoid 0:3edb3708c8c5 5630 char valueList[256];
whismanoid 0:3edb3708c8c5 5631 if (cmdLine.parse_byteCount_byteList_dec( numValues, valueList, 256))
whismanoid 0:3edb3708c8c5 5632 {
whismanoid 0:3edb3708c8c5 5633 // first value is the "9" command itself
whismanoid 0:3edb3708c8c5 5634 g_MAX11131_device.enabledChannelsPatternLength_1_256 = numValues - 1;
whismanoid 0:3edb3708c8c5 5635 // copy valueList[1, ...] into g_MAX11131_device.enabledChannelsPattern[0, ...]
whismanoid 0:3edb3708c8c5 5636 for (size_t index = 0; index < (numValues - 1); index++)
whismanoid 0:3edb3708c8c5 5637 {
whismanoid 0:3edb3708c8c5 5638 g_MAX11131_device.enabledChannelsPattern[index] = valueList[1 + index];
whismanoid 0:3edb3708c8c5 5639 }
whismanoid 0:3edb3708c8c5 5640 }
whismanoid 0:3edb3708c8c5 5641 //
whismanoid 0:3edb3708c8c5 5642 cmdLine.serial().printf("ScanSampleSetExternalClock enabledChannelsPattern:{ ");
whismanoid 0:3edb3708c8c5 5643 int index;
whismanoid 0:3edb3708c8c5 5644 for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++)
whismanoid 0:3edb3708c8c5 5645 {
whismanoid 0:3edb3708c8c5 5646 //~ Serial.print( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC);
whismanoid 0:3edb3708c8c5 5647 //~ Serial.print(" ");
whismanoid 0:3edb3708c8c5 5648 cmdLine.serial().printf("AIN%d ", ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F));
whismanoid 0:3edb3708c8c5 5649 }
whismanoid 0:3edb3708c8c5 5650 cmdLine.serial().printf("}");
whismanoid 0:3edb3708c8c5 5651 cmdLine.serial().printf(" pm=%d id=%d\r\n", g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5652 g_MAX11131_device.chan_id_0_1);
whismanoid 0:3edb3708c8c5 5653 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5654 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 0:3edb3708c8c5 5655 g_MAX11131_device.NumWords = g_MAX11131_device.ScanSampleSetExternalClock();
whismanoid 0:3edb3708c8c5 5656 //
whismanoid 0:3edb3708c8c5 5657 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5658 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5659 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5660 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5661 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5662 //
whismanoid 0:3edb3708c8c5 5663 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 5664 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5665 }
whismanoid 0:3edb3708c8c5 5666 break;
whismanoid 0:3edb3708c8c5 5667 case 'a': case 'A':
whismanoid 0:3edb3708c8c5 5668 {
whismanoid 0:3edb3708c8c5 5669 // recommended for hex command codes A0..AF
whismanoid 0:3edb3708c8c5 5670 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5671 {
whismanoid 0:3edb3708c8c5 5672 case 't': case 'T':
whismanoid 0:3edb3708c8c5 5673 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5674 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5675 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5676 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5677 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 11:38b95a59de02 5678 return false; // command not handled
whismanoid 0:3edb3708c8c5 5679 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5680 }
whismanoid 0:3edb3708c8c5 5681 }
whismanoid 0:3edb3708c8c5 5682 break;
whismanoid 0:3edb3708c8c5 5683 case 'b': case 'B':
whismanoid 0:3edb3708c8c5 5684 {
whismanoid 0:3edb3708c8c5 5685 // recommended for hex command codes B0..BF
whismanoid 0:3edb3708c8c5 5686 }
whismanoid 0:3edb3708c8c5 5687 break;
whismanoid 0:3edb3708c8c5 5688 case 'c': case 'C':
whismanoid 0:3edb3708c8c5 5689 {
whismanoid 0:3edb3708c8c5 5690 // recommended for hex command codes C0..CF
whismanoid 0:3edb3708c8c5 5691 }
whismanoid 0:3edb3708c8c5 5692 break;
whismanoid 0:3edb3708c8c5 5693 case 'd': case 'D':
whismanoid 0:3edb3708c8c5 5694 {
whismanoid 0:3edb3708c8c5 5695 // recommended for hex command codes D0..DF
whismanoid 0:3edb3708c8c5 5696 }
whismanoid 0:3edb3708c8c5 5697 break;
whismanoid 0:3edb3708c8c5 5698 case 'e': case 'E':
whismanoid 0:3edb3708c8c5 5699 {
whismanoid 0:3edb3708c8c5 5700 // recommended for hex command codes E0..EF
whismanoid 0:3edb3708c8c5 5701 }
whismanoid 0:3edb3708c8c5 5702 break;
whismanoid 0:3edb3708c8c5 5703 case 'f': case 'F':
whismanoid 0:3edb3708c8c5 5704 {
whismanoid 0:3edb3708c8c5 5705 // recommended for hex command codes F0..FF
whismanoid 0:3edb3708c8c5 5706 }
whismanoid 0:3edb3708c8c5 5707 break;
whismanoid 0:3edb3708c8c5 5708 case 'x': case 'X':
whismanoid 0:3edb3708c8c5 5709 {
whismanoid 0:3edb3708c8c5 5710 }
whismanoid 0:3edb3708c8c5 5711 break;
whismanoid 0:3edb3708c8c5 5712 case 'y': case 'Y':
whismanoid 0:3edb3708c8c5 5713 {
whismanoid 0:3edb3708c8c5 5714 }
whismanoid 0:3edb3708c8c5 5715 break;
whismanoid 0:3edb3708c8c5 5716 case 'i': case 'I':
whismanoid 0:3edb3708c8c5 5717 {
whismanoid 0:3edb3708c8c5 5718 // TODO: cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range");
whismanoid 0:3edb3708c8c5 5719 char strChannelId[3];
whismanoid 0:3edb3708c8c5 5720 strChannelId[0] = cmdLine[2];
whismanoid 0:3edb3708c8c5 5721 strChannelId[1] = cmdLine[3];
whismanoid 0:3edb3708c8c5 5722 strChannelId[2] = '\0';
whismanoid 0:3edb3708c8c5 5723 int channelId_0_15 = strtoul(strChannelId, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 0:3edb3708c8c5 5724 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5725 {
whismanoid 0:3edb3708c8c5 5726 case 's': case 'S':
whismanoid 0:3edb3708c8c5 5727 g_MAX11131_device.Reconfigure_SingleEnded(channelId_0_15);
whismanoid 0:3edb3708c8c5 5728 break;
whismanoid 0:3edb3708c8c5 5729 case 'u': case 'U':
whismanoid 0:3edb3708c8c5 5730 g_MAX11131_device.Reconfigure_DifferentialUnipolar(channelId_0_15);
whismanoid 0:3edb3708c8c5 5731 break;
whismanoid 0:3edb3708c8c5 5732 case 'b': case 'B':
whismanoid 0:3edb3708c8c5 5733 g_MAX11131_device.Reconfigure_DifferentialBipolarFSVref(channelId_0_15);
whismanoid 0:3edb3708c8c5 5734 break;
whismanoid 0:3edb3708c8c5 5735 case 'r': case 'R':
whismanoid 0:3edb3708c8c5 5736 g_MAX11131_device.Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15);
whismanoid 0:3edb3708c8c5 5737 break;
whismanoid 0:3edb3708c8c5 5738 }
whismanoid 0:3edb3708c8c5 5739 // char cmd1 = strCommandArgs[0];
whismanoid 0:3edb3708c8c5 5740 // strCommandArgs.remove(0, 1); // unsigned int index, unsigned int count
whismanoid 0:3edb3708c8c5 5741 // // get argument int channelId_0_15
whismanoid 0:3edb3708c8c5 5742 // // parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 5743 // int channelId_0_15 = strtoul(strCommandArgs.c_str(), NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 0:3edb3708c8c5 5744 // if (cmd1 == 'S') {
whismanoid 0:3edb3708c8c5 5745 // MAX11131_Reconfigure_SingleEnded(channelId_0_15);
whismanoid 0:3edb3708c8c5 5746 // }
whismanoid 0:3edb3708c8c5 5747 // else if (cmd1 == 'U') {
whismanoid 0:3edb3708c8c5 5748 // MAX11131_Reconfigure_DifferentialUnipolar(channelId_0_15);
whismanoid 0:3edb3708c8c5 5749 // }
whismanoid 0:3edb3708c8c5 5750 // else if (cmd1 == 'B') {
whismanoid 0:3edb3708c8c5 5751 // MAX11131_Reconfigure_DifferentialBipolarFSVref(channelId_0_15);
whismanoid 0:3edb3708c8c5 5752 // }
whismanoid 0:3edb3708c8c5 5753 // else if (cmd1 == 'R') {
whismanoid 0:3edb3708c8c5 5754 // MAX11131_Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15);
whismanoid 0:3edb3708c8c5 5755 // }
whismanoid 11:38b95a59de02 5756 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5757 }
whismanoid 0:3edb3708c8c5 5758 break;
whismanoid 0:3edb3708c8c5 5759 case '@':
whismanoid 0:3edb3708c8c5 5760 {
whismanoid 0:3edb3708c8c5 5761 // TODO: cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration");
whismanoid 0:3edb3708c8c5 5762 // print shadow register configuration
whismanoid 0:3edb3708c8c5 5763 //
whismanoid 0:3edb3708c8c5 5764 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_MODE_CONTROL & 0xFFFF));
whismanoid 0:3edb3708c8c5 5765 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_MODE_CONTROL);
whismanoid 0:3edb3708c8c5 5766 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_CONFIGURATION & 0xFFFF));
whismanoid 0:3edb3708c8c5 5767 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_CONFIGURATION);
whismanoid 0:3edb3708c8c5 5768 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.UNIPOLAR & 0xFFFF));
whismanoid 0:3edb3708c8c5 5769 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.UNIPOLAR);
whismanoid 0:3edb3708c8c5 5770 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.BIPOLAR & 0xFFFF));
whismanoid 0:3edb3708c8c5 5771 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.BIPOLAR);
whismanoid 0:3edb3708c8c5 5772 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.RANGE & 0xFFFF));
whismanoid 0:3edb3708c8c5 5773 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.RANGE);
whismanoid 0:3edb3708c8c5 5774 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN0 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5775 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN0);
whismanoid 0:3edb3708c8c5 5776 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN1 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5777 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN1);
whismanoid 0:3edb3708c8c5 5778 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.SAMPLESET & 0xFFFF));
whismanoid 0:3edb3708c8c5 5779 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.SAMPLESET);
whismanoid 0:3edb3708c8c5 5780 //
whismanoid 0:3edb3708c8c5 5781 // VERIFY: print shadow SAMPLESET pattern entry
whismanoid 0:3edb3708c8c5 5782 int entryIndex;
whismanoid 0:3edb3708c8c5 5783 for (entryIndex = 0; entryIndex < g_MAX11131_device.enabledChannelsPatternLength_1_256;
whismanoid 0:3edb3708c8c5 5784 entryIndex += 4)
whismanoid 0:3edb3708c8c5 5785 {
whismanoid 0:3edb3708c8c5 5786 uint16_t pack4channels = 0;
whismanoid 0:3edb3708c8c5 5787 pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 0]) & 0x0F) << 12);
whismanoid 0:3edb3708c8c5 5788 if ((entryIndex + 1) < g_MAX11131_device.enabledChannelsPatternLength_1_256) {
whismanoid 0:3edb3708c8c5 5789 pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 1]) & 0x0F) << 8);
whismanoid 0:3edb3708c8c5 5790 }
whismanoid 0:3edb3708c8c5 5791 if ((entryIndex + 2) < g_MAX11131_device.enabledChannelsPatternLength_1_256) {
whismanoid 0:3edb3708c8c5 5792 pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 2]) & 0x0F) << 4);
whismanoid 0:3edb3708c8c5 5793 }
whismanoid 0:3edb3708c8c5 5794 if ((entryIndex + 3) < g_MAX11131_device.enabledChannelsPatternLength_1_256) {
whismanoid 0:3edb3708c8c5 5795 pack4channels |= ((g_MAX11131_device.enabledChannelsPattern[entryIndex + 3]) & 0x0F);
whismanoid 0:3edb3708c8c5 5796 }
whismanoid 0:3edb3708c8c5 5797 //~ SPIwrite16bits(pack4channels);
whismanoid 0:3edb3708c8c5 5798 cmdLine.serial().printf(" 0x%4.4x", (pack4channels & 0xFFFF));
whismanoid 0:3edb3708c8c5 5799 // decode SAMPLESET channel select pattern
whismanoid 0:3edb3708c8c5 5800 cmdLine.serial().printf(" SampleSet Entry: AIN%d AIN%d AIN%d AIN%d\r\n",
whismanoid 0:3edb3708c8c5 5801 ((pack4channels >> 12) & 0x000F),
whismanoid 0:3edb3708c8c5 5802 ((pack4channels >> 8) & 0x000F),
whismanoid 0:3edb3708c8c5 5803 ((pack4channels >> 4) & 0x000F),
whismanoid 0:3edb3708c8c5 5804 ((pack4channels ) & 0x000F)
whismanoid 0:3edb3708c8c5 5805 );
whismanoid 0:3edb3708c8c5 5806 }
whismanoid 0:3edb3708c8c5 5807 //cmdLine.serial().printf(" SAMPLESET enabledChannelsPattern:{ ");
whismanoid 0:3edb3708c8c5 5808 //int index;
whismanoid 0:3edb3708c8c5 5809 //for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++)
whismanoid 0:3edb3708c8c5 5810 //{
whismanoid 0:3edb3708c8c5 5811 // //~ cmdLine.serial().printf( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC);
whismanoid 0:3edb3708c8c5 5812 // //~ cmdLine.serial().printf(" ");
whismanoid 0:3edb3708c8c5 5813 // cmdLine.serial().printf("AIN");
whismanoid 0:3edb3708c8c5 5814 // cmdLine.serial().printf( ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F), DEC);
whismanoid 0:3edb3708c8c5 5815 // cmdLine.serial().printf(" ");
whismanoid 0:3edb3708c8c5 5816 //}
whismanoid 0:3edb3708c8c5 5817 //cmdLine.serial().printf("}");
whismanoid 0:3edb3708c8c5 5818 //
whismanoid 0:3edb3708c8c5 5819 // Menu @) print MAX11131 configuration AND g_MAX11131_device globals
whismanoid 0:3edb3708c8c5 5820 //
whismanoid 0:3edb3708c8c5 5821 cmdLine.serial().printf("SPI_MOSI_Semantic=%d\r\n", (g_MAX11131_device.SPI_MOSI_Semantic & 0xFFFF));
whismanoid 0:3edb3708c8c5 5822 cmdLine.serial().printf("NumWords=%d\r\n", (g_MAX11131_device.NumWords & 0xFFFF));
whismanoid 0:3edb3708c8c5 5823 cmdLine.serial().printf("isExternalClock=%d\r\n", (g_MAX11131_device.isExternalClock & 0xFFFF));
whismanoid 0:3edb3708c8c5 5824 cmdLine.serial().printf("ScanMode=%d\r\n", (g_MAX11131_device.ScanMode & 0xFFFF));
whismanoid 0:3edb3708c8c5 5825 cmdLine.serial().printf("channelNumber_0_15=%d\r\n",
whismanoid 0:3edb3708c8c5 5826 (g_MAX11131_device.channelNumber_0_15 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5827 cmdLine.serial().printf("PowerManagement_0_2=%d\r\n",
whismanoid 0:3edb3708c8c5 5828 (g_MAX11131_device.PowerManagement_0_2 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5829 cmdLine.serial().printf("chan_id_0_1=%d\r\n", (g_MAX11131_device.chan_id_0_1 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5830 cmdLine.serial().printf("average_0_4_8_16_32=%d\r\n",
whismanoid 0:3edb3708c8c5 5831 (g_MAX11131_device.average_0_4_8_16_32 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5832 cmdLine.serial().printf("nscan_4_8_12_16=%d\r\n", (g_MAX11131_device.nscan_4_8_12_16 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5833 cmdLine.serial().printf("swcnv_0_1=%d\r\n", (g_MAX11131_device.swcnv_0_1 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5834 cmdLine.serial().printf("enabledChannelsMask=0x%4.4x\r\n",
whismanoid 0:3edb3708c8c5 5835 (g_MAX11131_device.enabledChannelsMask & 0xFFFF));
whismanoid 0:3edb3708c8c5 5836 //
whismanoid 0:3edb3708c8c5 5837 cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX11131_device.VRef);
whismanoid 0:3edb3708c8c5 5838 // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB
whismanoid 0:3edb3708c8c5 5839 //
whismanoid 11:38b95a59de02 5840 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5841 }
whismanoid 0:3edb3708c8c5 5842 //case '&':
whismanoid 0:3edb3708c8c5 5843 //{
whismanoid 0:3edb3708c8c5 5844 // // TODO: cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual");
whismanoid 0:3edb3708c8c5 5845 //}
whismanoid 0:3edb3708c8c5 5846 break;
whismanoid 0:3edb3708c8c5 5847 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 0:3edb3708c8c5 5848 {
whismanoid 0:3edb3708c8c5 5849 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 5850 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5851 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5852 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5853 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5854 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5855 }
whismanoid 0:3edb3708c8c5 5856 break;
whismanoid 0:3edb3708c8c5 5857 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 0:3edb3708c8c5 5858 {
whismanoid 0:3edb3708c8c5 5859 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5860 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5861 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5862 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5863 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5864 }
whismanoid 0:3edb3708c8c5 5865 break;
whismanoid 11:38b95a59de02 5866 } // end switch (cmdLine[0])
whismanoid 11:38b95a59de02 5867 return false; // command not handled
whismanoid 11:38b95a59de02 5868 } // end bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 5869 #endif
whismanoid 0:3edb3708c8c5 5870
whismanoid 11:38b95a59de02 5871 //--------------------------------------------------
whismanoid 11:38b95a59de02 5872 #if 0 // APPLICATION_MAX5171 // MAX5171_menu_onEOLcommandParser moved to Test_Menu_MAX5171.cpp
whismanoid 11:38b95a59de02 5873 bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 5874 {
whismanoid 11:38b95a59de02 5875 switch (cmdLine[0])
whismanoid 11:38b95a59de02 5876 {
whismanoid 0:3edb3708c8c5 5877 case '0':
whismanoid 0:3edb3708c8c5 5878 {
whismanoid 0:3edb3708c8c5 5879 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5880 //~ cmdLine.serial().printf("\r\n 0 code=? -- CODE");
whismanoid 0:3edb3708c8c5 5881 uint16_t code;
whismanoid 0:3edb3708c8c5 5882 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 5883 {
whismanoid 0:3edb3708c8c5 5884 }
whismanoid 0:3edb3708c8c5 5885 cmdLine.serial().printf("CODE code=%d", code);
whismanoid 0:3edb3708c8c5 5886 g_MAX5171_device.CODE(code);
whismanoid 11:38b95a59de02 5887 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5888 }
whismanoid 0:3edb3708c8c5 5889 break;
whismanoid 0:3edb3708c8c5 5890 case '4':
whismanoid 0:3edb3708c8c5 5891 {
whismanoid 0:3edb3708c8c5 5892 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5893 //~ cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD");
whismanoid 0:3edb3708c8c5 5894 uint16_t code;
whismanoid 0:3edb3708c8c5 5895 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 5896 {
whismanoid 0:3edb3708c8c5 5897 }
whismanoid 0:3edb3708c8c5 5898 cmdLine.serial().printf("CODE_LOAD code=%d", code);
whismanoid 0:3edb3708c8c5 5899 g_MAX5171_device.CODE_LOAD(code);
whismanoid 11:38b95a59de02 5900 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5901 }
whismanoid 0:3edb3708c8c5 5902 break;
whismanoid 0:3edb3708c8c5 5903 case '8':
whismanoid 0:3edb3708c8c5 5904 {
whismanoid 0:3edb3708c8c5 5905 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5906 //~ cmdLine.serial().printf("\r\n 8 -- LOAD");
whismanoid 0:3edb3708c8c5 5907 cmdLine.serial().printf("LOAD");
whismanoid 0:3edb3708c8c5 5908 g_MAX5171_device.LOAD();
whismanoid 11:38b95a59de02 5909 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5910 }
whismanoid 0:3edb3708c8c5 5911 break;
whismanoid 0:3edb3708c8c5 5912 case 'c': case 'C':
whismanoid 0:3edb3708c8c5 5913 {
whismanoid 0:3edb3708c8c5 5914 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5915 //~ cmdLine.serial().printf("\r\n c -- NOP");
whismanoid 0:3edb3708c8c5 5916 cmdLine.serial().printf("NOP");
whismanoid 0:3edb3708c8c5 5917 g_MAX5171_device.NOP();
whismanoid 11:38b95a59de02 5918 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5919 }
whismanoid 0:3edb3708c8c5 5920 break;
whismanoid 0:3edb3708c8c5 5921 case 'd': case 'D':
whismanoid 0:3edb3708c8c5 5922 {
whismanoid 0:3edb3708c8c5 5923 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5924 //~ cmdLine.serial().printf("\r\n d -- SHUTDOWN");
whismanoid 0:3edb3708c8c5 5925 cmdLine.serial().printf("SHUTDOWN");
whismanoid 0:3edb3708c8c5 5926 g_MAX5171_device.SHUTDOWN();
whismanoid 11:38b95a59de02 5927 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5928 }
whismanoid 0:3edb3708c8c5 5929 break;
whismanoid 0:3edb3708c8c5 5930 case 'e': case 'E':
whismanoid 0:3edb3708c8c5 5931 {
whismanoid 0:3edb3708c8c5 5932 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5933 {
whismanoid 0:3edb3708c8c5 5934 case '0':
whismanoid 0:3edb3708c8c5 5935 {
whismanoid 0:3edb3708c8c5 5936 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5937 //~ cmdLine.serial().printf("\r\n e0 -- UPO_LOW");
whismanoid 0:3edb3708c8c5 5938 cmdLine.serial().printf("UPO_LOW");
whismanoid 0:3edb3708c8c5 5939 g_MAX5171_device.UPO_LOW();
whismanoid 11:38b95a59de02 5940 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5941 }
whismanoid 0:3edb3708c8c5 5942 break;
whismanoid 0:3edb3708c8c5 5943 case '8':
whismanoid 0:3edb3708c8c5 5944 {
whismanoid 0:3edb3708c8c5 5945 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5946 //~ cmdLine.serial().printf("\r\n e8 -- UPO_HIGH");
whismanoid 0:3edb3708c8c5 5947 cmdLine.serial().printf("UPO_HIGH");
whismanoid 0:3edb3708c8c5 5948 g_MAX5171_device.UPO_HIGH();
whismanoid 11:38b95a59de02 5949 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5950 }
whismanoid 0:3edb3708c8c5 5951 break;
whismanoid 0:3edb3708c8c5 5952 }
whismanoid 0:3edb3708c8c5 5953 }
whismanoid 0:3edb3708c8c5 5954 break;
whismanoid 0:3edb3708c8c5 5955 case 'f': case 'F':
whismanoid 0:3edb3708c8c5 5956 {
whismanoid 0:3edb3708c8c5 5957 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5958 {
whismanoid 0:3edb3708c8c5 5959 case '0':
whismanoid 0:3edb3708c8c5 5960 {
whismanoid 0:3edb3708c8c5 5961 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5962 //~ cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE");
whismanoid 0:3edb3708c8c5 5963 cmdLine.serial().printf("MODE1_DOUT_SCLK_RISING_EDGE");
whismanoid 0:3edb3708c8c5 5964 g_MAX5171_device.MODE1_DOUT_SCLK_RISING_EDGE();
whismanoid 11:38b95a59de02 5965 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5966 }
whismanoid 0:3edb3708c8c5 5967 break;
whismanoid 0:3edb3708c8c5 5968 case '8':
whismanoid 0:3edb3708c8c5 5969 {
whismanoid 0:3edb3708c8c5 5970 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5971 //~ cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE");
whismanoid 0:3edb3708c8c5 5972 cmdLine.serial().printf("MODE0_DOUT_SCLK_FALLING_EDGE");
whismanoid 0:3edb3708c8c5 5973 g_MAX5171_device.MODE0_DOUT_SCLK_FALLING_EDGE();
whismanoid 11:38b95a59de02 5974 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5975 }
whismanoid 0:3edb3708c8c5 5976 break;
whismanoid 0:3edb3708c8c5 5977 }
whismanoid 0:3edb3708c8c5 5978 }
whismanoid 0:3edb3708c8c5 5979 break;
whismanoid 0:3edb3708c8c5 5980 case 'a': case 'A':
whismanoid 0:3edb3708c8c5 5981 {
whismanoid 0:3edb3708c8c5 5982 // recommended for hex command codes A0..AF
whismanoid 0:3edb3708c8c5 5983 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5984 {
whismanoid 0:3edb3708c8c5 5985 case 't': case 'T':
whismanoid 0:3edb3708c8c5 5986 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5987 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5988 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5989 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5990 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 0:3edb3708c8c5 5991 return;
whismanoid 0:3edb3708c8c5 5992 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5993 }
whismanoid 0:3edb3708c8c5 5994 }
whismanoid 0:3edb3708c8c5 5995 break;
whismanoid 0:3edb3708c8c5 5996 case 'x': case 'X':
whismanoid 0:3edb3708c8c5 5997 {
whismanoid 0:3edb3708c8c5 5998 }
whismanoid 0:3edb3708c8c5 5999 break;
whismanoid 0:3edb3708c8c5 6000 case 'y': case 'Y':
whismanoid 0:3edb3708c8c5 6001 {
whismanoid 0:3edb3708c8c5 6002 }
whismanoid 0:3edb3708c8c5 6003 break;
whismanoid 0:3edb3708c8c5 6004 case 'z': case 'Z':
whismanoid 0:3edb3708c8c5 6005 {
whismanoid 0:3edb3708c8c5 6006 }
whismanoid 0:3edb3708c8c5 6007 break;
whismanoid 0:3edb3708c8c5 6008 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 0:3edb3708c8c5 6009 {
whismanoid 0:3edb3708c8c5 6010 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 6011 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6012 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6013 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6014 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6015 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6016 }
whismanoid 0:3edb3708c8c5 6017 break;
whismanoid 0:3edb3708c8c5 6018 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 0:3edb3708c8c5 6019 {
whismanoid 0:3edb3708c8c5 6020 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6021 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6022 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6023 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6024 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6025 }
whismanoid 0:3edb3708c8c5 6026 break;
whismanoid 11:38b95a59de02 6027 } // end switch (cmdLine[0])
whismanoid 11:38b95a59de02 6028 return false; // command not handled
whismanoid 11:38b95a59de02 6029 } // end bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 6030 #endif
whismanoid 0:3edb3708c8c5 6031
whismanoid 11:38b95a59de02 6032 //--------------------------------------------------
whismanoid 11:38b95a59de02 6033 #if 0 // APPLICATION_MAX11410 // MAX11410_menu_onEOLcommandParser moved to Test_Menu_MAX11410.cpp
whismanoid 11:38b95a59de02 6034 bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 6035 {
whismanoid 11:38b95a59de02 6036 switch (cmdLine[0])
whismanoid 11:38b95a59de02 6037 {
whismanoid 0:3edb3708c8c5 6038 // TODO1: MAX11410 main_menu_onEOLcommandParser
whismanoid 0:3edb3708c8c5 6039 case '0':
whismanoid 0:3edb3708c8c5 6040 {
whismanoid 0:3edb3708c8c5 6041 // recommended for hex command codes 00..0F
whismanoid 0:3edb3708c8c5 6042 // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn");
whismanoid 0:3edb3708c8c5 6043 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 6044 uint16_t code;
whismanoid 0:3edb3708c8c5 6045 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 6046 {
whismanoid 0:3edb3708c8c5 6047 }
whismanoid 0:3edb3708c8c5 6048 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 6049 {
whismanoid 0:3edb3708c8c5 6050 }
whismanoid 0:3edb3708c8c5 6051 if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG))
whismanoid 0:3edb3708c8c5 6052 {
whismanoid 0:3edb3708c8c5 6053 isUpdatedSPIConfig = true;
whismanoid 0:3edb3708c8c5 6054 }
whismanoid 0:3edb3708c8c5 6055 cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 6056 MAX5715_CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 6057 cmdLine.serial().printf("\r\n placeholder");
whismanoid 11:38b95a59de02 6058 return true; // command was handled by MAX11410
whismanoid 0:3edb3708c8c5 6059 }
whismanoid 0:3edb3708c8c5 6060 break;
whismanoid 0:3edb3708c8c5 6061 case '1':
whismanoid 0:3edb3708c8c5 6062 {
whismanoid 0:3edb3708c8c5 6063 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 6064 }
whismanoid 0:3edb3708c8c5 6065 break;
whismanoid 0:3edb3708c8c5 6066 case '2':
whismanoid 0:3edb3708c8c5 6067 {
whismanoid 0:3edb3708c8c5 6068 // recommended for hex command codes 20..2F
whismanoid 0:3edb3708c8c5 6069 }
whismanoid 0:3edb3708c8c5 6070 break;
whismanoid 0:3edb3708c8c5 6071 case '3':
whismanoid 0:3edb3708c8c5 6072 {
whismanoid 0:3edb3708c8c5 6073 // recommended for hex command codes 30..3F
whismanoid 0:3edb3708c8c5 6074 }
whismanoid 0:3edb3708c8c5 6075 break;
whismanoid 0:3edb3708c8c5 6076 case '4':
whismanoid 0:3edb3708c8c5 6077 {
whismanoid 0:3edb3708c8c5 6078 // recommended for hex command codes 40..4F
whismanoid 0:3edb3708c8c5 6079 }
whismanoid 0:3edb3708c8c5 6080 break;
whismanoid 0:3edb3708c8c5 6081 case '5':
whismanoid 0:3edb3708c8c5 6082 {
whismanoid 0:3edb3708c8c5 6083 // recommended for hex command codes 50..5F
whismanoid 0:3edb3708c8c5 6084 }
whismanoid 0:3edb3708c8c5 6085 break;
whismanoid 0:3edb3708c8c5 6086 case '6':
whismanoid 0:3edb3708c8c5 6087 {
whismanoid 0:3edb3708c8c5 6088 // recommended for hex command codes 60..6F
whismanoid 0:3edb3708c8c5 6089 }
whismanoid 0:3edb3708c8c5 6090 break;
whismanoid 0:3edb3708c8c5 6091 case '7':
whismanoid 0:3edb3708c8c5 6092 {
whismanoid 0:3edb3708c8c5 6093 // recommended for hex command codes 70..7F
whismanoid 0:3edb3708c8c5 6094 }
whismanoid 0:3edb3708c8c5 6095 break;
whismanoid 0:3edb3708c8c5 6096 case '8':
whismanoid 0:3edb3708c8c5 6097 {
whismanoid 0:3edb3708c8c5 6098 // recommended for hex command codes 80..8F
whismanoid 0:3edb3708c8c5 6099 }
whismanoid 0:3edb3708c8c5 6100 break;
whismanoid 0:3edb3708c8c5 6101 case '9':
whismanoid 0:3edb3708c8c5 6102 {
whismanoid 0:3edb3708c8c5 6103 // recommended for hex command codes 90..9F
whismanoid 0:3edb3708c8c5 6104 }
whismanoid 0:3edb3708c8c5 6105 break;
whismanoid 0:3edb3708c8c5 6106 case 'a': case 'A':
whismanoid 0:3edb3708c8c5 6107 {
whismanoid 0:3edb3708c8c5 6108 // recommended for hex command codes A0..AF
whismanoid 0:3edb3708c8c5 6109 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 6110 {
whismanoid 0:3edb3708c8c5 6111 case 't': case 'T':
whismanoid 0:3edb3708c8c5 6112 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6113 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6114 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6115 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6116 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 0:3edb3708c8c5 6117 return;
whismanoid 0:3edb3708c8c5 6118 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6119 }
whismanoid 0:3edb3708c8c5 6120 }
whismanoid 0:3edb3708c8c5 6121 break;
whismanoid 0:3edb3708c8c5 6122 case 'b': case 'B':
whismanoid 0:3edb3708c8c5 6123 {
whismanoid 0:3edb3708c8c5 6124 // recommended for hex command codes B0..BF
whismanoid 0:3edb3708c8c5 6125 }
whismanoid 0:3edb3708c8c5 6126 break;
whismanoid 0:3edb3708c8c5 6127 case 'c': case 'C':
whismanoid 0:3edb3708c8c5 6128 {
whismanoid 0:3edb3708c8c5 6129 // recommended for hex command codes C0..CF
whismanoid 0:3edb3708c8c5 6130 }
whismanoid 0:3edb3708c8c5 6131 break;
whismanoid 0:3edb3708c8c5 6132 case 'd': case 'D':
whismanoid 0:3edb3708c8c5 6133 {
whismanoid 0:3edb3708c8c5 6134 // recommended for hex command codes D0..DF
whismanoid 0:3edb3708c8c5 6135 }
whismanoid 0:3edb3708c8c5 6136 break;
whismanoid 0:3edb3708c8c5 6137 case 'e': case 'E':
whismanoid 0:3edb3708c8c5 6138 {
whismanoid 0:3edb3708c8c5 6139 // recommended for hex command codes E0..EF
whismanoid 0:3edb3708c8c5 6140 }
whismanoid 0:3edb3708c8c5 6141 break;
whismanoid 0:3edb3708c8c5 6142 case 'f': case 'F':
whismanoid 0:3edb3708c8c5 6143 {
whismanoid 0:3edb3708c8c5 6144 // recommended for hex command codes F0..FF
whismanoid 0:3edb3708c8c5 6145 }
whismanoid 0:3edb3708c8c5 6146 break;
whismanoid 0:3edb3708c8c5 6147 case 'x': case 'X':
whismanoid 0:3edb3708c8c5 6148 {
whismanoid 0:3edb3708c8c5 6149 }
whismanoid 0:3edb3708c8c5 6150 break;
whismanoid 0:3edb3708c8c5 6151 case 'y': case 'Y':
whismanoid 0:3edb3708c8c5 6152 {
whismanoid 0:3edb3708c8c5 6153 }
whismanoid 0:3edb3708c8c5 6154 break;
whismanoid 0:3edb3708c8c5 6155 case 'z': case 'Z':
whismanoid 0:3edb3708c8c5 6156 {
whismanoid 0:3edb3708c8c5 6157 }
whismanoid 0:3edb3708c8c5 6158 break;
whismanoid 0:3edb3708c8c5 6159 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 0:3edb3708c8c5 6160 {
whismanoid 0:3edb3708c8c5 6161 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 6162 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6163 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6164 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6165 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6166 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6167 }
whismanoid 0:3edb3708c8c5 6168 break;
whismanoid 0:3edb3708c8c5 6169 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 0:3edb3708c8c5 6170 {
whismanoid 0:3edb3708c8c5 6171 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6172 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6173 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6174 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6175 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6176 }
whismanoid 0:3edb3708c8c5 6177 break;
whismanoid 11:38b95a59de02 6178 } // end switch (cmdLine[0])
whismanoid 11:38b95a59de02 6179 return false; // command not handled
whismanoid 11:38b95a59de02 6180 } // end bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 6181 #endif
whismanoid 0:3edb3708c8c5 6182
whismanoid 0:3edb3708c8c5 6183
whismanoid 11:38b95a59de02 6184 //--------------------------------------------------
whismanoid 16:09f10869b638 6185 #if APPLICATION_MAX12345 // MAX12345_menu_onEOLcommandParser see Test_Menu_MAX12345.cpp
whismanoid 11:38b95a59de02 6186 bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 6187 {
whismanoid 11:38b95a59de02 6188 switch (cmdLine[0])
whismanoid 11:38b95a59de02 6189 {
whismanoid 11:38b95a59de02 6190 // TODO1: MAX12345 main_menu_onEOLcommandParser
whismanoid 0:3edb3708c8c5 6191 case '0':
whismanoid 0:3edb3708c8c5 6192 {
whismanoid 0:3edb3708c8c5 6193 // recommended for hex command codes 00..0F
whismanoid 0:3edb3708c8c5 6194 // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn");
whismanoid 0:3edb3708c8c5 6195 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 6196 uint16_t code;
whismanoid 0:3edb3708c8c5 6197 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 6198 {
whismanoid 0:3edb3708c8c5 6199 }
whismanoid 0:3edb3708c8c5 6200 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 6201 {
whismanoid 0:3edb3708c8c5 6202 }
whismanoid 0:3edb3708c8c5 6203 if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG))
whismanoid 0:3edb3708c8c5 6204 {
whismanoid 0:3edb3708c8c5 6205 isUpdatedSPIConfig = true;
whismanoid 0:3edb3708c8c5 6206 }
whismanoid 0:3edb3708c8c5 6207 cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 6208 MAX5715_CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 6209 cmdLine.serial().printf("\r\n placeholder");
whismanoid 11:38b95a59de02 6210 return true; // command was handled by MAX12345
whismanoid 0:3edb3708c8c5 6211 }
whismanoid 0:3edb3708c8c5 6212 break;
whismanoid 0:3edb3708c8c5 6213 case '1':
whismanoid 0:3edb3708c8c5 6214 {
whismanoid 0:3edb3708c8c5 6215 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 6216 }
whismanoid 0:3edb3708c8c5 6217 break;
whismanoid 0:3edb3708c8c5 6218 case '2':
whismanoid 0:3edb3708c8c5 6219 {
whismanoid 0:3edb3708c8c5 6220 // recommended for hex command codes 20..2F
whismanoid 0:3edb3708c8c5 6221 }
whismanoid 0:3edb3708c8c5 6222 break;
whismanoid 0:3edb3708c8c5 6223 case '3':
whismanoid 0:3edb3708c8c5 6224 {
whismanoid 0:3edb3708c8c5 6225 // recommended for hex command codes 30..3F
whismanoid 0:3edb3708c8c5 6226 }
whismanoid 0:3edb3708c8c5 6227 break;
whismanoid 0:3edb3708c8c5 6228 case '4':
whismanoid 0:3edb3708c8c5 6229 {
whismanoid 0:3edb3708c8c5 6230 // recommended for hex command codes 40..4F
whismanoid 0:3edb3708c8c5 6231 }
whismanoid 0:3edb3708c8c5 6232 break;
whismanoid 0:3edb3708c8c5 6233 case '5':
whismanoid 0:3edb3708c8c5 6234 {
whismanoid 0:3edb3708c8c5 6235 // recommended for hex command codes 50..5F
whismanoid 0:3edb3708c8c5 6236 }
whismanoid 0:3edb3708c8c5 6237 break;
whismanoid 0:3edb3708c8c5 6238 case '6':
whismanoid 0:3edb3708c8c5 6239 {
whismanoid 0:3edb3708c8c5 6240 // recommended for hex command codes 60..6F
whismanoid 0:3edb3708c8c5 6241 }
whismanoid 0:3edb3708c8c5 6242 break;
whismanoid 0:3edb3708c8c5 6243 case '7':
whismanoid 0:3edb3708c8c5 6244 {
whismanoid 0:3edb3708c8c5 6245 // recommended for hex command codes 70..7F
whismanoid 0:3edb3708c8c5 6246 }
whismanoid 0:3edb3708c8c5 6247 break;
whismanoid 0:3edb3708c8c5 6248 case '8':
whismanoid 0:3edb3708c8c5 6249 {
whismanoid 0:3edb3708c8c5 6250 // recommended for hex command codes 80..8F
whismanoid 0:3edb3708c8c5 6251 }
whismanoid 0:3edb3708c8c5 6252 break;
whismanoid 0:3edb3708c8c5 6253 case '9':
whismanoid 0:3edb3708c8c5 6254 {
whismanoid 0:3edb3708c8c5 6255 // recommended for hex command codes 90..9F
whismanoid 0:3edb3708c8c5 6256 }
whismanoid 0:3edb3708c8c5 6257 break;
whismanoid 0:3edb3708c8c5 6258 case 'a': case 'A':
whismanoid 0:3edb3708c8c5 6259 {
whismanoid 0:3edb3708c8c5 6260 // recommended for hex command codes A0..AF
whismanoid 0:3edb3708c8c5 6261 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 6262 {
whismanoid 0:3edb3708c8c5 6263 case 't': case 'T':
whismanoid 0:3edb3708c8c5 6264 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6265 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6266 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6267 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6268 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 0:3edb3708c8c5 6269 return;
whismanoid 0:3edb3708c8c5 6270 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6271 }
whismanoid 0:3edb3708c8c5 6272 }
whismanoid 0:3edb3708c8c5 6273 break;
whismanoid 0:3edb3708c8c5 6274 case 'b': case 'B':
whismanoid 0:3edb3708c8c5 6275 {
whismanoid 0:3edb3708c8c5 6276 // recommended for hex command codes B0..BF
whismanoid 0:3edb3708c8c5 6277 }
whismanoid 0:3edb3708c8c5 6278 break;
whismanoid 0:3edb3708c8c5 6279 case 'c': case 'C':
whismanoid 0:3edb3708c8c5 6280 {
whismanoid 0:3edb3708c8c5 6281 // recommended for hex command codes C0..CF
whismanoid 0:3edb3708c8c5 6282 }
whismanoid 0:3edb3708c8c5 6283 break;
whismanoid 0:3edb3708c8c5 6284 case 'd': case 'D':
whismanoid 0:3edb3708c8c5 6285 {
whismanoid 0:3edb3708c8c5 6286 // recommended for hex command codes D0..DF
whismanoid 0:3edb3708c8c5 6287 }
whismanoid 0:3edb3708c8c5 6288 break;
whismanoid 0:3edb3708c8c5 6289 case 'e': case 'E':
whismanoid 0:3edb3708c8c5 6290 {
whismanoid 0:3edb3708c8c5 6291 // recommended for hex command codes E0..EF
whismanoid 0:3edb3708c8c5 6292 }
whismanoid 0:3edb3708c8c5 6293 break;
whismanoid 0:3edb3708c8c5 6294 case 'f': case 'F':
whismanoid 0:3edb3708c8c5 6295 {
whismanoid 0:3edb3708c8c5 6296 // recommended for hex command codes F0..FF
whismanoid 0:3edb3708c8c5 6297 }
whismanoid 0:3edb3708c8c5 6298 break;
whismanoid 0:3edb3708c8c5 6299 case 'x': case 'X':
whismanoid 0:3edb3708c8c5 6300 {
whismanoid 0:3edb3708c8c5 6301 }
whismanoid 0:3edb3708c8c5 6302 break;
whismanoid 0:3edb3708c8c5 6303 case 'y': case 'Y':
whismanoid 0:3edb3708c8c5 6304 {
whismanoid 0:3edb3708c8c5 6305 }
whismanoid 0:3edb3708c8c5 6306 break;
whismanoid 0:3edb3708c8c5 6307 case 'z': case 'Z':
whismanoid 0:3edb3708c8c5 6308 {
whismanoid 0:3edb3708c8c5 6309 }
whismanoid 0:3edb3708c8c5 6310 break;
whismanoid 0:3edb3708c8c5 6311 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 0:3edb3708c8c5 6312 {
whismanoid 0:3edb3708c8c5 6313 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 6314 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6315 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6316 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6317 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6318 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6319 }
whismanoid 0:3edb3708c8c5 6320 break;
whismanoid 0:3edb3708c8c5 6321 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 0:3edb3708c8c5 6322 {
whismanoid 0:3edb3708c8c5 6323 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6324 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6325 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6326 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6327 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6328 }
whismanoid 0:3edb3708c8c5 6329 break;
whismanoid 11:38b95a59de02 6330 } // end switch (cmdLine[0])
whismanoid 11:38b95a59de02 6331 return false; // command not handled
whismanoid 11:38b95a59de02 6332 } // end bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 6333 #endif
whismanoid 11:38b95a59de02 6334
whismanoid 11:38b95a59de02 6335
whismanoid 11:38b95a59de02 6336 //--------------------------------------------------
whismanoid 11:38b95a59de02 6337 // main menu command-line parser
whismanoid 11:38b95a59de02 6338 // invoked by CmdLine::append(char ch) or CmdLine::idleAppendIfReadable()
whismanoid 11:38b95a59de02 6339 void main_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 6340 {
whismanoid 11:38b95a59de02 6341 // DIAGNOSTIC: print line buffer
whismanoid 11:38b95a59de02 6342 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 11:38b95a59de02 6343 //
whismanoid 11:38b95a59de02 6344 switch (cmdLine[0])
whismanoid 11:38b95a59de02 6345 {
whismanoid 11:38b95a59de02 6346 case '?':
whismanoid 11:38b95a59de02 6347 main_menu_status(cmdLine);
whismanoid 11:38b95a59de02 6348 main_menu_help(cmdLine);
whismanoid 11:38b95a59de02 6349 // print command prompt
whismanoid 11:38b95a59de02 6350 //cmdLine.serial().printf("\r\n>");
whismanoid 11:38b95a59de02 6351 break;
whismanoid 11:38b95a59de02 6352 case '\r': case '\n': // ignore blank line
whismanoid 11:38b95a59de02 6353 case '\0': // ignore empty line
whismanoid 11:38b95a59de02 6354 case '#': // ignore comment line
whismanoid 11:38b95a59de02 6355 // # -- lines beginning with # are comments
whismanoid 11:38b95a59de02 6356 main_menu_status(cmdLine);
whismanoid 11:38b95a59de02 6357 //~ main_menu_help(cmdLine);
whismanoid 11:38b95a59de02 6358 // print command prompt
whismanoid 11:38b95a59de02 6359 //cmdLine.serial().printf("\r\n>");
whismanoid 11:38b95a59de02 6360 break;
whismanoid 11:38b95a59de02 6361 #if ECHO_EOF_ON_EOL
whismanoid 11:38b95a59de02 6362 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 11:38b95a59de02 6363 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 11:38b95a59de02 6364 diagnostic_led_EOF();
whismanoid 11:38b95a59de02 6365 break;
whismanoid 11:38b95a59de02 6366 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 11:38b95a59de02 6367 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 11:38b95a59de02 6368 diagnostic_led_EOF();
whismanoid 11:38b95a59de02 6369 break;
whismanoid 11:38b95a59de02 6370 #endif
whismanoid 11:38b95a59de02 6371 #if APPLICATION_ArduinoPinsMonitor
whismanoid 11:38b95a59de02 6372 case '.':
whismanoid 11:38b95a59de02 6373 {
whismanoid 11:38b95a59de02 6374 // . -- SelfTest
whismanoid 11:38b95a59de02 6375 cmdLine.serial().printf("SelfTest()");
whismanoid 11:38b95a59de02 6376 SelfTest(cmdLine);
whismanoid 11:38b95a59de02 6377 }
whismanoid 11:38b95a59de02 6378 break;
whismanoid 11:38b95a59de02 6379 case '%':
whismanoid 11:38b95a59de02 6380 {
whismanoid 11:38b95a59de02 6381 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 11:38b95a59de02 6382 }
whismanoid 11:38b95a59de02 6383 break; // case '%'
whismanoid 11:38b95a59de02 6384 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 11:38b95a59de02 6385 //
whismanoid 11:38b95a59de02 6386 // Application-specific commands here
whismanoid 11:38b95a59de02 6387 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 11:38b95a59de02 6388 //
whismanoid 11:38b95a59de02 6389 #if APPLICATION_ArduinoPinsMonitor
whismanoid 11:38b95a59de02 6390 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 6391
whismanoid 0:3edb3708c8c5 6392 //
whismanoid 0:3edb3708c8c5 6393 // TODO1: add new commands here
whismanoid 0:3edb3708c8c5 6394 //
whismanoid 0:3edb3708c8c5 6395 default:
whismanoid 11:38b95a59de02 6396 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 11:38b95a59de02 6397 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 11:38b95a59de02 6398 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 11:38b95a59de02 6399 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 11:38b95a59de02 6400 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 11:38b95a59de02 6401 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 11:38b95a59de02 6402 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 11:38b95a59de02 6403 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 11:38b95a59de02 6404 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 11:38b95a59de02 6405 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 11:38b95a59de02 6406 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 11:38b95a59de02 6407 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 11:38b95a59de02 6408 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 11:38b95a59de02 6409 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 11:38b95a59de02 6410 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 11:38b95a59de02 6411 #else
whismanoid 11:38b95a59de02 6412 if (0) // not_handled_by_device_submenu
whismanoid 11:38b95a59de02 6413 #endif
whismanoid 11:38b95a59de02 6414 {
whismanoid 11:38b95a59de02 6415 cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 0:3edb3708c8c5 6416 # if HAS_DAPLINK_SERIAL
whismanoid 11:38b95a59de02 6417 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 11:38b95a59de02 6418 cmdLine.str()[0], cmdLine.str());
whismanoid 0:3edb3708c8c5 6419 # endif // HAS_DAPLINK_SERIAL
whismanoid 11:38b95a59de02 6420 }
whismanoid 0:3edb3708c8c5 6421 } // switch (cmdLine[0])
whismanoid 0:3edb3708c8c5 6422 //
whismanoid 0:3edb3708c8c5 6423 // print command prompt
whismanoid 0:3edb3708c8c5 6424 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 0:3edb3708c8c5 6425 cmdLine.serial().printf("\r\nMAX5715 > ");
whismanoid 0:3edb3708c8c5 6426 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 0:3edb3708c8c5 6427 cmdLine.serial().printf("\r\nMAX11131 > ");
whismanoid 0:3edb3708c8c5 6428 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 0:3edb3708c8c5 6429 cmdLine.serial().printf("\r\nMAX5171 > ");
whismanoid 0:3edb3708c8c5 6430 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 0:3edb3708c8c5 6431 cmdLine.serial().printf("\r\nMAX11410 > ");
whismanoid 0:3edb3708c8c5 6432 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 0:3edb3708c8c5 6433 cmdLine.serial().printf("\r\nMAX12345 > ");
whismanoid 0:3edb3708c8c5 6434 #else
whismanoid 0:3edb3708c8c5 6435 cmdLine.serial().printf("\r\n> ");
whismanoid 0:3edb3708c8c5 6436 #endif
whismanoid 11:38b95a59de02 6437 } // end void main_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 6438
whismanoid 0:3edb3708c8c5 6439 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6440 void InitializeConfiguration()
whismanoid 0:3edb3708c8c5 6441 {
whismanoid 0:3edb3708c8c5 6442
whismanoid 0:3edb3708c8c5 6443 #if APPLICATION_MAX5715 // InitializeConfiguration
whismanoid 0:3edb3708c8c5 6444 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6445 cmdLine_DAPLINKserial.serial().printf("\r\nMAX5715_Init()");
whismanoid 0:3edb3708c8c5 6446 # endif
whismanoid 8:132276960128 6447 cmdLine_serial.serial().printf("\r\nMAX5715_Init()");
whismanoid 0:3edb3708c8c5 6448 int initResult = g_MAX5715_device.Init(); // defined in #include MAX5715.h
whismanoid 0:3edb3708c8c5 6449 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6450 cmdLine_DAPLINKserial.serial().printf("\r\nMAX5715_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6451 # endif
whismanoid 8:132276960128 6452 cmdLine_serial.serial().printf("\r\nMAX5715_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6453 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 6454
whismanoid 0:3edb3708c8c5 6455 #if APPLICATION_MAX11131 // InitializeConfiguration
whismanoid 0:3edb3708c8c5 6456 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6457 cmdLine_DAPLINKserial.serial().printf("\r\nMAX11131_Init()");
whismanoid 0:3edb3708c8c5 6458 # endif
whismanoid 8:132276960128 6459 cmdLine_serial.serial().printf("\r\nMAX11131_Init()");
whismanoid 0:3edb3708c8c5 6460 g_MAX11131_device.Init(); // defined in #include MAX11131.h
whismanoid 0:3edb3708c8c5 6461 #endif // APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 6462
whismanoid 0:3edb3708c8c5 6463 #if APPLICATION_MAX5171 // InitializeConfiguration
whismanoid 0:3edb3708c8c5 6464 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6465 cmdLine_DAPLINKserial.serial().printf("\r\nMAX5171_Init()");
whismanoid 0:3edb3708c8c5 6466 # endif
whismanoid 8:132276960128 6467 cmdLine_serial.serial().printf("\r\nMAX5171_Init()");
whismanoid 0:3edb3708c8c5 6468 int initResult = g_MAX5171_device.Init(); // defined in #include MAX5171.h
whismanoid 0:3edb3708c8c5 6469 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6470 cmdLine_DAPLINKserial.serial().printf("\r\nMAX5171_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6471 # endif
whismanoid 8:132276960128 6472 cmdLine_serial.serial().printf("\r\nMAX5171_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6473 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 6474
whismanoid 0:3edb3708c8c5 6475 #if APPLICATION_MAX11410 // InitializeConfiguration
whismanoid 0:3edb3708c8c5 6476 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6477 cmdLine_DAPLINKserial.serial().printf("\r\nMAX11410_Init()");
whismanoid 0:3edb3708c8c5 6478 # endif
whismanoid 8:132276960128 6479 cmdLine_serial.serial().printf("\r\nMAX11410_Init()");
whismanoid 0:3edb3708c8c5 6480 int initResult = g_MAX11410_device.Init(); // defined in #include MAX11410.h
whismanoid 0:3edb3708c8c5 6481 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6482 cmdLine_DAPLINKserial.serial().printf("\r\nMAX11410_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6483 # endif
whismanoid 8:132276960128 6484 cmdLine_serial.serial().printf("\r\nMAX11410_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6485 #endif // APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 6486
whismanoid 0:3edb3708c8c5 6487 #if APPLICATION_MAX12345 // InitializeConfiguration
whismanoid 0:3edb3708c8c5 6488 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6489 cmdLine_DAPLINKserial.serial().printf("\r\nMAX12345_Init()");
whismanoid 0:3edb3708c8c5 6490 # endif
whismanoid 8:132276960128 6491 cmdLine_serial.serial().printf("\r\nMAX12345_Init()");
whismanoid 16:09f10869b638 6492 int initResult = g_MAX12345_device.Init(); // defined in #include MAX12345.h
whismanoid 0:3edb3708c8c5 6493 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6494 cmdLine_DAPLINKserial.serial().printf("\r\nMAX12345_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6495 # endif
whismanoid 8:132276960128 6496 cmdLine_serial.serial().printf("\r\nMAX12345_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6497 #endif // APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 6498
whismanoid 0:3edb3708c8c5 6499 }
whismanoid 0:3edb3708c8c5 6500
whismanoid 0:3edb3708c8c5 6501 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6502 // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 6503 void diagnostic_led_EOF()
whismanoid 0:3edb3708c8c5 6504 {
whismanoid 0:3edb3708c8c5 6505 #if USE_LEDS
whismanoid 0:3edb3708c8c5 6506 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 6507 // TODO1: mbed-os-5.11: [Warning] 'static osStatus rtos::Thread::wait(uint32_t)' is deprecated: Static methods only affecting current thread cause confusion. Replaced by ThisThread::sleep_for. [since mbed-os-5.10] [-Wdeprecated-declarations]
whismanoid 0:3edb3708c8c5 6508 ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250);
whismanoid 0:3edb3708c8c5 6509 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 6510 ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250);
whismanoid 0:3edb3708c8c5 6511 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 6512 ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250);
whismanoid 0:3edb3708c8c5 6513 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 6514 ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250);
whismanoid 0:3edb3708c8c5 6515 #endif // USE_LEDS
whismanoid 0:3edb3708c8c5 6516 }
whismanoid 0:3edb3708c8c5 6517
whismanoid 0:3edb3708c8c5 6518 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6519 // Support commands that get handled immediately w/o waiting for EOL
whismanoid 0:3edb3708c8c5 6520 // handled as immediate command, do not append to buffer
whismanoid 0:3edb3708c8c5 6521 void on_immediate_0x21() // Unicode (U+0021) ! EXCLAMATION MARK
whismanoid 0:3edb3708c8c5 6522 {
whismanoid 0:3edb3708c8c5 6523 #if USE_LEDS
whismanoid 0:3edb3708c8c5 6524 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 6525 #endif // USE_LEDS
whismanoid 0:3edb3708c8c5 6526 InitializeConfiguration();
whismanoid 0:3edb3708c8c5 6527 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6528 }
whismanoid 0:3edb3708c8c5 6529
whismanoid 0:3edb3708c8c5 6530 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6531 // Support commands that get handled immediately w/o waiting for EOL
whismanoid 0:3edb3708c8c5 6532 // handled as immediate command, do not append to buffer
whismanoid 0:3edb3708c8c5 6533 void on_immediate_0x7b() // Unicode (U+007B) { LEFT CURLY BRACKET
whismanoid 0:3edb3708c8c5 6534 {
whismanoid 0:3edb3708c8c5 6535 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6536 onButton2FallingEdge();
whismanoid 0:3edb3708c8c5 6537 #endif
whismanoid 0:3edb3708c8c5 6538 }
whismanoid 0:3edb3708c8c5 6539
whismanoid 0:3edb3708c8c5 6540 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6541 // Support commands that get handled immediately w/o waiting for EOL
whismanoid 0:3edb3708c8c5 6542 // handled as immediate command, do not append to buffer
whismanoid 0:3edb3708c8c5 6543 void on_immediate_0x7d() // Unicode (U+007D) } RIGHT CURLY BRACKET
whismanoid 0:3edb3708c8c5 6544 {
whismanoid 0:3edb3708c8c5 6545 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6546 onButton1FallingEdge();
whismanoid 0:3edb3708c8c5 6547 #endif
whismanoid 0:3edb3708c8c5 6548 }
whismanoid 0:3edb3708c8c5 6549
whismanoid 0:3edb3708c8c5 6550 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6551 // based on example code: https://os.mbed.com/docs/v5.7/reference/pwmout.html
whismanoid 0:3edb3708c8c5 6552 int main()
whismanoid 0:3edb3708c8c5 6553 {
whismanoid 0:3edb3708c8c5 6554 // Configure serial ports
whismanoid 0:3edb3708c8c5 6555 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 6556 // Note: DAPLINKserial interferes with the timer tick interrupt. Try faster baud rate?
whismanoid 0:3edb3708c8c5 6557 DAPLINKserial.baud(115200); // default 9600 baud
whismanoid 8:132276960128 6558 //serial.baud(9600); // class USBSerial has no baud function
whismanoid 0:3edb3708c8c5 6559 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6560 DAPLINKserial.printf("\r\n\r\nDAPLINK_SERIAL: main() startup\r\n");
whismanoid 0:3edb3708c8c5 6561 # endif
whismanoid 0:3edb3708c8c5 6562 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6563 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 6564 // MAX32625MBED crash if DAPLINKserial.baud(anything other than 9600 baud)
whismanoid 0:3edb3708c8c5 6565 // xxx DAPLINKserial.baud(115200); // default 9600 baud
whismanoid 8:132276960128 6566 //serial.baud(9600); // class USBSerial has no baud function
whismanoid 0:3edb3708c8c5 6567 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6568 DAPLINKserial.printf("\r\n\r\nDAPLINK_SERIAL: main() startup\r\n");
whismanoid 0:3edb3708c8c5 6569 # endif
whismanoid 0:3edb3708c8c5 6570 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6571 #elif defined(TARGET_LPC1768)
whismanoid 8:132276960128 6572 serial.baud(115200); // default 9600 baud
whismanoid 0:3edb3708c8c5 6573 #else
whismanoid 0:3edb3708c8c5 6574 // unknown target
whismanoid 0:3edb3708c8c5 6575 #endif
whismanoid 8:132276960128 6576 cmdLine_serial.clear();
whismanoid 8:132276960128 6577 //~ cmdLine_serial.serial().printf("\r\n cmdLine_serial.serial().printf test\r\n");
whismanoid 8:132276960128 6578 cmdLine_serial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 23:cebc8b06c25e 6579 cmdLine_serial.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 23:cebc8b06c25e 6580 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 8:132276960128 6581 cmdLine_serial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 8:132276960128 6582 cmdLine_serial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 8:132276960128 6583 cmdLine_serial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 0:3edb3708c8c5 6584 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6585 cmdLine_DAPLINKserial.clear();
whismanoid 0:3edb3708c8c5 6586 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 0:3edb3708c8c5 6587 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 0:3edb3708c8c5 6588 /// @todo CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 0:3edb3708c8c5 6589 cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 0:3edb3708c8c5 6590 cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 0:3edb3708c8c5 6591 cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 0:3edb3708c8c5 6592 # endif
whismanoid 0:3edb3708c8c5 6593
whismanoid 0:3edb3708c8c5 6594
whismanoid 0:3edb3708c8c5 6595 print_banner();
whismanoid 0:3edb3708c8c5 6596
whismanoid 0:3edb3708c8c5 6597 //#ifdef SCOPE_TRIG_PIN
whismanoid 0:3edb3708c8c5 6598 // scopePinP12 = 0;
whismanoid 0:3edb3708c8c5 6599 // scopePinP12 = 1;
whismanoid 0:3edb3708c8c5 6600 //#endif // SCOPE_TRIG_PIN
whismanoid 0:3edb3708c8c5 6601
whismanoid 0:3edb3708c8c5 6602 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6603 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 6604 # else
whismanoid 0:3edb3708c8c5 6605 button1.fall(&onButton1FallingEdge);
whismanoid 0:3edb3708c8c5 6606 # endif
whismanoid 0:3edb3708c8c5 6607 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6608 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6609 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 6610 # else
whismanoid 0:3edb3708c8c5 6611 button2.fall(&onButton2FallingEdge);
whismanoid 0:3edb3708c8c5 6612 # endif
whismanoid 0:3edb3708c8c5 6613 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6614
whismanoid 17:c2f46173f6b2 6615 #if defined(TARGET_MAX32630)
whismanoid 17:c2f46173f6b2 6616 // Timer tick needs to be the highest priority (priority 0, the default).
whismanoid 17:c2f46173f6b2 6617 // DAPLINKserial interferes with the timer tick interrupt.
whismanoid 17:c2f46173f6b2 6618 // Lower the priority of the serial port interrupts to avoid disrupting onTimerTick() handler.
whismanoid 17:c2f46173f6b2 6619 NVIC_SetPriority(UART0_IRQn, 2); // reservedBlueToothSerial(P0_1, P0_0) // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6620 NVIC_SetPriority(UART1_IRQn, 2); // DAPLINKserial(P2_1, P2_0) // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6621 NVIC_SetPriority(UART2_IRQn, 2); // reservedSerial(P3_1, P3_0) // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6622 NVIC_SetPriority(UART3_IRQn, 2); // reservedSerial(P5_4, P5_3) // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6623 NVIC_SetPriority(GPIO_P0_IRQn, 2); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6624 NVIC_SetPriority(GPIO_P1_IRQn, 2); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6625 NVIC_SetPriority(GPIO_P2_IRQn, 2); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6626 NVIC_SetPriority(GPIO_P3_IRQn, 2); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6627 NVIC_SetPriority(GPIO_P4_IRQn, 2); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6628 NVIC_SetPriority(GPIO_P5_IRQn, 2); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6629 NVIC_SetPriority(GPIO_P6_IRQn, 2); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6630 NVIC_SetPriority(GPIO_P7_IRQn, 2); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6631 NVIC_SetPriority(GPIO_P8_IRQn, 2); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6632 //~ NVIC_SetPriority(RTC0_IRQn, 0); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6633 //~ NVIC_SetPriority(RTC3_IRQn, 0); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6634 //~ NVIC_SetPriority(US_TIMER_IRQn, 0); // 0=highest priority; 1=lower
whismanoid 17:c2f46173f6b2 6635 #endif
whismanoid 17:c2f46173f6b2 6636
whismanoid 0:3edb3708c8c5 6637 #if HAS_SPI
whismanoid 0:3edb3708c8c5 6638 // spi init
whismanoid 0:3edb3708c8c5 6639 // mode | POL PHA
whismanoid 0:3edb3708c8c5 6640 // -----+--------
whismanoid 0:3edb3708c8c5 6641 // 0 | 0 0
whismanoid 0:3edb3708c8c5 6642 // 1 | 0 1
whismanoid 0:3edb3708c8c5 6643 // 2 | 1 0
whismanoid 0:3edb3708c8c5 6644 // 3 | 1 1
whismanoid 0:3edb3708c8c5 6645 //~ spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 0:3edb3708c8c5 6646 //~ spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 0:3edb3708c8c5 6647 //~ spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 0:3edb3708c8c5 6648 //~ spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 0:3edb3708c8c5 6649 //
whismanoid 0:3edb3708c8c5 6650 //~ spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 0:3edb3708c8c5 6651 //~ spi.frequency(9600000); // int SCLK_Hz=9600000 = 9.6MHz = 96MHz/10
whismanoid 0:3edb3708c8c5 6652 //~ spi.frequency(10666666); // int SCLK_Hz=10666666 = 10.6MHz = 96MHz/9
whismanoid 0:3edb3708c8c5 6653 //~ spi.frequency(12000000); // int SCLK_Hz=12000000 = 12MHz = 96MHz/8
whismanoid 0:3edb3708c8c5 6654 //~ spi.frequency(13714286); // int SCLK_Hz=13714286 = 13.7MHz = 96MHz/7
whismanoid 0:3edb3708c8c5 6655 //~ spi.frequency(16000000); // int SCLK_Hz=16000000 = 16MHz = 96MHz/6
whismanoid 0:3edb3708c8c5 6656 //~ spi.frequency(19200000); // int SCLK_Hz=19200000 = 19.2MHz = 96MHz/5
whismanoid 0:3edb3708c8c5 6657 //~ spi.frequency(24000000); // int SCLK_Hz=24000000 = 24MHz = 96MHz/4
whismanoid 0:3edb3708c8c5 6658 //~ spi.frequency(32000000); // int SCLK_Hz=32000000 = 32MHz = 96MHz/3
whismanoid 0:3edb3708c8c5 6659 //~ spi.frequency(48000000); // int SCLK_Hz=48000000 = 48MHz = 96MHz/2
whismanoid 0:3edb3708c8c5 6660 // unspecified SPI device
whismanoid 0:3edb3708c8c5 6661 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 0:3edb3708c8c5 6662 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 0:3edb3708c8c5 6663 spi_cs = 1;
whismanoid 0:3edb3708c8c5 6664 #endif
whismanoid 0:3edb3708c8c5 6665
whismanoid 0:3edb3708c8c5 6666 #if HAS_I2C
whismanoid 0:3edb3708c8c5 6667 // i2c init
whismanoid 0:3edb3708c8c5 6668 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 0:3edb3708c8c5 6669 // i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 0:3edb3708c8c5 6670 #else
whismanoid 0:3edb3708c8c5 6671 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:3edb3708c8c5 6672 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 6673 // DigitalInOut digitalInOut14(P1_6, PIN_INPUT, PullUp, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 6674 digitalInOut14.input();
whismanoid 0:3edb3708c8c5 6675 #endif
whismanoid 0:3edb3708c8c5 6676 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 6677 // DigitalInOut digitalInOut15(P1_7, PIN_INPUT, PullUp, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 6678 digitalInOut15.input();
whismanoid 0:3edb3708c8c5 6679 #endif
whismanoid 0:3edb3708c8c5 6680 #if HAS_digitalInOut16
whismanoid 0:3edb3708c8c5 6681 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:3edb3708c8c5 6682 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:3edb3708c8c5 6683 //DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 6684 digitalInOut16.input();
whismanoid 0:3edb3708c8c5 6685 #endif
whismanoid 0:3edb3708c8c5 6686 #if HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 6687 //DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 6688 digitalInOut17.input();
whismanoid 0:3edb3708c8c5 6689 #endif
whismanoid 0:3edb3708c8c5 6690 #endif
whismanoid 0:3edb3708c8c5 6691
whismanoid 0:3edb3708c8c5 6692 #if USE_LEDS
whismanoid 0:3edb3708c8c5 6693 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 6694 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 0:3edb3708c8c5 6695 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6696 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 6697 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6698 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 6699 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6700 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 0:3edb3708c8c5 6701 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6702 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 0:3edb3708c8c5 6703 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6704 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 0:3edb3708c8c5 6705 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6706 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 6707 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6708 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 0:3edb3708c8c5 6709 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6710 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 6711 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 0:3edb3708c8c5 6712 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6713 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 6714 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6715 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 6716 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6717 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 0:3edb3708c8c5 6718 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6719 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 0:3edb3708c8c5 6720 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6721 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 0:3edb3708c8c5 6722 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6723 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 6724 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6725 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 0:3edb3708c8c5 6726 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6727 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:3edb3708c8c5 6728 led1 = LED_ON;
whismanoid 0:3edb3708c8c5 6729 led2 = LED_OFF;
whismanoid 0:3edb3708c8c5 6730 led3 = LED_OFF;
whismanoid 0:3edb3708c8c5 6731 led4 = LED_OFF;
whismanoid 0:3edb3708c8c5 6732 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 0:3edb3708c8c5 6733 //led1 = LED_ON;
whismanoid 0:3edb3708c8c5 6734 led2 = LED_ON;
whismanoid 0:3edb3708c8c5 6735 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 0:3edb3708c8c5 6736 led1 = LED_OFF;
whismanoid 0:3edb3708c8c5 6737 //led2 = LED_ON;
whismanoid 0:3edb3708c8c5 6738 led3 = LED_ON;
whismanoid 0:3edb3708c8c5 6739 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 0:3edb3708c8c5 6740 led2 = LED_OFF;
whismanoid 0:3edb3708c8c5 6741 //led3 = LED_ON;
whismanoid 0:3edb3708c8c5 6742 led4 = LED_ON;
whismanoid 0:3edb3708c8c5 6743 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 0:3edb3708c8c5 6744 led3 = LED_OFF;
whismanoid 0:3edb3708c8c5 6745 led4 = LED_ON;
whismanoid 0:3edb3708c8c5 6746 //
whismanoid 0:3edb3708c8c5 6747 #endif // target definition
whismanoid 0:3edb3708c8c5 6748 #endif
whismanoid 0:3edb3708c8c5 6749
whismanoid 0:3edb3708c8c5 6750 // cmd_TE();
whismanoid 0:3edb3708c8c5 6751
whismanoid 0:3edb3708c8c5 6752 #if USE_LEDS
whismanoid 0:3edb3708c8c5 6753 rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 0:3edb3708c8c5 6754 #endif // USE_LEDS
whismanoid 0:3edb3708c8c5 6755 InitializeConfiguration();
whismanoid 0:3edb3708c8c5 6756
whismanoid 0:3edb3708c8c5 6757 while (1) {
whismanoid 0:3edb3708c8c5 6758 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 6759 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 0:3edb3708c8c5 6760 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 0:3edb3708c8c5 6761 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6762 static int button1_value_prev = 1;
whismanoid 0:3edb3708c8c5 6763 static int button1_value_now = 1;
whismanoid 0:3edb3708c8c5 6764 button1_value_prev = button1_value_now;
whismanoid 0:3edb3708c8c5 6765 button1_value_now = button1.read();
whismanoid 0:3edb3708c8c5 6766 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 0:3edb3708c8c5 6767 {
whismanoid 0:3edb3708c8c5 6768 // on button1 falling edge (button1 press)
whismanoid 0:3edb3708c8c5 6769 onButton1FallingEdge();
whismanoid 0:3edb3708c8c5 6770 }
whismanoid 0:3edb3708c8c5 6771 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6772 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6773 static int button2_value_prev = 1;
whismanoid 0:3edb3708c8c5 6774 static int button2_value_now = 1;
whismanoid 0:3edb3708c8c5 6775 button2_value_prev = button2_value_now;
whismanoid 0:3edb3708c8c5 6776 button2_value_now = button2.read();
whismanoid 0:3edb3708c8c5 6777 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 0:3edb3708c8c5 6778 {
whismanoid 0:3edb3708c8c5 6779 // on button2 falling edge (button2 press)
whismanoid 0:3edb3708c8c5 6780 onButton2FallingEdge();
whismanoid 0:3edb3708c8c5 6781 }
whismanoid 0:3edb3708c8c5 6782 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6783 #endif
whismanoid 0:3edb3708c8c5 6784 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6785 if (DAPLINKserial.readable()) {
whismanoid 0:3edb3708c8c5 6786 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 0:3edb3708c8c5 6787 }
whismanoid 0:3edb3708c8c5 6788 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:132276960128 6789 if (serial.readable()) {
whismanoid 8:132276960128 6790 int c = serial.getc();
whismanoid 8:132276960128 6791 cmdLine_serial.append(c);
whismanoid 0:3edb3708c8c5 6792 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6793 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6794 cmdLine_DAPLINKserial.serial().printf("%c", c);
whismanoid 0:3edb3708c8c5 6795 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6796 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6797 //
whismanoid 0:3edb3708c8c5 6798 }
whismanoid 0:3edb3708c8c5 6799 } // while(1)
whismanoid 0:3edb3708c8c5 6800 }