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

Dependencies:   MaximTinyTester CmdLine MAX541 MAX5715 USBDevice

Committer:
whismanoid
Date:
Sun Jul 14 03:16:54 2019 +0000
Revision:
14:cbe972986136
Parent:
13:e36d51f46794
Child:
15:2c21eaa9188b
Workaround MAX32630FTHR issue with SPI mode2, mode3

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 13:e36d51f46794 40 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 13:e36d51f46794 41 // - MAX32600MBED
whismanoid 0:3edb3708c8c5 42 // - NUCLEO_F446RE
whismanoid 13:e36d51f46794 43 // - remove USBDevice library
whismanoid 0:3edb3708c8c5 44 // - NUCLEO_F401RE
whismanoid 13:e36d51f46794 45 // - remove USBDevice library
whismanoid 13:e36d51f46794 46 // - MAX32630FTHR
whismanoid 13:e36d51f46794 47 // - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 0:3edb3708c8c5 48
whismanoid 0:3edb3708c8c5 49 #include "mbed.h"
whismanoid 0:3edb3708c8c5 50 #if defined(TARGET)
whismanoid 0:3edb3708c8c5 51 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 0:3edb3708c8c5 52 // Create a string definition for the TARGET
whismanoid 0:3edb3708c8c5 53 #define STRING_ARG(arg) #arg
whismanoid 0:3edb3708c8c5 54 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 0:3edb3708c8c5 55 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 11:9fa2402071de 56 #elif defined(TARGET_MAX32600)
whismanoid 11:9fa2402071de 57 #define TARGET_NAME "MAX32600"
whismanoid 0:3edb3708c8c5 58 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 59 #define TARGET_NAME "LPC1768"
whismanoid 0:3edb3708c8c5 60 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 61 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 0:3edb3708c8c5 62 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 63 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 0:3edb3708c8c5 64 #else
whismanoid 0:3edb3708c8c5 65 #error TARGET NOT DEFINED
whismanoid 0:3edb3708c8c5 66 #endif
whismanoid 0:3edb3708c8c5 67 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 68 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 69 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 0:3edb3708c8c5 70 // +-------------[microUSB]-------------+
whismanoid 0:3edb3708c8c5 71 // | J1 MAX32630FTHR J2 |
whismanoid 0:3edb3708c8c5 72 // ______ | [ ] RST GND [ ] |
whismanoid 0:3edb3708c8c5 73 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 0:3edb3708c8c5 74 // ______ | [ ] 1V8 reset SW1 |
whismanoid 0:3edb3708c8c5 75 // ______ | [ ] GND J4 J3 |
whismanoid 0:3edb3708c8c5 76 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 0:3edb3708c8c5 77 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 0:3edb3708c8c5 78 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 13:e36d51f46794 79 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 13:e36d51f46794 80 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 13:e36d51f46794 81 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 13:e36d51f46794 82 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 13:e36d51f46794 83 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 13:e36d51f46794 84 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 13:e36d51f46794 85 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 13:e36d51f46794 86 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 13:e36d51f46794 87 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 0:3edb3708c8c5 88 // | |
whismanoid 0:3edb3708c8c5 89 // | XIP Flash MAX14690N |
whismanoid 0:3edb3708c8c5 90 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 0:3edb3708c8c5 91 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 0:3edb3708c8c5 92 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 0:3edb3708c8c5 93 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 0:3edb3708c8c5 94 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 0:3edb3708c8c5 95 // | XIP_DIO3 P1_5 |
whismanoid 0:3edb3708c8c5 96 // | |
whismanoid 0:3edb3708c8c5 97 // | PAN1326B MicroSD LED |
whismanoid 0:3edb3708c8c5 98 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 0:3edb3708c8c5 99 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 0:3edb3708c8c5 100 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 0:3edb3708c8c5 101 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 0:3edb3708c8c5 102 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 0:3edb3708c8c5 103 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 0:3edb3708c8c5 104 // +------------------------------------+
whismanoid 0:3edb3708c8c5 105 // 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 106 // 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 107 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 108 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 109 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 110 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 111 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 112 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 113 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 114 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 115 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 116 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:3edb3708c8c5 117 // AIN_10 = x undefined?
whismanoid 0:3edb3708c8c5 118 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 119 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 120 //
whismanoid 0:3edb3708c8c5 121 #include "max32630fthr.h"
whismanoid 0:3edb3708c8c5 122 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:3edb3708c8c5 123 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:3edb3708c8c5 124 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:3edb3708c8c5 125 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 13:e36d51f46794 126 // Arduino connector
whismanoid 13:e36d51f46794 127 #ifndef A0
whismanoid 13:e36d51f46794 128 #define A0 AIN_0
whismanoid 13:e36d51f46794 129 #endif
whismanoid 13:e36d51f46794 130 #ifndef A1
whismanoid 13:e36d51f46794 131 #define A1 AIN_1
whismanoid 13:e36d51f46794 132 #endif
whismanoid 13:e36d51f46794 133 #ifndef A2
whismanoid 13:e36d51f46794 134 #define A2 AIN_2
whismanoid 13:e36d51f46794 135 #endif
whismanoid 13:e36d51f46794 136 #ifndef A3
whismanoid 13:e36d51f46794 137 #define A3 AIN_3
whismanoid 13:e36d51f46794 138 #endif
whismanoid 13:e36d51f46794 139 #ifndef D0
whismanoid 13:e36d51f46794 140 #define D0 P4_0
whismanoid 13:e36d51f46794 141 #endif
whismanoid 13:e36d51f46794 142 #ifndef D1
whismanoid 13:e36d51f46794 143 #define D1 P5_6
whismanoid 13:e36d51f46794 144 #endif
whismanoid 13:e36d51f46794 145 #ifndef D2
whismanoid 13:e36d51f46794 146 #define D2 P5_5
whismanoid 13:e36d51f46794 147 #endif
whismanoid 13:e36d51f46794 148 #ifndef D3
whismanoid 13:e36d51f46794 149 #define D3 P5_4
whismanoid 13:e36d51f46794 150 #endif
whismanoid 13:e36d51f46794 151 #ifndef D4
whismanoid 13:e36d51f46794 152 #define D4 P5_3
whismanoid 13:e36d51f46794 153 #endif
whismanoid 13:e36d51f46794 154 #ifndef D5
whismanoid 13:e36d51f46794 155 #define D5 P3_3
whismanoid 13:e36d51f46794 156 #endif
whismanoid 13:e36d51f46794 157 #ifndef D6
whismanoid 13:e36d51f46794 158 #define D6 P3_2
whismanoid 13:e36d51f46794 159 #endif
whismanoid 13:e36d51f46794 160 #ifndef D7
whismanoid 13:e36d51f46794 161 #define D7 P3_5
whismanoid 13:e36d51f46794 162 #endif
whismanoid 13:e36d51f46794 163 #ifndef D8
whismanoid 13:e36d51f46794 164 #define D8 P3_4
whismanoid 13:e36d51f46794 165 #endif
whismanoid 13:e36d51f46794 166 #ifndef D9
whismanoid 13:e36d51f46794 167 #define D9 P3_1
whismanoid 13:e36d51f46794 168 #endif
whismanoid 13:e36d51f46794 169 #ifndef D10
whismanoid 13:e36d51f46794 170 #define D10 P3_0
whismanoid 13:e36d51f46794 171 #endif
whismanoid 13:e36d51f46794 172 #ifndef D11
whismanoid 13:e36d51f46794 173 #define D11 P5_1
whismanoid 13:e36d51f46794 174 #endif
whismanoid 13:e36d51f46794 175 #ifndef D12
whismanoid 13:e36d51f46794 176 #define D12 P5_2
whismanoid 13:e36d51f46794 177 #endif
whismanoid 13:e36d51f46794 178 #ifndef D13
whismanoid 13:e36d51f46794 179 #define D13 P5_0
whismanoid 13:e36d51f46794 180 #endif
whismanoid 0:3edb3708c8c5 181 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 182 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 183 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 184 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:3edb3708c8c5 185 // +-------------------------------------+
whismanoid 0:3edb3708c8c5 186 // | MAX32625MBED Arduino UNO header |
whismanoid 0:3edb3708c8c5 187 // | |
whismanoid 0:3edb3708c8c5 188 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:3edb3708c8c5 189 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:3edb3708c8c5 190 // | AREF=N/C[ ] |
whismanoid 0:3edb3708c8c5 191 // | GND[ ] |
whismanoid 0:3edb3708c8c5 192 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:3edb3708c8c5 193 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:3edb3708c8c5 194 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:3edb3708c8c5 195 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:3edb3708c8c5 196 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:3edb3708c8c5 197 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:3edb3708c8c5 198 // | [ ]GND |
whismanoid 0:3edb3708c8c5 199 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:3edb3708c8c5 200 // | 6[ ]~| P0_6 dig6
whismanoid 0:3edb3708c8c5 201 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:3edb3708c8c5 202 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:3edb3708c8c5 203 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:3edb3708c8c5 204 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:3edb3708c8c5 205 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:3edb3708c8c5 206 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:3edb3708c8c5 207 // | [ ] [ ] [ ] |
whismanoid 0:3edb3708c8c5 208 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:3edb3708c8c5 209 // \_______________________/
whismanoid 0:3edb3708c8c5 210 //
whismanoid 0:3edb3708c8c5 211 // +------------------------+
whismanoid 0:3edb3708c8c5 212 // | |
whismanoid 0:3edb3708c8c5 213 // | MicroSD LED |
whismanoid 0:3edb3708c8c5 214 // | SD_SCLK P2_4 r P3_0 |
whismanoid 0:3edb3708c8c5 215 // | SD_MOSI P2_5 g P3_1 |
whismanoid 0:3edb3708c8c5 216 // | SD_MISO P2_6 b P3_2 |
whismanoid 0:3edb3708c8c5 217 // | SD_SSEL P2_7 y P3_3 |
whismanoid 0:3edb3708c8c5 218 // | |
whismanoid 0:3edb3708c8c5 219 // | DAPLINK BUTTONS |
whismanoid 0:3edb3708c8c5 220 // | TX P2_1 SW3 P2_3 |
whismanoid 0:3edb3708c8c5 221 // | RX P2_0 SW2 P2_2 |
whismanoid 0:3edb3708c8c5 222 // +------------------------+
whismanoid 0:3edb3708c8c5 223 //
whismanoid 0:3edb3708c8c5 224 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 225 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 226 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 227 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 228 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 229 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 230 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 231 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 232 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 233 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:3edb3708c8c5 234 // AIN_10 = x undefined?
whismanoid 0:3edb3708c8c5 235 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 236 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 237 //
whismanoid 0:3edb3708c8c5 238 //#include "max32625mbed.h" // ?
whismanoid 0:3edb3708c8c5 239 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 0:3edb3708c8c5 240 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:3edb3708c8c5 241 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:3edb3708c8c5 242 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:3edb3708c8c5 243 // Arduino connector
whismanoid 0:3edb3708c8c5 244 #ifndef A0
whismanoid 0:3edb3708c8c5 245 #define A0 AIN_0
whismanoid 0:3edb3708c8c5 246 #endif
whismanoid 0:3edb3708c8c5 247 #ifndef A1
whismanoid 0:3edb3708c8c5 248 #define A1 AIN_1
whismanoid 0:3edb3708c8c5 249 #endif
whismanoid 0:3edb3708c8c5 250 #ifndef A2
whismanoid 0:3edb3708c8c5 251 #define A2 AIN_2
whismanoid 0:3edb3708c8c5 252 #endif
whismanoid 0:3edb3708c8c5 253 #ifndef A3
whismanoid 0:3edb3708c8c5 254 #define A3 AIN_3
whismanoid 0:3edb3708c8c5 255 #endif
whismanoid 0:3edb3708c8c5 256 #ifndef D0
whismanoid 0:3edb3708c8c5 257 #define D0 P0_0
whismanoid 0:3edb3708c8c5 258 #endif
whismanoid 0:3edb3708c8c5 259 #ifndef D1
whismanoid 0:3edb3708c8c5 260 #define D1 P0_1
whismanoid 0:3edb3708c8c5 261 #endif
whismanoid 0:3edb3708c8c5 262 #ifndef D2
whismanoid 0:3edb3708c8c5 263 #define D2 P0_2
whismanoid 0:3edb3708c8c5 264 #endif
whismanoid 0:3edb3708c8c5 265 #ifndef D3
whismanoid 0:3edb3708c8c5 266 #define D3 P0_3
whismanoid 0:3edb3708c8c5 267 #endif
whismanoid 0:3edb3708c8c5 268 #ifndef D4
whismanoid 0:3edb3708c8c5 269 #define D4 P0_4
whismanoid 0:3edb3708c8c5 270 #endif
whismanoid 0:3edb3708c8c5 271 #ifndef D5
whismanoid 0:3edb3708c8c5 272 #define D5 P0_5
whismanoid 0:3edb3708c8c5 273 #endif
whismanoid 0:3edb3708c8c5 274 #ifndef D6
whismanoid 0:3edb3708c8c5 275 #define D6 P0_6
whismanoid 0:3edb3708c8c5 276 #endif
whismanoid 0:3edb3708c8c5 277 #ifndef D7
whismanoid 0:3edb3708c8c5 278 #define D7 P0_7
whismanoid 0:3edb3708c8c5 279 #endif
whismanoid 0:3edb3708c8c5 280 #ifndef D8
whismanoid 0:3edb3708c8c5 281 #define D8 P1_4
whismanoid 0:3edb3708c8c5 282 #endif
whismanoid 0:3edb3708c8c5 283 #ifndef D9
whismanoid 0:3edb3708c8c5 284 #define D9 P1_5
whismanoid 0:3edb3708c8c5 285 #endif
whismanoid 0:3edb3708c8c5 286 #ifndef D10
whismanoid 0:3edb3708c8c5 287 #define D10 P1_3
whismanoid 0:3edb3708c8c5 288 #endif
whismanoid 0:3edb3708c8c5 289 #ifndef D11
whismanoid 0:3edb3708c8c5 290 #define D11 P1_1
whismanoid 0:3edb3708c8c5 291 #endif
whismanoid 0:3edb3708c8c5 292 #ifndef D12
whismanoid 0:3edb3708c8c5 293 #define D12 P1_2
whismanoid 0:3edb3708c8c5 294 #endif
whismanoid 0:3edb3708c8c5 295 #ifndef D13
whismanoid 0:3edb3708c8c5 296 #define D13 P1_0
whismanoid 0:3edb3708c8c5 297 #endif
whismanoid 0:3edb3708c8c5 298 //--------------------------------------------------
whismanoid 11:9fa2402071de 299 #elif defined(TARGET_MAX32600)
whismanoid 11:9fa2402071de 300 // target MAX32600
whismanoid 11:9fa2402071de 301 //
whismanoid 11:9fa2402071de 302 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 11:9fa2402071de 303 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 11:9fa2402071de 304 //
whismanoid 11:9fa2402071de 305 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 306 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 307 // TODO1: target NUCLEO_F446RE
whismanoid 0:3edb3708c8c5 308 //
whismanoid 0:3edb3708c8c5 309 // USER_BUTTON PC13
whismanoid 0:3edb3708c8c5 310 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 0:3edb3708c8c5 311 #define USE_LEDS 0
whismanoid 0:3edb3708c8c5 312 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 7:bf501f8cb637 313 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 0:3edb3708c8c5 314 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:3edb3708c8c5 315 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:3edb3708c8c5 316 //
whismanoid 0:3edb3708c8c5 317 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 318 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 319 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 320 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 0:3edb3708c8c5 321 // +-------------[microUSB]-------------+
whismanoid 0:3edb3708c8c5 322 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 0:3edb3708c8c5 323 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 0:3edb3708c8c5 324 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 0:3edb3708c8c5 325 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 0:3edb3708c8c5 326 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 0:3edb3708c8c5 327 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 0:3edb3708c8c5 328 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 0:3edb3708c8c5 329 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 0:3edb3708c8c5 330 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 0:3edb3708c8c5 331 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 0:3edb3708c8c5 332 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 0:3edb3708c8c5 333 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 0:3edb3708c8c5 334 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 0:3edb3708c8c5 335 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 0:3edb3708c8c5 336 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 0:3edb3708c8c5 337 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 0:3edb3708c8c5 338 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 0:3edb3708c8c5 339 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 0:3edb3708c8c5 340 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 0:3edb3708c8c5 341 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 0:3edb3708c8c5 342 // +------------------------------------+
whismanoid 0:3edb3708c8c5 343 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 0:3edb3708c8c5 344 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 0:3edb3708c8c5 345 //
whismanoid 0:3edb3708c8c5 346 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 347 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 0:3edb3708c8c5 348 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:3edb3708c8c5 349 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 0:3edb3708c8c5 350 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:3edb3708c8c5 351 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 352 // unknown target
whismanoid 0:3edb3708c8c5 353 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 354 #endif // target definition
whismanoid 0:3edb3708c8c5 355
whismanoid 0:3edb3708c8c5 356
whismanoid 0:3edb3708c8c5 357 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 358 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 0:3edb3708c8c5 359 #ifndef APPLICATION_ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 360 #define APPLICATION_ArduinoPinsMonitor 1
whismanoid 0:3edb3708c8c5 361 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 362
whismanoid 0:3edb3708c8c5 363 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 364 // Support MAX5715BOB Breakout Board
whismanoid 0:3edb3708c8c5 365 #ifndef APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 366 #define APPLICATION_MAX5715 1
whismanoid 0:3edb3708c8c5 367 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 368 #if APPLICATION_MAX5715 // header file
whismanoid 0:3edb3708c8c5 369 #include "MAX5715.h"
whismanoid 0:3edb3708c8c5 370 // suppress the I2C diagnostics, not relevant to this chip
whismanoid 0:3edb3708c8c5 371 #define HAS_I2C 0
whismanoid 0:3edb3708c8c5 372 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 373
whismanoid 0:3edb3708c8c5 374 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 375 // Support MAX11131BOB Breakout Board
whismanoid 0:3edb3708c8c5 376 #ifndef APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 377 #define APPLICATION_MAX11131 0
whismanoid 0:3edb3708c8c5 378 #endif // APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 379 #if APPLICATION_MAX11131 // header file
whismanoid 0:3edb3708c8c5 380 #include "MAX11131.h"
whismanoid 0:3edb3708c8c5 381 // suppress the I2C diagnostics, not relevant to this chip
whismanoid 0:3edb3708c8c5 382 #define HAS_I2C 0
whismanoid 0:3edb3708c8c5 383 #endif // APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 384
whismanoid 0:3edb3708c8c5 385 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 386 // Support MAX5171BOB Breakout Board
whismanoid 0:3edb3708c8c5 387 #ifndef APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 388 #define APPLICATION_MAX5171 0
whismanoid 0:3edb3708c8c5 389 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 390 #if APPLICATION_MAX5171 // header file
whismanoid 0:3edb3708c8c5 391 #include "MAX5171.h"
whismanoid 0:3edb3708c8c5 392 // suppress the I2C diagnostics, not relevant to this chip
whismanoid 0:3edb3708c8c5 393 #define HAS_I2C 0
whismanoid 0:3edb3708c8c5 394 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 395
whismanoid 0:3edb3708c8c5 396 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 397 // Support MAX11410BOB Breakout Board (placeholder)
whismanoid 0:3edb3708c8c5 398 #ifndef APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 399 #define APPLICATION_MAX11410 0
whismanoid 0:3edb3708c8c5 400 #endif // APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 401 #if APPLICATION_MAX11410 // header file
whismanoid 0:3edb3708c8c5 402 #include "MAX11410.h"
whismanoid 0:3edb3708c8c5 403 #endif // APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 404
whismanoid 0:3edb3708c8c5 405 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 406 // Support MAX12345BOB Breakout Board (placeholder)
whismanoid 0:3edb3708c8c5 407 #ifndef APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 408 #define APPLICATION_MAX12345 0
whismanoid 0:3edb3708c8c5 409 #endif // APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 410 #if APPLICATION_MAX12345 // header file
whismanoid 0:3edb3708c8c5 411 #include "MAX12345.h"
whismanoid 0:3edb3708c8c5 412 #endif // APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 413
whismanoid 0:3edb3708c8c5 414
whismanoid 0:3edb3708c8c5 415 #include "MAX541.h"
whismanoid 0:3edb3708c8c5 416
whismanoid 0:3edb3708c8c5 417 #include "MaximTinyTester.h"
whismanoid 0:3edb3708c8c5 418
whismanoid 0:3edb3708c8c5 419 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 420 // Option to dedicate SPI port pins
whismanoid 0:3edb3708c8c5 421 //
whismanoid 0:3edb3708c8c5 422 // SPI2_MOSI = P5_1
whismanoid 0:3edb3708c8c5 423 // SPI2_MISO = P5_2
whismanoid 0:3edb3708c8c5 424 // SPI2_SCK = P5_0
whismanoid 0:3edb3708c8c5 425 // On this board I'm using P3_0 as spi_cs
whismanoid 0:3edb3708c8c5 426 // SPI2_SS = P5_3
whismanoid 0:3edb3708c8c5 427 // SPI2_SDIO2 = P5_4
whismanoid 0:3edb3708c8c5 428 // SPI2_SDIO3 = P5_5
whismanoid 0:3edb3708c8c5 429 // SPI2_SRN = P5_6
whismanoid 0:3edb3708c8c5 430 //
whismanoid 0:3edb3708c8c5 431 #ifndef HAS_SPI
whismanoid 0:3edb3708c8c5 432 #define HAS_SPI 1
whismanoid 0:3edb3708c8c5 433 #endif
whismanoid 0:3edb3708c8c5 434 #if HAS_SPI
whismanoid 0:3edb3708c8c5 435 #define SPI_MODE0 0
whismanoid 0:3edb3708c8c5 436 #define SPI_MODE1 1
whismanoid 0:3edb3708c8c5 437 #define SPI_MODE2 2
whismanoid 0:3edb3708c8c5 438 #define SPI_MODE3 3
whismanoid 0:3edb3708c8c5 439 //
whismanoid 0:3edb3708c8c5 440 // Define application-specific default SPI_SCLK_Hz and SPI_dataMode
whismanoid 0:3edb3708c8c5 441 #if APPLICATION_MAX5715 // SPI interface default settings
whismanoid 0:3edb3708c8c5 442 //
whismanoid 0:3edb3708c8c5 443 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 444 //#define SPI_SCLK_Hz 24000000 // 24MHz
whismanoid 0:3edb3708c8c5 445 #define SPI_SCLK_Hz 12000000 // 12MHz
whismanoid 0:3edb3708c8c5 446 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 447 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 448 //#define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 449 #define SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 450 //
whismanoid 0:3edb3708c8c5 451 #elif APPLICATION_MAX11131 // SPI interface default settings
whismanoid 0:3edb3708c8c5 452 //
whismanoid 0:3edb3708c8c5 453 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 454 //#define SPI_SCLK_Hz 24000000 // 24MHz
whismanoid 0:3edb3708c8c5 455 #define SPI_SCLK_Hz 12000000 // 12MHz
whismanoid 0:3edb3708c8c5 456 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 457 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 458 //#define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 459 #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 460 //
whismanoid 0:3edb3708c8c5 461 #elif APPLICATION_MAX5171 // SPI interface default settings
whismanoid 0:3edb3708c8c5 462 //
whismanoid 0:3edb3708c8c5 463 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 464 //#define SPI_SCLK_Hz 24000000 // 24MHz
whismanoid 0:3edb3708c8c5 465 #define SPI_SCLK_Hz 12000000 // 12MHz
whismanoid 0:3edb3708c8c5 466 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 467 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 468 //#define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 469 #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 470 //
whismanoid 0:3edb3708c8c5 471 #elif APPLICATION_MAX11410 // SPI interface default settings
whismanoid 0:3edb3708c8c5 472 //
whismanoid 0:3edb3708c8c5 473 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 474 //#define SPI_SCLK_Hz 24000000 // 24MHz
whismanoid 0:3edb3708c8c5 475 //#define SPI_SCLK_Hz 12000000 // 12MHz
whismanoid 0:3edb3708c8c5 476 #define SPI_SCLK_Hz 8000000 // 8MHz
whismanoid 0:3edb3708c8c5 477 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 478 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 479 //#define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 480 #define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Falling Edge stable; SCLK idle Low
whismanoid 0:3edb3708c8c5 481 //
whismanoid 0:3edb3708c8c5 482 #elif APPLICATION_MAX12345 // SPI interface default settings
whismanoid 0:3edb3708c8c5 483 //
whismanoid 0:3edb3708c8c5 484 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 485 //#define SPI_SCLK_Hz 24000000 // 24MHz
whismanoid 0:3edb3708c8c5 486 #define SPI_SCLK_Hz 12000000 // 12MHz
whismanoid 0:3edb3708c8c5 487 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 488 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 489 //#define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 490 #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 491 //
whismanoid 0:3edb3708c8c5 492 #else // APPLICATION_ArduinoPinsMonitor diagnostic
whismanoid 0:3edb3708c8c5 493 //
whismanoid 0:3edb3708c8c5 494 //#define SPI_SCLK_Hz 48000000 // 48MHz
whismanoid 0:3edb3708c8c5 495 //#define SPI_SCLK_Hz 4000000 // 4MHz
whismanoid 0:3edb3708c8c5 496 //#define SPI_SCLK_Hz 2000000 // 2MHz
whismanoid 0:3edb3708c8c5 497 #define SPI_SCLK_Hz 1000000 // 1MHz
whismanoid 0:3edb3708c8c5 498 //#define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low
whismanoid 0:3edb3708c8c5 499 //#define SPI_dataMode SPI_MODE1 // CPOL=0,CPHA=1: Falling Edge stable; SCLK idle Low
whismanoid 0:3edb3708c8c5 500 //#define SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 501 #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 0:3edb3708c8c5 502 //
whismanoid 0:3edb3708c8c5 503 #endif
whismanoid 0:3edb3708c8c5 504 //
whismanoid 14:cbe972986136 505 #if defined(TARGET_MAX32630)
whismanoid 14:cbe972986136 506 // Before setting global variables g_SPI_SCLK_Hz and g_SPI_dataMode,
whismanoid 14:cbe972986136 507 // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem (issue #30)
whismanoid 14:cbe972986136 508 #warning "MAX32630 SPI workaround..."
whismanoid 14:cbe972986136 509 // replace SPI_MODE2 (CPOL=1,CPHA=0) with SPI_MODE1 (CPOL=0,CPHA=1) Falling Edge stable
whismanoid 14:cbe972986136 510 // replace SPI_MODE3 (CPOL=1,CPHA=1) with SPI_MODE0 (CPOL=0,CPHA=0) Rising Edge stable
whismanoid 14:cbe972986136 511 # if ((SPI_dataMode) == (SPI_MODE2))
whismanoid 14:cbe972986136 512 #warning "MAX32630 SPI_MODE2 workaround, changing SPI_dataMode to SPI_MODE1..."
whismanoid 14:cbe972986136 513 // SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High
whismanoid 14:cbe972986136 514 # undef SPI_dataMode
whismanoid 14:cbe972986136 515 # define SPI_dataMode SPI_MODE1 // CPOL=0,CPHA=1: Falling Edge stable; SCLK idle Low
whismanoid 14:cbe972986136 516 # elif ((SPI_dataMode) == (SPI_MODE3))
whismanoid 14:cbe972986136 517 #warning "MAX32630 SPI_MODE3 workaround, changing SPI_dataMode to SPI_MODE0..."
whismanoid 14:cbe972986136 518 // SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 14:cbe972986136 519 # undef SPI_dataMode
whismanoid 14:cbe972986136 520 # define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low
whismanoid 14:cbe972986136 521 # endif // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem
whismanoid 14:cbe972986136 522 // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem (issue #30)
whismanoid 14:cbe972986136 523 // limit SPI SCLK speed to 6MHz or less
whismanoid 14:cbe972986136 524 # if ((SPI_SCLK_Hz) > (6000000))
whismanoid 14:cbe972986136 525 #warning "MAX32630 SPI speed workaround, changing SPI_SCLK_Hz to 6000000 or 6MHz..."
whismanoid 14:cbe972986136 526 # undef SPI_SCLK_Hz
whismanoid 14:cbe972986136 527 # define SPI_SCLK_Hz 6000000 // 6MHz
whismanoid 14:cbe972986136 528 # endif
whismanoid 14:cbe972986136 529 #endif
whismanoid 14:cbe972986136 530 //
whismanoid 0:3edb3708c8c5 531 uint32_t g_SPI_SCLK_Hz = SPI_SCLK_Hz;
whismanoid 0:3edb3708c8c5 532 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 0:3edb3708c8c5 533 #if defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 534 // Nucleo SPI frequency isn't working quite as expected...
whismanoid 0:3edb3708c8c5 535 // Looks like STMF4 has an spi clock prescaler (2,4,8,16,32,64,128,256)
whismanoid 0:3edb3708c8c5 536 // so 180MHz->[90.0, 45.0, 22.5, 11.25, 5.625, 2.8125, 1.40625, 0.703125]
whismanoid 0:3edb3708c8c5 537 // %SC SCLK=1MHz sets spi frequency 703.125kHz
whismanoid 0:3edb3708c8c5 538 // %SC SCLK=2MHz sets spi frequency 1.40625MHz
whismanoid 0:3edb3708c8c5 539 // %SC SCLK=3MHz sets spi frequency 2.8125MHz
whismanoid 0:3edb3708c8c5 540 // %SC SCLK=6MHz sets spi frequency 5.625MHz
whismanoid 0:3edb3708c8c5 541 // %SC SCLK=12MHz sets spi frequency 11.25MHz
whismanoid 0:3edb3708c8c5 542 // %SC SCLK=23MHz sets spi frequency 22.5MHz
whismanoid 0:3edb3708c8c5 543 // %SC SCLK=45MHz sets spi frequency 45.0MHz
whismanoid 0:3edb3708c8c5 544 // Don't know why I can't reach spi frequency 90.0MHz, but ok whatever.
whismanoid 0:3edb3708c8c5 545 const uint32_t limit_min_SPI_SCLK_divisor = 2;
whismanoid 0:3edb3708c8c5 546 const uint32_t limit_max_SPI_SCLK_divisor = 256;
whismanoid 0:3edb3708c8c5 547 // not really a divisor, just a powers-of-two prescaler with no intermediate divisors.
whismanoid 0:3edb3708c8c5 548 #else
whismanoid 0:3edb3708c8c5 549 const uint32_t limit_min_SPI_SCLK_divisor = 2;
whismanoid 0:3edb3708c8c5 550 const uint32_t limit_max_SPI_SCLK_divisor = 8191;
whismanoid 0:3edb3708c8c5 551 #endif
whismanoid 0:3edb3708c8c5 552 const uint32_t limit_max_SPI_SCLK_Hz = (SystemCoreClock / limit_min_SPI_SCLK_divisor); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 0:3edb3708c8c5 553 const uint32_t limit_min_SPI_SCLK_Hz = (SystemCoreClock / limit_max_SPI_SCLK_divisor); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 0:3edb3708c8c5 554 //
whismanoid 0:3edb3708c8c5 555 uint8_t g_SPI_dataMode = SPI_dataMode;
whismanoid 0:3edb3708c8c5 556 uint8_t g_SPI_cs_state = 1;
whismanoid 0:3edb3708c8c5 557 //
whismanoid 0:3edb3708c8c5 558 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 559 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 560 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:3edb3708c8c5 561 //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 562 //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 563 //SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0
whismanoid 0:3edb3708c8c5 564 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0
whismanoid 0:3edb3708c8c5 565 //
whismanoid 0:3edb3708c8c5 566 DigitalOut spi_cs(P3_0);
whismanoid 0:3edb3708c8c5 567 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 568 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 569 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:3edb3708c8c5 570 //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 571 //DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32635MBED: P0_7 Arduino 8-pin header D4
whismanoid 0:3edb3708c8c5 572 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 573 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32635MBED: P1_3 Arduino 10-pin header D10
whismanoid 0:3edb3708c8c5 574 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 575 DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header
whismanoid 0:3edb3708c8c5 576 #define HAS_SPI2_MAX541 1
whismanoid 0:3edb3708c8c5 577 //
whismanoid 11:9fa2402071de 578 #elif defined(TARGET_MAX32600)
whismanoid 11:9fa2402071de 579 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 11:9fa2402071de 580 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 11:9fa2402071de 581 //
whismanoid 0:3edb3708c8c5 582 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 583 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 584 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:3edb3708c8c5 585 //
whismanoid 0:3edb3708c8c5 586 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:3edb3708c8c5 587 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 588 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:3edb3708c8c5 589 //
whismanoid 0:3edb3708c8c5 590 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 591 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 592 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:3edb3708c8c5 593 //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 594 //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 595 //SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0
whismanoid 0:3edb3708c8c5 596 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0
whismanoid 0:3edb3708c8c5 597 //
whismanoid 0:3edb3708c8c5 598 DigitalOut spi_cs(P3_0);
whismanoid 0:3edb3708c8c5 599 #else
whismanoid 0:3edb3708c8c5 600 // unknown target
whismanoid 0:3edb3708c8c5 601 #endif
whismanoid 0:3edb3708c8c5 602 #endif
whismanoid 0:3edb3708c8c5 603
whismanoid 0:3edb3708c8c5 604 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 605 // Device driver object
whismanoid 0:3edb3708c8c5 606 #if APPLICATION_MAX5715 // SPI interface default settings
whismanoid 0:3edb3708c8c5 607 DigitalOut LDACb_pin(D9); // Arduino 10-pin header D9
whismanoid 0:3edb3708c8c5 608 DigitalOut CLRb_pin(D8); // Arduino 10-pin header D8
whismanoid 0:3edb3708c8c5 609 //~ DigitalIn RDYb_pin(D12); // Arduino 10-pin header D12 (MISO)
whismanoid 0:3edb3708c8c5 610 MAX5715 g_MAX5715_device(spi, spi_cs,
whismanoid 0:3edb3708c8c5 611 LDACb_pin,
whismanoid 0:3edb3708c8c5 612 CLRb_pin,
whismanoid 0:3edb3708c8c5 613 ///* RDYb_pin */ digitalInOut12,
whismanoid 0:3edb3708c8c5 614 MAX5715::MAX5715_IC);
whismanoid 0:3edb3708c8c5 615 //
whismanoid 0:3edb3708c8c5 616 #elif APPLICATION_MAX11131 // SPI interface default settings
whismanoid 0:3edb3708c8c5 617 DigitalOut CNVSTb_pin(D9); // Arduino 10-pin header D9
whismanoid 0:3edb3708c8c5 618 //DigitalOut CLRb_pin(D8); // Arduino 10-pin header D8
whismanoid 0:3edb3708c8c5 619 DigitalIn EOCb_pin(D12); // Arduino 10-pin header D12 (MISO)
whismanoid 0:3edb3708c8c5 620 MAX11131 g_MAX11131_device(spi, spi_cs,
whismanoid 0:3edb3708c8c5 621 CNVSTb_pin,
whismanoid 0:3edb3708c8c5 622 EOCb_pin,
whismanoid 0:3edb3708c8c5 623 ///* RDYb_pin */ digitalInOut12,
whismanoid 0:3edb3708c8c5 624 MAX11131::MAX11131_IC);
whismanoid 0:3edb3708c8c5 625 //
whismanoid 0:3edb3708c8c5 626 //
whismanoid 0:3edb3708c8c5 627 #elif APPLICATION_MAX5171 // SPI interface default settings
whismanoid 0:3edb3708c8c5 628 // AnalogOut FB_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5171 device
whismanoid 0:3edb3708c8c5 629 DigitalOut RS_pin(D9); // Digital Configuration Input to MAX5171 device
whismanoid 0:3edb3708c8c5 630 DigitalOut PDLb_pin(D8); // Digital Configuration Input to MAX5171 device
whismanoid 0:3edb3708c8c5 631 DigitalOut CLRb_pin(D7); // Digital Configuration Input to MAX5171 device
whismanoid 0:3edb3708c8c5 632 DigitalOut SHDN_pin(D6); // Digital Configuration Input to MAX5171 device
whismanoid 0:3edb3708c8c5 633 // AnalogIn OUT_pin(A0); // Analog Output from MAX5171 device
whismanoid 0:3edb3708c8c5 634 DigitalIn UPO_pin(D2); // Digital General-Purpose Output from MAX5171 device
whismanoid 0:3edb3708c8c5 635 MAX5171 g_MAX5171_device(spi, spi_cs, RS_pin, PDLb_pin, CLRb_pin, SHDN_pin, UPO_pin, MAX5171::MAX5171_IC);
whismanoid 0:3edb3708c8c5 636 //
whismanoid 0:3edb3708c8c5 637 #elif APPLICATION_MAX11410 // SPI interface default settings
whismanoid 0:3edb3708c8c5 638 //
whismanoid 0:3edb3708c8c5 639 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 0:3edb3708c8c5 640 //
whismanoid 0:3edb3708c8c5 641 #elif APPLICATION_MAX12345 // SPI interface default settings
whismanoid 0:3edb3708c8c5 642 //
whismanoid 0:3edb3708c8c5 643 MAX12345 g_MAX12345_device(spi, spi_cs, ...);
whismanoid 0:3edb3708c8c5 644 //
whismanoid 0:3edb3708c8c5 645 #else // APPLICATION_ArduinoPinsMonitor diagnostic
whismanoid 0:3edb3708c8c5 646 //
whismanoid 0:3edb3708c8c5 647 #endif
whismanoid 0:3edb3708c8c5 648
whismanoid 0:3edb3708c8c5 649
whismanoid 0:3edb3708c8c5 650 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 651 // Option to dedicate I2C port pins
whismanoid 0:3edb3708c8c5 652 //
whismanoid 0:3edb3708c8c5 653 #ifndef HAS_I2C
whismanoid 0:3edb3708c8c5 654 #define HAS_I2C 1
whismanoid 0:3edb3708c8c5 655 #endif
whismanoid 0:3edb3708c8c5 656 #if HAS_I2C
whismanoid 0:3edb3708c8c5 657 //#include "I2C.h"
whismanoid 0:3edb3708c8c5 658 //#include "I2CSlave.h"
whismanoid 0:3edb3708c8c5 659 //#define I2C_SCL_Hz 400000 // 400kHz
whismanoid 0:3edb3708c8c5 660 //#define I2C_SCL_Hz 200000 // 200kHz
whismanoid 0:3edb3708c8c5 661 #define I2C_SCL_Hz 100000 // 100kHz
whismanoid 0:3edb3708c8c5 662 //
whismanoid 0:3edb3708c8c5 663 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 664 // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 0:3edb3708c8c5 665 const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 0:3edb3708c8c5 666 const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 0:3edb3708c8c5 667 //
whismanoid 0:3edb3708c8c5 668 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 669 //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl MAX32630FTHR: NOT_CONNECTED
whismanoid 0:3edb3708c8c5 670 //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl MAX32630FTHR: P3_4, P3_5
whismanoid 0:3edb3708c8c5 671 //I2C i2cMaster2(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0
whismanoid 0:3edb3708c8c5 672 //I2C i2cMaster(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0
whismanoid 0:3edb3708c8c5 673 //
whismanoid 0:3edb3708c8c5 674 //I2CSlave i2cSlave0(I2C0_SDA, I2C0_SCL); // sda scl MAX32630FTHR: NOT_CONNECTED
whismanoid 0:3edb3708c8c5 675 //I2CSlave i2cSlave1(I2C1_SDA, I2C1_SCL); // sda scl MAX32630FTHR: P3_4, P3_5
whismanoid 0:3edb3708c8c5 676 //I2CSlave i2cSlave2(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0
whismanoid 0:3edb3708c8c5 677 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 678 // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 0:3edb3708c8c5 679 const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 0:3edb3708c8c5 680 const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 0:3edb3708c8c5 681 //
whismanoid 0:3edb3708c8c5 682 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 683 //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 684 //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header
whismanoid 0:3edb3708c8c5 685 // 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 686 //
whismanoid 0:3edb3708c8c5 687 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 688 // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 0:3edb3708c8c5 689 const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 0:3edb3708c8c5 690 const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 0:3edb3708c8c5 691 //
whismanoid 0:3edb3708c8c5 692 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 693 //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 694 //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header
whismanoid 0:3edb3708c8c5 695 // 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 696 # ifndef I2C0_SDA
whismanoid 0:3edb3708c8c5 697 # define I2C0_SDA I2C_SDA
whismanoid 0:3edb3708c8c5 698 # define I2C0_SCL I2C_SCL
whismanoid 0:3edb3708c8c5 699 # endif
whismanoid 0:3edb3708c8c5 700 //
whismanoid 0:3edb3708c8c5 701 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 702 // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 0:3edb3708c8c5 703 const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 0:3edb3708c8c5 704 const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 0:3edb3708c8c5 705 //
whismanoid 0:3edb3708c8c5 706 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 707 //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 708 //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header
whismanoid 0:3edb3708c8c5 709 // 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 710 # ifndef I2C0_SDA
whismanoid 0:3edb3708c8c5 711 # define I2C0_SDA I2C_SDA
whismanoid 0:3edb3708c8c5 712 # define I2C0_SCL I2C_SCL
whismanoid 0:3edb3708c8c5 713 # endif
whismanoid 0:3edb3708c8c5 714 //
whismanoid 0:3edb3708c8c5 715 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 716 #else
whismanoid 0:3edb3708c8c5 717 // unknown target
whismanoid 0:3edb3708c8c5 718 #endif
whismanoid 0:3edb3708c8c5 719 //
whismanoid 0:3edb3708c8c5 720 #endif
whismanoid 0:3edb3708c8c5 721 #if HAS_I2C
whismanoid 0:3edb3708c8c5 722 uint32_t g_I2C_SCL_Hz = I2C_SCL_Hz;
whismanoid 0:3edb3708c8c5 723 uint8_t g_I2C_status = 0; // g_I2C_status = Wire_Sr.endTransmission();
whismanoid 0:3edb3708c8c5 724 uint8_t g_I2C_deviceAddress7 = (0xA0 >> 1); // I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified.
whismanoid 0:3edb3708c8c5 725 uint8_t g_I2C_read_count = 0;
whismanoid 0:3edb3708c8c5 726 uint8_t g_I2C_write_count = 0;
whismanoid 0:3edb3708c8c5 727 uint8_t g_I2C_write_data[256];
whismanoid 0:3edb3708c8c5 728 uint8_t g_I2C_command_regAddress;
whismanoid 0:3edb3708c8c5 729 //
whismanoid 0:3edb3708c8c5 730 // TODO: i2c init
whismanoid 0:3edb3708c8c5 731 // i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 0:3edb3708c8c5 732 #endif
whismanoid 0:3edb3708c8c5 733 #if HAS_I2C
whismanoid 0:3edb3708c8c5 734 // TODO: i2c transfer
whismanoid 0:3edb3708c8c5 735 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 0:3edb3708c8c5 736 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 0:3edb3708c8c5 737 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 0:3edb3708c8c5 738 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 0:3edb3708c8c5 739 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 0:3edb3708c8c5 740 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 0:3edb3708c8c5 741 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 0:3edb3708c8c5 742 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 0:3edb3708c8c5 743 // /* 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 744 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 0:3edb3708c8c5 745 #endif
whismanoid 0:3edb3708c8c5 746
whismanoid 0:3edb3708c8c5 747
whismanoid 0:3edb3708c8c5 748 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 749 // Declare the Serial driver
whismanoid 0:3edb3708c8c5 750 // default baud rate settings are 9600 8N1
whismanoid 0:3edb3708c8c5 751 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 0:3edb3708c8c5 752 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 0:3edb3708c8c5 753 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 754 #include "USBSerial.h"
whismanoid 0:3edb3708c8c5 755 // Hardware serial port over DAPLink
whismanoid 0:3edb3708c8c5 756 // The default baud rate for the DapLink UART is 9600
whismanoid 0:3edb3708c8c5 757 Serial DAPLINKserial(P2_1, P2_0); // tx, rx
whismanoid 0:3edb3708c8c5 758 #define HAS_DAPLINK_SERIAL 1
whismanoid 0:3edb3708c8c5 759 // Virtual serial port over USB
whismanoid 0:3edb3708c8c5 760 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 7:bf501f8cb637 761 USBSerial serial;
whismanoid 0:3edb3708c8c5 762 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 763 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 764 #include "USBSerial.h"
whismanoid 0:3edb3708c8c5 765 // Hardware serial port over DAPLink
whismanoid 0:3edb3708c8c5 766 // The default baud rate for the DapLink UART is 9600
whismanoid 0:3edb3708c8c5 767 Serial DAPLINKserial(P2_1, P2_0); // tx, rx
whismanoid 0:3edb3708c8c5 768 #define HAS_DAPLINK_SERIAL 1
whismanoid 0:3edb3708c8c5 769 // Virtual serial port over USB
whismanoid 0:3edb3708c8c5 770 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 7:bf501f8cb637 771 USBSerial serial;
whismanoid 0:3edb3708c8c5 772 //--------------------------------------------------
whismanoid 11:9fa2402071de 773 #elif defined(TARGET_MAX32600)
whismanoid 11:9fa2402071de 774 #include "USBSerial.h"
whismanoid 11:9fa2402071de 775 // Hardware serial port over DAPLink
whismanoid 11:9fa2402071de 776 // The default baud rate for the DapLink UART is 9600
whismanoid 11:9fa2402071de 777 Serial DAPLINKserial(P1_1, P1_0); // tx, rx
whismanoid 11:9fa2402071de 778 #define HAS_DAPLINK_SERIAL 1
whismanoid 11:9fa2402071de 779 // Virtual serial port over USB
whismanoid 11:9fa2402071de 780 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 11:9fa2402071de 781 USBSerial serial;
whismanoid 11:9fa2402071de 782 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 783 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 7:bf501f8cb637 784 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 0:3edb3708c8c5 785 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 786 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:3edb3708c8c5 787 #elif defined(TARGET_LPC1768)
whismanoid 7:bf501f8cb637 788 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 0:3edb3708c8c5 789 #else
whismanoid 0:3edb3708c8c5 790 // unknown target
whismanoid 0:3edb3708c8c5 791 #endif
whismanoid 0:3edb3708c8c5 792
whismanoid 0:3edb3708c8c5 793 void on_immediate_0x21(); // Unicode (U+0021) ! EXCLAMATION MARK
whismanoid 0:3edb3708c8c5 794 void on_immediate_0x7b(); // Unicode (U+007B) { LEFT CURLY BRACKET
whismanoid 0:3edb3708c8c5 795 void on_immediate_0x7d(); // Unicode (U+007D) } RIGHT CURLY BRACKET
whismanoid 0:3edb3708c8c5 796
whismanoid 0:3edb3708c8c5 797 #include "CmdLine.h"
whismanoid 0:3edb3708c8c5 798
whismanoid 0:3edb3708c8c5 799 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 800 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 0:3edb3708c8c5 801 # endif // HAS_DAPLINK_SERIAL
whismanoid 7:bf501f8cb637 802 CmdLine cmdLine_serial(serial, "serial");
whismanoid 0:3edb3708c8c5 803
whismanoid 0:3edb3708c8c5 804
whismanoid 0:3edb3708c8c5 805 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 806 // tolerate AT commands, which may be sent during probe, such as:
whismanoid 0:3edb3708c8c5 807 // AT
whismanoid 0:3edb3708c8c5 808 // AT+CGMI -- request manufacturer identification AT+CMGI=?
whismanoid 0:3edb3708c8c5 809 // AT+CGMM -- request manufacturer model
whismanoid 0:3edb3708c8c5 810 // AT%IPSYS?
whismanoid 0:3edb3708c8c5 811 // ATE0 -- echo disable
whismanoid 0:3edb3708c8c5 812 // ATV1 -- verbose result codes OK | ERROR | NO CARRIER
whismanoid 0:3edb3708c8c5 813 // AT+CMEE=1
whismanoid 0:3edb3708c8c5 814 // ATX4
whismanoid 0:3edb3708c8c5 815 // AT&C1
whismanoid 0:3edb3708c8c5 816 // ATE0
whismanoid 0:3edb3708c8c5 817 // AT+CMEE=1
whismanoid 0:3edb3708c8c5 818 // AT+GCAP
whismanoid 0:3edb3708c8c5 819 // ATI
whismanoid 0:3edb3708c8c5 820 // AT+CPIN?
whismanoid 0:3edb3708c8c5 821 // AT+CGMM
whismanoid 0:3edb3708c8c5 822 #ifndef IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 823 #define IGNORE_AT_COMMANDS 1
whismanoid 0:3edb3708c8c5 824 #endif
whismanoid 0:3edb3708c8c5 825
whismanoid 0:3edb3708c8c5 826
whismanoid 0:3edb3708c8c5 827 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:3edb3708c8c5 828 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 829 // Declare the DigitalInOut GPIO pins
whismanoid 0:3edb3708c8c5 830 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:3edb3708c8c5 831 // D) Digital High/Low/Input Pin
whismanoid 0:3edb3708c8c5 832 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 833 // +-------------[microUSB]-------------+
whismanoid 0:3edb3708c8c5 834 // | J1 MAX32630FTHR J2 |
whismanoid 0:3edb3708c8c5 835 // | [ ] RST GND [ ] |
whismanoid 0:3edb3708c8c5 836 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:3edb3708c8c5 837 // | [ ] 1V8 reset SW1 |
whismanoid 0:3edb3708c8c5 838 // | [ ] GND J4 J3 |
whismanoid 0:3edb3708c8c5 839 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:3edb3708c8c5 840 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:3edb3708c8c5 841 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:3edb3708c8c5 842 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:3edb3708c8c5 843 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:3edb3708c8c5 844 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:3edb3708c8c5 845 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:3edb3708c8c5 846 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:3edb3708c8c5 847 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:3edb3708c8c5 848 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:3edb3708c8c5 849 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:3edb3708c8c5 850 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:3edb3708c8c5 851 // +------------------------------------+
whismanoid 0:3edb3708c8c5 852 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:3edb3708c8c5 853 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:3edb3708c8c5 854 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:3edb3708c8c5 855 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:3edb3708c8c5 856 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:3edb3708c8c5 857 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:3edb3708c8c5 858 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:3edb3708c8c5 859 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:3edb3708c8c5 860 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:3edb3708c8c5 861 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:3edb3708c8c5 862 #if HAS_I2C
whismanoid 0:3edb3708c8c5 863 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 864 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:3edb3708c8c5 865 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:3edb3708c8c5 866 #else // HAS_I2C
whismanoid 0:3edb3708c8c5 867 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:3edb3708c8c5 868 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:3edb3708c8c5 869 #endif // HAS_I2C
whismanoid 0:3edb3708c8c5 870 #if HAS_SPI
whismanoid 0:3edb3708c8c5 871 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 872 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:3edb3708c8c5 873 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:3edb3708c8c5 874 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:3edb3708c8c5 875 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:3edb3708c8c5 876 #else // HAS_SPI
whismanoid 0:3edb3708c8c5 877 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:3edb3708c8c5 878 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:3edb3708c8c5 879 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:3edb3708c8c5 880 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:3edb3708c8c5 881 #endif // HAS_SPI
whismanoid 0:3edb3708c8c5 882 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 883 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:3edb3708c8c5 884 #endif
whismanoid 0:3edb3708c8c5 885 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 886 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:3edb3708c8c5 887 #endif
whismanoid 0:3edb3708c8c5 888 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 889 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:3edb3708c8c5 890 #endif
whismanoid 0:3edb3708c8c5 891 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 892 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:3edb3708c8c5 893 #endif
whismanoid 0:3edb3708c8c5 894 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 895 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:3edb3708c8c5 896 #endif
whismanoid 0:3edb3708c8c5 897 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 898 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:3edb3708c8c5 899 #endif
whismanoid 0:3edb3708c8c5 900 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 901 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:3edb3708c8c5 902 #endif
whismanoid 0:3edb3708c8c5 903 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 904 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:3edb3708c8c5 905 #endif
whismanoid 0:3edb3708c8c5 906 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 907 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:3edb3708c8c5 908 #endif
whismanoid 0:3edb3708c8c5 909 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 910 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:3edb3708c8c5 911 #endif
whismanoid 0:3edb3708c8c5 912 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 913 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:3edb3708c8c5 914 #endif
whismanoid 0:3edb3708c8c5 915 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 916 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:3edb3708c8c5 917 #endif
whismanoid 0:3edb3708c8c5 918 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 919 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:3edb3708c8c5 920 #endif
whismanoid 0:3edb3708c8c5 921 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 922 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:3edb3708c8c5 923 #endif
whismanoid 0:3edb3708c8c5 924 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 925 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:3edb3708c8c5 926 #endif
whismanoid 0:3edb3708c8c5 927 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 928 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:3edb3708c8c5 929 #endif
whismanoid 0:3edb3708c8c5 930 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 931 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 932 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:3edb3708c8c5 933 // +-------------------------------------+
whismanoid 0:3edb3708c8c5 934 // | MAX32625MBED Arduino UNO header |
whismanoid 0:3edb3708c8c5 935 // | |
whismanoid 0:3edb3708c8c5 936 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:3edb3708c8c5 937 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:3edb3708c8c5 938 // | AREF=N/C[ ] |
whismanoid 0:3edb3708c8c5 939 // | GND[ ] |
whismanoid 0:3edb3708c8c5 940 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:3edb3708c8c5 941 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:3edb3708c8c5 942 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:3edb3708c8c5 943 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:3edb3708c8c5 944 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:3edb3708c8c5 945 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:3edb3708c8c5 946 // | [ ]GND |
whismanoid 0:3edb3708c8c5 947 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:3edb3708c8c5 948 // | 6[ ]~| P0_6 dig6
whismanoid 0:3edb3708c8c5 949 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:3edb3708c8c5 950 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:3edb3708c8c5 951 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:3edb3708c8c5 952 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:3edb3708c8c5 953 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:3edb3708c8c5 954 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:3edb3708c8c5 955 // | [ ] [ ] [ ] |
whismanoid 0:3edb3708c8c5 956 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:3edb3708c8c5 957 // \_______________________/
whismanoid 0:3edb3708c8c5 958 //
whismanoid 0:3edb3708c8c5 959 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:3edb3708c8c5 960 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:3edb3708c8c5 961 #if APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 962 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:3edb3708c8c5 963 #else
whismanoid 0:3edb3708c8c5 964 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:3edb3708c8c5 965 #endif
whismanoid 0:3edb3708c8c5 966 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:3edb3708c8c5 967 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:3edb3708c8c5 968 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:3edb3708c8c5 969 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:3edb3708c8c5 970 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:3edb3708c8c5 971 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:3edb3708c8c5 972 #if APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 973 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:3edb3708c8c5 974 #else
whismanoid 0:3edb3708c8c5 975 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:3edb3708c8c5 976 #endif
whismanoid 0:3edb3708c8c5 977 #if HAS_SPI
whismanoid 0:3edb3708c8c5 978 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 979 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:3edb3708c8c5 980 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:3edb3708c8c5 981 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:3edb3708c8c5 982 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:3edb3708c8c5 983 #else // HAS_SPI
whismanoid 0:3edb3708c8c5 984 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:3edb3708c8c5 985 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:3edb3708c8c5 986 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:3edb3708c8c5 987 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:3edb3708c8c5 988 #endif // HAS_SPI
whismanoid 0:3edb3708c8c5 989 #if HAS_I2C
whismanoid 0:3edb3708c8c5 990 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 991 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 992 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 993 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 994 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 995 #else // HAS_I2C
whismanoid 0:3edb3708c8c5 996 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 997 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 998 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 999 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 1000 #endif // HAS_I2C
whismanoid 0:3edb3708c8c5 1001 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 1002 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:3edb3708c8c5 1003 #endif
whismanoid 0:3edb3708c8c5 1004 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 1005 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:3edb3708c8c5 1006 #endif
whismanoid 0:3edb3708c8c5 1007 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 1008 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:3edb3708c8c5 1009 #endif
whismanoid 0:3edb3708c8c5 1010 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 1011 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:3edb3708c8c5 1012 #endif
whismanoid 0:3edb3708c8c5 1013 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 1014 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:3edb3708c8c5 1015 #endif
whismanoid 0:3edb3708c8c5 1016 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 1017 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:3edb3708c8c5 1018 #endif
whismanoid 0:3edb3708c8c5 1019 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 1020 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:3edb3708c8c5 1021 #endif
whismanoid 0:3edb3708c8c5 1022 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 1023 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:3edb3708c8c5 1024 #endif
whismanoid 0:3edb3708c8c5 1025 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 1026 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:3edb3708c8c5 1027 #endif
whismanoid 0:3edb3708c8c5 1028 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 1029 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:3edb3708c8c5 1030 #endif
whismanoid 0:3edb3708c8c5 1031 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 1032 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:3edb3708c8c5 1033 #endif
whismanoid 0:3edb3708c8c5 1034 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 1035 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:3edb3708c8c5 1036 #endif
whismanoid 0:3edb3708c8c5 1037 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 1038 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:3edb3708c8c5 1039 #endif
whismanoid 0:3edb3708c8c5 1040 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 1041 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:3edb3708c8c5 1042 #endif
whismanoid 0:3edb3708c8c5 1043 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 1044 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:3edb3708c8c5 1045 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:3edb3708c8c5 1046 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 1047 #endif
whismanoid 0:3edb3708c8c5 1048 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 1049 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:3edb3708c8c5 1050 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 1051 #endif
whismanoid 0:3edb3708c8c5 1052 #if HAS_digitalInOut16
whismanoid 0:3edb3708c8c5 1053 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:3edb3708c8c5 1054 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:3edb3708c8c5 1055 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:3edb3708c8c5 1056 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 1057 #endif
whismanoid 0:3edb3708c8c5 1058 #if HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 1059 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:3edb3708c8c5 1060 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 1061 #endif
whismanoid 0:3edb3708c8c5 1062 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1063 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 1064 #define HAS_digitalInOut0 0 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:3edb3708c8c5 1065 #define HAS_digitalInOut1 0 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:3edb3708c8c5 1066 #if APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 1067 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:3edb3708c8c5 1068 #else
whismanoid 0:3edb3708c8c5 1069 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:3edb3708c8c5 1070 #endif
whismanoid 0:3edb3708c8c5 1071 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:3edb3708c8c5 1072 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:3edb3708c8c5 1073 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:3edb3708c8c5 1074 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:3edb3708c8c5 1075 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:3edb3708c8c5 1076 #if APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 1077 #define HAS_digitalInOut8 0 // P1_4 TARGET_MAX32625MBED D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:3edb3708c8c5 1078 #else
whismanoid 0:3edb3708c8c5 1079 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:3edb3708c8c5 1080 #endif
whismanoid 0:3edb3708c8c5 1081 #if APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 1082 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:3edb3708c8c5 1083 #elif APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 1084 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:3edb3708c8c5 1085 #else
whismanoid 0:3edb3708c8c5 1086 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:3edb3708c8c5 1087 #endif
whismanoid 0:3edb3708c8c5 1088 #if HAS_SPI
whismanoid 0:3edb3708c8c5 1089 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:3edb3708c8c5 1090 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:3edb3708c8c5 1091 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:3edb3708c8c5 1092 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:3edb3708c8c5 1093 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:3edb3708c8c5 1094 #define HAS_digitalInOut10 0
whismanoid 0:3edb3708c8c5 1095 #define HAS_digitalInOut11 0
whismanoid 0:3edb3708c8c5 1096 #define HAS_digitalInOut12 0
whismanoid 0:3edb3708c8c5 1097 #define HAS_digitalInOut13 0
whismanoid 0:3edb3708c8c5 1098 #else // HAS_SPI
whismanoid 0:3edb3708c8c5 1099 #define HAS_digitalInOut10 1
whismanoid 0:3edb3708c8c5 1100 #define HAS_digitalInOut11 1
whismanoid 0:3edb3708c8c5 1101 #define HAS_digitalInOut12 1
whismanoid 0:3edb3708c8c5 1102 #define HAS_digitalInOut13 1
whismanoid 0:3edb3708c8c5 1103 #endif // HAS_SPI
whismanoid 0:3edb3708c8c5 1104 #if HAS_I2C
whismanoid 0:3edb3708c8c5 1105 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:3edb3708c8c5 1106 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 1107 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 1108 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 1109 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 1110 #define HAS_digitalInOut14 0
whismanoid 0:3edb3708c8c5 1111 #define HAS_digitalInOut15 0
whismanoid 0:3edb3708c8c5 1112 #define HAS_digitalInOut16 0
whismanoid 0:3edb3708c8c5 1113 #define HAS_digitalInOut17 0
whismanoid 0:3edb3708c8c5 1114 #else // HAS_I2C
whismanoid 0:3edb3708c8c5 1115 #define HAS_digitalInOut14 1
whismanoid 0:3edb3708c8c5 1116 #define HAS_digitalInOut15 1
whismanoid 0:3edb3708c8c5 1117 #define HAS_digitalInOut16 0
whismanoid 0:3edb3708c8c5 1118 #define HAS_digitalInOut17 0
whismanoid 0:3edb3708c8c5 1119 #endif // HAS_I2C
whismanoid 0:3edb3708c8c5 1120 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 1121 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1122 #endif
whismanoid 0:3edb3708c8c5 1123 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 1124 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1125 #endif
whismanoid 0:3edb3708c8c5 1126 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 1127 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1128 #endif
whismanoid 0:3edb3708c8c5 1129 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 1130 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1131 #endif
whismanoid 0:3edb3708c8c5 1132 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 1133 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1134 #endif
whismanoid 0:3edb3708c8c5 1135 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 1136 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1137 #endif
whismanoid 0:3edb3708c8c5 1138 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 1139 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1140 #endif
whismanoid 0:3edb3708c8c5 1141 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 1142 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1143 #endif
whismanoid 0:3edb3708c8c5 1144 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 1145 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1146 #endif
whismanoid 0:3edb3708c8c5 1147 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 1148 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1149 #endif
whismanoid 0:3edb3708c8c5 1150 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 1151 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:3edb3708c8c5 1152 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1153 #endif
whismanoid 0:3edb3708c8c5 1154 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 1155 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:3edb3708c8c5 1156 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1157 #endif
whismanoid 0:3edb3708c8c5 1158 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 1159 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:3edb3708c8c5 1160 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1161 #endif
whismanoid 0:3edb3708c8c5 1162 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 1163 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:3edb3708c8c5 1164 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1165 #endif
whismanoid 0:3edb3708c8c5 1166 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 1167 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 1168 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1169 #endif
whismanoid 0:3edb3708c8c5 1170 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 1171 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 1172 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1173 #endif
whismanoid 0:3edb3708c8c5 1174 #if HAS_digitalInOut16
whismanoid 0:3edb3708c8c5 1175 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 1176 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1177 #endif
whismanoid 0:3edb3708c8c5 1178 #if HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 1179 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 1180 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1181 #endif
whismanoid 0:3edb3708c8c5 1182 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1183 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 1184 #define HAS_digitalInOut0 1
whismanoid 0:3edb3708c8c5 1185 #define HAS_digitalInOut1 1
whismanoid 0:3edb3708c8c5 1186 #define HAS_digitalInOut2 1
whismanoid 0:3edb3708c8c5 1187 #define HAS_digitalInOut3 1
whismanoid 0:3edb3708c8c5 1188 #define HAS_digitalInOut4 1
whismanoid 0:3edb3708c8c5 1189 #define HAS_digitalInOut5 1
whismanoid 0:3edb3708c8c5 1190 #define HAS_digitalInOut6 1
whismanoid 0:3edb3708c8c5 1191 #define HAS_digitalInOut7 1
whismanoid 0:3edb3708c8c5 1192 #define HAS_digitalInOut8 1
whismanoid 0:3edb3708c8c5 1193 #define HAS_digitalInOut9 1
whismanoid 0:3edb3708c8c5 1194 // #define HAS_digitalInOut10 1
whismanoid 0:3edb3708c8c5 1195 // #define HAS_digitalInOut11 1
whismanoid 0:3edb3708c8c5 1196 // #define HAS_digitalInOut12 1
whismanoid 0:3edb3708c8c5 1197 // #define HAS_digitalInOut13 1
whismanoid 0:3edb3708c8c5 1198 // #define HAS_digitalInOut14 1
whismanoid 0:3edb3708c8c5 1199 // #define HAS_digitalInOut15 1
whismanoid 0:3edb3708c8c5 1200 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 1201 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:3edb3708c8c5 1202 #endif
whismanoid 0:3edb3708c8c5 1203 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 1204 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:3edb3708c8c5 1205 #endif
whismanoid 0:3edb3708c8c5 1206 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 1207 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:3edb3708c8c5 1208 #endif
whismanoid 0:3edb3708c8c5 1209 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 1210 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:3edb3708c8c5 1211 #endif
whismanoid 0:3edb3708c8c5 1212 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 1213 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:3edb3708c8c5 1214 #endif
whismanoid 0:3edb3708c8c5 1215 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 1216 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:3edb3708c8c5 1217 #endif
whismanoid 0:3edb3708c8c5 1218 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 1219 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:3edb3708c8c5 1220 #endif
whismanoid 0:3edb3708c8c5 1221 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 1222 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:3edb3708c8c5 1223 #endif
whismanoid 0:3edb3708c8c5 1224 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 1225 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:3edb3708c8c5 1226 #endif
whismanoid 0:3edb3708c8c5 1227 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 1228 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:3edb3708c8c5 1229 #endif
whismanoid 0:3edb3708c8c5 1230 //
whismanoid 0:3edb3708c8c5 1231 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:3edb3708c8c5 1232 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:3edb3708c8c5 1233 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:3edb3708c8c5 1234 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:3edb3708c8c5 1235 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:3edb3708c8c5 1236 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:3edb3708c8c5 1237 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:3edb3708c8c5 1238 //
whismanoid 0:3edb3708c8c5 1239 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:3edb3708c8c5 1240 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:3edb3708c8c5 1241 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:3edb3708c8c5 1242 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:3edb3708c8c5 1243 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:3edb3708c8c5 1244 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:3edb3708c8c5 1245 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:3edb3708c8c5 1246 //
whismanoid 0:3edb3708c8c5 1247 // these could be additional digitalInOut pins
whismanoid 0:3edb3708c8c5 1248 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 1249 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:3edb3708c8c5 1250 #endif
whismanoid 0:3edb3708c8c5 1251 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 1252 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:3edb3708c8c5 1253 #endif
whismanoid 0:3edb3708c8c5 1254 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 1255 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:3edb3708c8c5 1256 #endif
whismanoid 0:3edb3708c8c5 1257 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 1258 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:3edb3708c8c5 1259 #endif
whismanoid 0:3edb3708c8c5 1260 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 1261 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1262 #endif
whismanoid 0:3edb3708c8c5 1263 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 1264 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:3edb3708c8c5 1265 #endif
whismanoid 0:3edb3708c8c5 1266 #else
whismanoid 0:3edb3708c8c5 1267 // unknown target
whismanoid 0:3edb3708c8c5 1268 #endif
whismanoid 0:3edb3708c8c5 1269 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:3edb3708c8c5 1270 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:3edb3708c8c5 1271 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:3edb3708c8c5 1272 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:3edb3708c8c5 1273 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:3edb3708c8c5 1274 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:3edb3708c8c5 1275 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:3edb3708c8c5 1276 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:3edb3708c8c5 1277 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:3edb3708c8c5 1278 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 1279 #define HAS_digitalInOuts 1
whismanoid 0:3edb3708c8c5 1280 #endif
whismanoid 0:3edb3708c8c5 1281
whismanoid 0:3edb3708c8c5 1282 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:3edb3708c8c5 1283 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1284 // Declare the AnalogIn driver
whismanoid 0:3edb3708c8c5 1285 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:3edb3708c8c5 1286 // A) analog input
whismanoid 0:3edb3708c8c5 1287 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 1288 #define HAS_analogIn0 1
whismanoid 0:3edb3708c8c5 1289 #define HAS_analogIn1 1
whismanoid 0:3edb3708c8c5 1290 #define HAS_analogIn2 1
whismanoid 0:3edb3708c8c5 1291 #define HAS_analogIn3 1
whismanoid 0:3edb3708c8c5 1292 #define HAS_analogIn4 1
whismanoid 0:3edb3708c8c5 1293 #define HAS_analogIn5 1
whismanoid 0:3edb3708c8c5 1294 #define HAS_analogIn6 1
whismanoid 0:3edb3708c8c5 1295 #define HAS_analogIn7 1
whismanoid 0:3edb3708c8c5 1296 #define HAS_analogIn8 1
whismanoid 0:3edb3708c8c5 1297 #define HAS_analogIn9 1
whismanoid 0:3edb3708c8c5 1298 // #define HAS_analogIn10 0
whismanoid 0:3edb3708c8c5 1299 // #define HAS_analogIn11 0
whismanoid 0:3edb3708c8c5 1300 // #define HAS_analogIn12 0
whismanoid 0:3edb3708c8c5 1301 // #define HAS_analogIn13 0
whismanoid 0:3edb3708c8c5 1302 // #define HAS_analogIn14 0
whismanoid 0:3edb3708c8c5 1303 // #define HAS_analogIn15 0
whismanoid 0:3edb3708c8c5 1304 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 1305 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1306 #endif
whismanoid 0:3edb3708c8c5 1307 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 1308 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1309 #endif
whismanoid 0:3edb3708c8c5 1310 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 1311 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1312 #endif
whismanoid 0:3edb3708c8c5 1313 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 1314 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1315 #endif
whismanoid 0:3edb3708c8c5 1316 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 1317 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 1318 #endif
whismanoid 0:3edb3708c8c5 1319 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 1320 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 1321 #endif
whismanoid 0:3edb3708c8c5 1322 #if HAS_analogIn6
whismanoid 0:3edb3708c8c5 1323 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 1324 #endif
whismanoid 0:3edb3708c8c5 1325 #if HAS_analogIn7
whismanoid 0:3edb3708c8c5 1326 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1327 #endif
whismanoid 0:3edb3708c8c5 1328 #if HAS_analogIn8
whismanoid 0:3edb3708c8c5 1329 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1330 #endif
whismanoid 0:3edb3708c8c5 1331 #if HAS_analogIn9
whismanoid 0:3edb3708c8c5 1332 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:3edb3708c8c5 1333 #endif
whismanoid 0:3edb3708c8c5 1334 #if HAS_analogIn10
whismanoid 0:3edb3708c8c5 1335 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:3edb3708c8c5 1336 #endif
whismanoid 0:3edb3708c8c5 1337 #if HAS_analogIn11
whismanoid 0:3edb3708c8c5 1338 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 1339 #endif
whismanoid 0:3edb3708c8c5 1340 #if HAS_analogIn12
whismanoid 0:3edb3708c8c5 1341 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 1342 #endif
whismanoid 0:3edb3708c8c5 1343 #if HAS_analogIn13
whismanoid 0:3edb3708c8c5 1344 AnalogIn analogIn13(____);
whismanoid 0:3edb3708c8c5 1345 #endif
whismanoid 0:3edb3708c8c5 1346 #if HAS_analogIn14
whismanoid 0:3edb3708c8c5 1347 AnalogIn analogIn14(____);
whismanoid 0:3edb3708c8c5 1348 #endif
whismanoid 0:3edb3708c8c5 1349 #if HAS_analogIn15
whismanoid 0:3edb3708c8c5 1350 AnalogIn analogIn15(____);
whismanoid 0:3edb3708c8c5 1351 #endif
whismanoid 0:3edb3708c8c5 1352 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1353 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 1354 #define HAS_analogIn0 1
whismanoid 0:3edb3708c8c5 1355 #define HAS_analogIn1 1
whismanoid 0:3edb3708c8c5 1356 #define HAS_analogIn2 1
whismanoid 0:3edb3708c8c5 1357 #define HAS_analogIn3 1
whismanoid 0:3edb3708c8c5 1358 #define HAS_analogIn4 1
whismanoid 0:3edb3708c8c5 1359 #define HAS_analogIn5 1
whismanoid 0:3edb3708c8c5 1360 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 1361 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1362 #endif
whismanoid 0:3edb3708c8c5 1363 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 1364 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1365 #endif
whismanoid 0:3edb3708c8c5 1366 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 1367 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1368 #endif
whismanoid 0:3edb3708c8c5 1369 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 1370 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:3edb3708c8c5 1371 #endif
whismanoid 0:3edb3708c8c5 1372 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 1373 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 1374 #endif
whismanoid 0:3edb3708c8c5 1375 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 1376 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 1377 #endif
whismanoid 0:3edb3708c8c5 1378 //--------------------------------------------------
whismanoid 11:9fa2402071de 1379 #elif defined(TARGET_MAX32600)
whismanoid 11:9fa2402071de 1380 #define HAS_analogIn0 1
whismanoid 11:9fa2402071de 1381 #define HAS_analogIn1 1
whismanoid 11:9fa2402071de 1382 #define HAS_analogIn2 1
whismanoid 11:9fa2402071de 1383 #define HAS_analogIn3 1
whismanoid 11:9fa2402071de 1384 #define HAS_analogIn4 1
whismanoid 11:9fa2402071de 1385 #define HAS_analogIn5 1
whismanoid 11:9fa2402071de 1386 #if HAS_analogIn0
whismanoid 11:9fa2402071de 1387 AnalogIn analogIn0(A0);
whismanoid 11:9fa2402071de 1388 #endif
whismanoid 11:9fa2402071de 1389 #if HAS_analogIn1
whismanoid 11:9fa2402071de 1390 AnalogIn analogIn1(A1);
whismanoid 11:9fa2402071de 1391 #endif
whismanoid 11:9fa2402071de 1392 #if HAS_analogIn2
whismanoid 11:9fa2402071de 1393 AnalogIn analogIn2(A2);
whismanoid 11:9fa2402071de 1394 #endif
whismanoid 11:9fa2402071de 1395 #if HAS_analogIn3
whismanoid 11:9fa2402071de 1396 AnalogIn analogIn3(A3);
whismanoid 11:9fa2402071de 1397 #endif
whismanoid 11:9fa2402071de 1398 #if HAS_analogIn4
whismanoid 11:9fa2402071de 1399 AnalogIn analogIn4(A4);
whismanoid 11:9fa2402071de 1400 #endif
whismanoid 11:9fa2402071de 1401 #if HAS_analogIn5
whismanoid 11:9fa2402071de 1402 AnalogIn analogIn5(A5);
whismanoid 11:9fa2402071de 1403 #endif
whismanoid 11:9fa2402071de 1404 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1405 #elif defined(TARGET_NUCLEO_F446RE)
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 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 1413 AnalogIn analogIn0(A0);
whismanoid 0:3edb3708c8c5 1414 #endif
whismanoid 0:3edb3708c8c5 1415 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 1416 AnalogIn analogIn1(A1);
whismanoid 0:3edb3708c8c5 1417 #endif
whismanoid 0:3edb3708c8c5 1418 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 1419 AnalogIn analogIn2(A2);
whismanoid 0:3edb3708c8c5 1420 #endif
whismanoid 0:3edb3708c8c5 1421 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 1422 AnalogIn analogIn3(A3);
whismanoid 0:3edb3708c8c5 1423 #endif
whismanoid 0:3edb3708c8c5 1424 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 1425 AnalogIn analogIn4(A4);
whismanoid 0:3edb3708c8c5 1426 #endif
whismanoid 0:3edb3708c8c5 1427 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 1428 AnalogIn analogIn5(A5);
whismanoid 0:3edb3708c8c5 1429 #endif
whismanoid 0:3edb3708c8c5 1430 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1431 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 1432 #define HAS_analogIn0 1
whismanoid 0:3edb3708c8c5 1433 #define HAS_analogIn1 1
whismanoid 0:3edb3708c8c5 1434 #define HAS_analogIn2 1
whismanoid 0:3edb3708c8c5 1435 #define HAS_analogIn3 1
whismanoid 0:3edb3708c8c5 1436 #define HAS_analogIn4 1
whismanoid 0:3edb3708c8c5 1437 #define HAS_analogIn5 1
whismanoid 0:3edb3708c8c5 1438 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 1439 AnalogIn analogIn0(A0);
whismanoid 0:3edb3708c8c5 1440 #endif
whismanoid 0:3edb3708c8c5 1441 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 1442 AnalogIn analogIn1(A1);
whismanoid 0:3edb3708c8c5 1443 #endif
whismanoid 0:3edb3708c8c5 1444 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 1445 AnalogIn analogIn2(A2);
whismanoid 0:3edb3708c8c5 1446 #endif
whismanoid 0:3edb3708c8c5 1447 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 1448 AnalogIn analogIn3(A3);
whismanoid 0:3edb3708c8c5 1449 #endif
whismanoid 0:3edb3708c8c5 1450 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 1451 AnalogIn analogIn4(A4);
whismanoid 0:3edb3708c8c5 1452 #endif
whismanoid 0:3edb3708c8c5 1453 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 1454 AnalogIn analogIn5(A5);
whismanoid 0:3edb3708c8c5 1455 #endif
whismanoid 0:3edb3708c8c5 1456 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1457 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:3edb3708c8c5 1458 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 1459 #define HAS_analogIn0 1
whismanoid 0:3edb3708c8c5 1460 #define HAS_analogIn1 1
whismanoid 0:3edb3708c8c5 1461 #define HAS_analogIn2 1
whismanoid 0:3edb3708c8c5 1462 #define HAS_analogIn3 1
whismanoid 0:3edb3708c8c5 1463 #define HAS_analogIn4 1
whismanoid 0:3edb3708c8c5 1464 #define HAS_analogIn5 1
whismanoid 0:3edb3708c8c5 1465 // #define HAS_analogIn6 1
whismanoid 0:3edb3708c8c5 1466 // #define HAS_analogIn7 1
whismanoid 0:3edb3708c8c5 1467 // #define HAS_analogIn8 1
whismanoid 0:3edb3708c8c5 1468 // #define HAS_analogIn9 1
whismanoid 0:3edb3708c8c5 1469 // #define HAS_analogIn10 1
whismanoid 0:3edb3708c8c5 1470 // #define HAS_analogIn11 1
whismanoid 0:3edb3708c8c5 1471 // #define HAS_analogIn12 1
whismanoid 0:3edb3708c8c5 1472 // #define HAS_analogIn13 1
whismanoid 0:3edb3708c8c5 1473 // #define HAS_analogIn14 1
whismanoid 0:3edb3708c8c5 1474 // #define HAS_analogIn15 1
whismanoid 0:3edb3708c8c5 1475 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 1476 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:3edb3708c8c5 1477 #endif
whismanoid 0:3edb3708c8c5 1478 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 1479 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:3edb3708c8c5 1480 #endif
whismanoid 0:3edb3708c8c5 1481 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 1482 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:3edb3708c8c5 1483 #endif
whismanoid 0:3edb3708c8c5 1484 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 1485 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:3edb3708c8c5 1486 #endif
whismanoid 0:3edb3708c8c5 1487 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 1488 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:3edb3708c8c5 1489 #endif
whismanoid 0:3edb3708c8c5 1490 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 1491 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:3edb3708c8c5 1492 #endif
whismanoid 0:3edb3708c8c5 1493 #if HAS_analogIn6
whismanoid 0:3edb3708c8c5 1494 AnalogIn analogIn6(____);
whismanoid 0:3edb3708c8c5 1495 #endif
whismanoid 0:3edb3708c8c5 1496 #if HAS_analogIn7
whismanoid 0:3edb3708c8c5 1497 AnalogIn analogIn7(____);
whismanoid 0:3edb3708c8c5 1498 #endif
whismanoid 0:3edb3708c8c5 1499 #if HAS_analogIn8
whismanoid 0:3edb3708c8c5 1500 AnalogIn analogIn8(____);
whismanoid 0:3edb3708c8c5 1501 #endif
whismanoid 0:3edb3708c8c5 1502 #if HAS_analogIn9
whismanoid 0:3edb3708c8c5 1503 AnalogIn analogIn9(____);
whismanoid 0:3edb3708c8c5 1504 #endif
whismanoid 0:3edb3708c8c5 1505 #if HAS_analogIn10
whismanoid 0:3edb3708c8c5 1506 AnalogIn analogIn10(____);
whismanoid 0:3edb3708c8c5 1507 #endif
whismanoid 0:3edb3708c8c5 1508 #if HAS_analogIn11
whismanoid 0:3edb3708c8c5 1509 AnalogIn analogIn11(____);
whismanoid 0:3edb3708c8c5 1510 #endif
whismanoid 0:3edb3708c8c5 1511 #if HAS_analogIn12
whismanoid 0:3edb3708c8c5 1512 AnalogIn analogIn12(____);
whismanoid 0:3edb3708c8c5 1513 #endif
whismanoid 0:3edb3708c8c5 1514 #if HAS_analogIn13
whismanoid 0:3edb3708c8c5 1515 AnalogIn analogIn13(____);
whismanoid 0:3edb3708c8c5 1516 #endif
whismanoid 0:3edb3708c8c5 1517 #if HAS_analogIn14
whismanoid 0:3edb3708c8c5 1518 AnalogIn analogIn14(____);
whismanoid 0:3edb3708c8c5 1519 #endif
whismanoid 0:3edb3708c8c5 1520 #if HAS_analogIn15
whismanoid 0:3edb3708c8c5 1521 AnalogIn analogIn15(____);
whismanoid 0:3edb3708c8c5 1522 #endif
whismanoid 0:3edb3708c8c5 1523 #else
whismanoid 0:3edb3708c8c5 1524 // unknown target
whismanoid 0:3edb3708c8c5 1525 #endif
whismanoid 0:3edb3708c8c5 1526 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:3edb3708c8c5 1527 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:3edb3708c8c5 1528 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:3edb3708c8c5 1529 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:3edb3708c8c5 1530 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:3edb3708c8c5 1531 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:3edb3708c8c5 1532 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:3edb3708c8c5 1533 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:3edb3708c8c5 1534 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:3edb3708c8c5 1535 #define HAS_analogIns 1
whismanoid 0:3edb3708c8c5 1536 #endif
whismanoid 0:3edb3708c8c5 1537
whismanoid 0:3edb3708c8c5 1538 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1539 // Option to use LEDs to show status
whismanoid 0:3edb3708c8c5 1540 #ifndef USE_LEDS
whismanoid 0:3edb3708c8c5 1541 #define USE_LEDS 1
whismanoid 0:3edb3708c8c5 1542 #endif
whismanoid 0:3edb3708c8c5 1543 #if USE_LEDS
whismanoid 0:3edb3708c8c5 1544 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 1545 # define LED_ON 0
whismanoid 0:3edb3708c8c5 1546 # define LED_OFF 1
whismanoid 0:3edb3708c8c5 1547 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1548 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 1549 # define LED_ON 0
whismanoid 0:3edb3708c8c5 1550 # define LED_OFF 1
whismanoid 0:3edb3708c8c5 1551 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1552 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:3edb3708c8c5 1553 #elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 1554 # define LED_ON 1
whismanoid 0:3edb3708c8c5 1555 # define LED_OFF 0
whismanoid 0:3edb3708c8c5 1556 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:3edb3708c8c5 1557 # define LED_ON 1
whismanoid 0:3edb3708c8c5 1558 # define LED_OFF 0
whismanoid 0:3edb3708c8c5 1559 #endif // target definition
whismanoid 0:3edb3708c8c5 1560 DigitalOut led1(LED1, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 0:3edb3708c8c5 1561 DigitalOut led2(LED2, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 0:3edb3708c8c5 1562 DigitalOut led3(LED3, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 0:3edb3708c8c5 1563 DigitalOut led4(LED4, LED_OFF);
whismanoid 12:5d3f9663ea0c 1564 #else // USE_LEDS=0
whismanoid 12:5d3f9663ea0c 1565 // issue #41 support Nucleo_F446RE
whismanoid 12:5d3f9663ea0c 1566 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 12:5d3f9663ea0c 1567 // but we still need placeholders led1 led2 led3 led4.
whismanoid 12:5d3f9663ea0c 1568 // Declare DigitalOut led1 led2 led3 led4 targeting safe pins.
whismanoid 12:5d3f9663ea0c 1569 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 12:5d3f9663ea0c 1570 # define LED_ON 0
whismanoid 12:5d3f9663ea0c 1571 # define LED_OFF 1
whismanoid 12:5d3f9663ea0c 1572 DigitalOut led1(NC, LED_OFF);
whismanoid 12:5d3f9663ea0c 1573 DigitalOut led2(NC, LED_OFF);
whismanoid 12:5d3f9663ea0c 1574 DigitalOut led3(NC, LED_OFF);
whismanoid 12:5d3f9663ea0c 1575 DigitalOut led4(NC, LED_OFF);
whismanoid 0:3edb3708c8c5 1576 #endif // USE_LEDS
whismanoid 0:3edb3708c8c5 1577
whismanoid 0:3edb3708c8c5 1578 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1579 #if USE_LEDS
whismanoid 0:3edb3708c8c5 1580 class RGB_LED {
whismanoid 0:3edb3708c8c5 1581 public:
whismanoid 0:3edb3708c8c5 1582 RGB_LED(DigitalOut &led_red, DigitalOut &led_green, DigitalOut &led_blue)
whismanoid 0:3edb3708c8c5 1583 : m_red(led_red), m_green(led_green), m_blue(led_blue)
whismanoid 0:3edb3708c8c5 1584 {
whismanoid 0:3edb3708c8c5 1585 };
whismanoid 0:3edb3708c8c5 1586 DigitalOut &m_red;
whismanoid 0:3edb3708c8c5 1587 DigitalOut &m_green;
whismanoid 0:3edb3708c8c5 1588 DigitalOut &m_blue;
whismanoid 0:3edb3708c8c5 1589 ~RGB_LED()
whismanoid 0:3edb3708c8c5 1590 {
whismanoid 0:3edb3708c8c5 1591 };
whismanoid 0:3edb3708c8c5 1592 /* diagnostic rbg led RED
whismanoid 0:3edb3708c8c5 1593 */
whismanoid 0:3edb3708c8c5 1594 void red() {
whismanoid 0:3edb3708c8c5 1595 m_red = LED_ON; m_green = LED_OFF; m_blue = LED_OFF; // diagnostic rbg led RED
whismanoid 0:3edb3708c8c5 1596 };
whismanoid 0:3edb3708c8c5 1597 /* diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 1598 */
whismanoid 0:3edb3708c8c5 1599 void green() {
whismanoid 0:3edb3708c8c5 1600 m_red = LED_OFF; m_green = LED_ON; m_blue = LED_OFF; // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 1601 };
whismanoid 0:3edb3708c8c5 1602 /* diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 1603 */
whismanoid 0:3edb3708c8c5 1604 void blue() {
whismanoid 0:3edb3708c8c5 1605 m_red = LED_OFF; m_green = LED_OFF; m_blue = LED_ON; // diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 1606 };
whismanoid 0:3edb3708c8c5 1607 /* diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 0:3edb3708c8c5 1608 */
whismanoid 0:3edb3708c8c5 1609 void white() {
whismanoid 0:3edb3708c8c5 1610 m_red = LED_ON; m_green = LED_ON; m_blue = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 0:3edb3708c8c5 1611 };
whismanoid 0:3edb3708c8c5 1612 /* diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 0:3edb3708c8c5 1613 */
whismanoid 0:3edb3708c8c5 1614 void cyan() {
whismanoid 0:3edb3708c8c5 1615 m_red = LED_OFF; m_green = LED_ON; m_blue = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 0:3edb3708c8c5 1616 };
whismanoid 0:3edb3708c8c5 1617 /* diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 0:3edb3708c8c5 1618 */
whismanoid 0:3edb3708c8c5 1619 void magenta() {
whismanoid 0:3edb3708c8c5 1620 m_red = LED_ON; m_green = LED_OFF; m_blue = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 0:3edb3708c8c5 1621 };
whismanoid 0:3edb3708c8c5 1622 /* diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 1623 */
whismanoid 0:3edb3708c8c5 1624 void yellow() {
whismanoid 0:3edb3708c8c5 1625 m_red = LED_ON; m_green = LED_ON; m_blue = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 1626 };
whismanoid 0:3edb3708c8c5 1627 /* diagnostic rbg led BLACK
whismanoid 0:3edb3708c8c5 1628 */
whismanoid 0:3edb3708c8c5 1629 void black() {
whismanoid 0:3edb3708c8c5 1630 m_red = LED_OFF; m_green = LED_OFF; m_blue = LED_OFF; // diagnostic rbg led BLACK
whismanoid 0:3edb3708c8c5 1631 };
whismanoid 0:3edb3708c8c5 1632 };
whismanoid 0:3edb3708c8c5 1633 RGB_LED rgb_led(led1, led2, led3); // red, green, blue LEDs
whismanoid 0:3edb3708c8c5 1634 #endif // USE_LEDS
whismanoid 0:3edb3708c8c5 1635
whismanoid 0:3edb3708c8c5 1636 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1637 // use BUTTON1 trigger some action
whismanoid 0:3edb3708c8c5 1638 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 1639 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 13:e36d51f46794 1640 #define HAS_BUTTON2_DEMO 0
whismanoid 13:e36d51f46794 1641 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 0:3edb3708c8c5 1642 #elif defined(TARGET_MAX32625)
whismanoid 0:3edb3708c8c5 1643 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 0:3edb3708c8c5 1644 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 0:3edb3708c8c5 1645 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 1646 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 0:3edb3708c8c5 1647 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 0:3edb3708c8c5 1648 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 1649 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 0:3edb3708c8c5 1650 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 0:3edb3708c8c5 1651 #endif
whismanoid 0:3edb3708c8c5 1652 //
whismanoid 0:3edb3708c8c5 1653 #ifndef HAS_BUTTON1_DEMO
whismanoid 0:3edb3708c8c5 1654 #define HAS_BUTTON1_DEMO 0
whismanoid 0:3edb3708c8c5 1655 #endif
whismanoid 0:3edb3708c8c5 1656 #ifndef HAS_BUTTON2_DEMO
whismanoid 0:3edb3708c8c5 1657 #define HAS_BUTTON2_DEMO 0
whismanoid 0:3edb3708c8c5 1658 #endif
whismanoid 0:3edb3708c8c5 1659 //
whismanoid 0:3edb3708c8c5 1660 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 0:3edb3708c8c5 1661 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 0:3edb3708c8c5 1662 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 1663 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 0:3edb3708c8c5 1664 #endif
whismanoid 0:3edb3708c8c5 1665 //
whismanoid 0:3edb3708c8c5 1666 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 1667 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 0:3edb3708c8c5 1668 #endif
whismanoid 0:3edb3708c8c5 1669 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 1670 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 0:3edb3708c8c5 1671 #endif
whismanoid 0:3edb3708c8c5 1672 //
whismanoid 0:3edb3708c8c5 1673 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 1674 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 1675 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 0:3edb3708c8c5 1676 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 0:3edb3708c8c5 1677 DigitalIn button1(BUTTON1);
whismanoid 0:3edb3708c8c5 1678 # else
whismanoid 0:3edb3708c8c5 1679 InterruptIn button1(BUTTON1);
whismanoid 0:3edb3708c8c5 1680 # endif
whismanoid 0:3edb3708c8c5 1681 #elif HAS_BUTTON1_DEMO
whismanoid 0:3edb3708c8c5 1682 DigitalIn button1(BUTTON1);
whismanoid 0:3edb3708c8c5 1683 #endif
whismanoid 0:3edb3708c8c5 1684 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 1685 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 1686 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 0:3edb3708c8c5 1687 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 0:3edb3708c8c5 1688 DigitalIn button2(BUTTON2);
whismanoid 0:3edb3708c8c5 1689 # else
whismanoid 0:3edb3708c8c5 1690 InterruptIn button2(BUTTON2);
whismanoid 0:3edb3708c8c5 1691 # endif
whismanoid 0:3edb3708c8c5 1692 #elif HAS_BUTTON2_DEMO
whismanoid 0:3edb3708c8c5 1693 DigitalIn button2(BUTTON2);
whismanoid 0:3edb3708c8c5 1694 #endif
whismanoid 0:3edb3708c8c5 1695
whismanoid 0:3edb3708c8c5 1696 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 1697 // Ticker is the periodic interrupt timer itself
whismanoid 0:3edb3708c8c5 1698 #define USE_PERIODIC_TIMER 0
whismanoid 0:3edb3708c8c5 1699 #if USE_PERIODIC_TIMER
whismanoid 0:3edb3708c8c5 1700 Ticker periodicInterruptTimer;
whismanoid 0:3edb3708c8c5 1701 us_timestamp_t periodicInterruptTimer_interval_usec = 50;
whismanoid 0:3edb3708c8c5 1702 us_timestamp_t periodicInterruptTimer_interval_usec_MAX = 1000;
whismanoid 0:3edb3708c8c5 1703 us_timestamp_t periodicInterruptTimer_interval_usec_MIN = 20;
whismanoid 0:3edb3708c8c5 1704 #endif
whismanoid 0:3edb3708c8c5 1705
whismanoid 0:3edb3708c8c5 1706
whismanoid 0:3edb3708c8c5 1707 #if APPLICATION_MAX11131 // hardware interface functions
whismanoid 0:3edb3708c8c5 1708 //----------------------------------------
whismanoid 0:3edb3708c8c5 1709 void print_value(CmdLine& cmdLine, int16_t value_u12, int channelId)
whismanoid 0:3edb3708c8c5 1710 {
whismanoid 0:3edb3708c8c5 1711 int channelPairIndex = channelId / 2;
whismanoid 0:3edb3708c8c5 1712 // 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 1713 // unused variable: int UCHn = (g_MAX11131_device.UNIPOLAR >> (10 - channelPairIndex)) & 0x01;
whismanoid 0:3edb3708c8c5 1714 int BCHn = (g_MAX11131_device.BIPOLAR >> (10 - channelPairIndex)) & 0x01;
whismanoid 0:3edb3708c8c5 1715 // unused variable: int RANGEn = (g_MAX11131_device.RANGE >> (10 - channelPairIndex)) & 0x01;
whismanoid 0:3edb3708c8c5 1716 //
whismanoid 0:3edb3708c8c5 1717 cmdLine.serial().printf(" ch=");
whismanoid 0:3edb3708c8c5 1718 // TODO1: if CHANID=0 don't print ch=channelId
whismanoid 0:3edb3708c8c5 1719 if ((g_MAX11131_device.isExternalClock == 0) || (g_MAX11131_device.chan_id_0_1 == 1))
whismanoid 0:3edb3708c8c5 1720 {
whismanoid 0:3edb3708c8c5 1721 // Internal clock modes always use channel ID.
whismanoid 0:3edb3708c8c5 1722 // External clock modes use channel ID if ADC_MODE_CONTROL.CHAN_ID is 1.
whismanoid 0:3edb3708c8c5 1723 cmdLine.serial().printf("%d", channelId);
whismanoid 0:3edb3708c8c5 1724 } else {
whismanoid 0:3edb3708c8c5 1725 cmdLine.serial().printf("?");
whismanoid 0:3edb3708c8c5 1726 }
whismanoid 0:3edb3708c8c5 1727 if (BCHn)
whismanoid 0:3edb3708c8c5 1728 {
whismanoid 3:8913cb4a8b9f 1729 cmdLine.serial().printf(" xb=%ld", g_MAX11131_device.TwosComplementValue(value_u12));
whismanoid 0:3edb3708c8c5 1730 }
whismanoid 0:3edb3708c8c5 1731 else
whismanoid 0:3edb3708c8c5 1732 {
whismanoid 0:3edb3708c8c5 1733 cmdLine.serial().printf(" xu=%d", value_u12);
whismanoid 0:3edb3708c8c5 1734 }
whismanoid 0:3edb3708c8c5 1735 cmdLine.serial().printf(" = 0x%4.4x = %6.4fV",
whismanoid 0:3edb3708c8c5 1736 (value_u12 & 0xFFFF),
whismanoid 0:3edb3708c8c5 1737 g_MAX11131_device.VoltageOfCode(value_u12, channelId)
whismanoid 0:3edb3708c8c5 1738 );
whismanoid 0:3edb3708c8c5 1739 // dtostrf width and precision: 2.5v / 4096 LSB = 0.0006103515625 volts per LSB
whismanoid 0:3edb3708c8c5 1740 }
whismanoid 0:3edb3708c8c5 1741
whismanoid 0:3edb3708c8c5 1742 //----------------------------------------
whismanoid 0:3edb3708c8c5 1743 // read data words
whismanoid 0:3edb3708c8c5 1744 // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 1745 // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 1746 // For internal clock modes, the data format always includes the channel address.
whismanoid 0:3edb3708c8c5 1747 // misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 1748 void AINcode_print_value_chanID(CmdLine& cmdLine, int nWords)
whismanoid 0:3edb3708c8c5 1749 {
whismanoid 0:3edb3708c8c5 1750 cmdLine.serial().printf("ScanRead_nWords_chanID nWords=%d\r\n", nWords);
whismanoid 0:3edb3708c8c5 1751 for (int index = 0; index < nWords; index++) {
whismanoid 0:3edb3708c8c5 1752 //~ int16_t misoData16 = MAX11131_ScanRead();
whismanoid 0:3edb3708c8c5 1753 // For internal clock modes, the data format always includes the channel address.
whismanoid 0:3edb3708c8c5 1754 // misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 1755 int16_t value_u12 = (g_MAX11131_device.RAW_misoData16[index] & 0x0FFF);
whismanoid 0:3edb3708c8c5 1756 int channelId = ((g_MAX11131_device.RAW_misoData16[index] >> 12) & 0x000F);
whismanoid 0:3edb3708c8c5 1757 // diagnostic: print raw MISO data
whismanoid 0:3edb3708c8c5 1758 cmdLine.serial().printf(" MAX11131.MISO[%u]=0x%4.4x:", index,
whismanoid 0:3edb3708c8c5 1759 (g_MAX11131_device.RAW_misoData16[index] & 0xFFFF));
whismanoid 0:3edb3708c8c5 1760 print_value(cmdLine, value_u12, channelId);
whismanoid 0:3edb3708c8c5 1761 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 1762 }
whismanoid 0:3edb3708c8c5 1763 }
whismanoid 0:3edb3708c8c5 1764
whismanoid 0:3edb3708c8c5 1765 //----------------------------------------
whismanoid 0:3edb3708c8c5 1766 // read data words
whismanoid 0:3edb3708c8c5 1767 // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 1768 // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 1769 // For external clock modes, the data format returned depends on the CHAN_ID bit.
whismanoid 0:3edb3708c8c5 1770 // when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x
whismanoid 0:3edb3708c8c5 1771 // when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 1772 void AINcode_print_value_externalClock(CmdLine& cmdLine, int nWords)
whismanoid 0:3edb3708c8c5 1773 {
whismanoid 0:3edb3708c8c5 1774 // For external clock modes, the data format returned depends on the CHAN_ID bit.
whismanoid 0:3edb3708c8c5 1775 // when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x
whismanoid 0:3edb3708c8c5 1776 // when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 1777 // For internal clock modes, the data format always includes the channel address.
whismanoid 0:3edb3708c8c5 1778 // misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 1779 if (g_MAX11131_device.chan_id_0_1 != 0) {
whismanoid 0:3edb3708c8c5 1780 AINcode_print_value_chanID(cmdLine, nWords);
whismanoid 0:3edb3708c8c5 1781 return;
whismanoid 0:3edb3708c8c5 1782 }
whismanoid 0:3edb3708c8c5 1783 cmdLine.serial().printf("ScanRead_nWords_externalClock nWords=%d\r\n", nWords);
whismanoid 0:3edb3708c8c5 1784 for (int index = 0; index < nWords; index++) {
whismanoid 0:3edb3708c8c5 1785 // int16_t misoData16 = MAX11131_ScanRead();
whismanoid 0:3edb3708c8c5 1786 int16_t value_u12 = ((g_MAX11131_device.RAW_misoData16[index] >> 3) & 0x0FFF);
whismanoid 0:3edb3708c8c5 1787 int channelId = g_MAX11131_device.channelNumber_0_15;
whismanoid 0:3edb3708c8c5 1788 // diagnostic: print raw MISO data
whismanoid 0:3edb3708c8c5 1789 cmdLine.serial().printf(" MAX11131.MISO[%u]=0x%4.4x:", index,
whismanoid 0:3edb3708c8c5 1790 (g_MAX11131_device.RAW_misoData16[index] & 0xFFFF));
whismanoid 0:3edb3708c8c5 1791 print_value(cmdLine, value_u12, channelId);
whismanoid 0:3edb3708c8c5 1792 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 1793 }
whismanoid 0:3edb3708c8c5 1794 }
whismanoid 0:3edb3708c8c5 1795
whismanoid 0:3edb3708c8c5 1796 //----------------------------------------
whismanoid 0:3edb3708c8c5 1797 // read data words and calculate mean, stddev
whismanoid 0:3edb3708c8c5 1798 // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 1799 // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 1800 void AINcode_print_value_chanID_mean(CmdLine& cmdLine, int nWords)
whismanoid 0:3edb3708c8c5 1801 {
whismanoid 0:3edb3708c8c5 1802 cmdLine.serial().printf("ScanRead_nWords_chanID_mean nWords=%d\r\n", nWords);
whismanoid 0:3edb3708c8c5 1803 double Sx = 0;
whismanoid 0:3edb3708c8c5 1804 double Sxx = 0;
whismanoid 0:3edb3708c8c5 1805 for (int index = 0; index < nWords; index++) {
whismanoid 0:3edb3708c8c5 1806 //~ int16_t misoData16 = MAX11131_ScanRead();
whismanoid 0:3edb3708c8c5 1807 // For internal clock modes, the data format always includes the channel address.
whismanoid 0:3edb3708c8c5 1808 // misoData16 = CH[3:0] DATA[11:0]
whismanoid 0:3edb3708c8c5 1809 int16_t value_u12 = (g_MAX11131_device.RAW_misoData16[index] & 0x0FFF);
whismanoid 0:3edb3708c8c5 1810 int channelId = ((g_MAX11131_device.RAW_misoData16[index] >> 12) & 0x000F);
whismanoid 0:3edb3708c8c5 1811 // TODO: sign-extend value_s12 from value_u12
whismanoid 0:3edb3708c8c5 1812 //
whismanoid 0:3edb3708c8c5 1813 cmdLine.serial().printf("n=%d", index);
whismanoid 0:3edb3708c8c5 1814 print_value(cmdLine, value_u12, channelId);
whismanoid 0:3edb3708c8c5 1815 //
whismanoid 0:3edb3708c8c5 1816 Sx = Sx + value_u12;
whismanoid 0:3edb3708c8c5 1817 Sxx = Sxx + ((double)value_u12 * value_u12);
whismanoid 0:3edb3708c8c5 1818 cmdLine.serial().printf(" Sx=%f Sxx=%f\r\n", Sx, Sxx);
whismanoid 0:3edb3708c8c5 1819 }
whismanoid 0:3edb3708c8c5 1820 double mean = Sx / nWords;
whismanoid 0:3edb3708c8c5 1821 cmdLine.serial().printf(" mean=%f=0x%4.4x", mean, (int)mean);
whismanoid 0:3edb3708c8c5 1822 // calculate standard deviation from N, Sx, Sxx
whismanoid 0:3edb3708c8c5 1823 if (nWords >= 2)
whismanoid 0:3edb3708c8c5 1824 {
whismanoid 0:3edb3708c8c5 1825 double variance = (Sxx - ( Sx * Sx / nWords)) / (nWords - 1);
whismanoid 0:3edb3708c8c5 1826 // stddev = square root of variance
whismanoid 0:3edb3708c8c5 1827 double stddev = sqrt(variance);
whismanoid 0:3edb3708c8c5 1828 cmdLine.serial().printf(" variance=%f stddev=%f", variance, stddev);
whismanoid 0:3edb3708c8c5 1829 }
whismanoid 0:3edb3708c8c5 1830 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 1831 }
whismanoid 0:3edb3708c8c5 1832
whismanoid 0:3edb3708c8c5 1833 /* MAX11131_print_register_verbose
whismanoid 0:3edb3708c8c5 1834 *
whismanoid 0:3edb3708c8c5 1835 * TODO: document this function
whismanoid 0:3edb3708c8c5 1836 * This header was inserted by uncrustify; see uncrustify_func_header.txt.
whismanoid 0:3edb3708c8c5 1837 *
whismanoid 0:3edb3708c8c5 1838 */
whismanoid 0:3edb3708c8c5 1839 void MAX11131_print_register_verbose(CmdLine& cmdLine, int16_t registerData)
whismanoid 0:3edb3708c8c5 1840 {
whismanoid 0:3edb3708c8c5 1841 if (registerData & 0x8000)
whismanoid 0:3edb3708c8c5 1842 {
whismanoid 0:3edb3708c8c5 1843 switch (registerData & 0xF800)
whismanoid 0:3edb3708c8c5 1844 {
whismanoid 0:3edb3708c8c5 1845 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 1846 cmdLine.serial().printf(" ADC_CONFIGURATION");
whismanoid 0:3edb3708c8c5 1847 {
whismanoid 0:3edb3708c8c5 1848 // define write-only register ADC_CONFIGURATION
whismanoid 0:3edb3708c8c5 1849 //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 1850 const int REFSEL_LSB = 10; const int REFSEL_BITS = 0x01; // ADC_CONFIGURATION.REFSEL
whismanoid 0:3edb3708c8c5 1851 const int AVGON_LSB = 9; const int AVGON_BITS = 0x01; // ADC_CONFIGURATION.AVGON
whismanoid 0:3edb3708c8c5 1852 const int NAVG_LSB = 7; const int NAVG_BITS = 0x03; // ADC_CONFIGURATION.NAVG[1:0]
whismanoid 0:3edb3708c8c5 1853 const int NSCAN_LSB = 5; const int NSCAN_BITS = 0x03; // ADC_CONFIGURATION.NSCAN[1:0]
whismanoid 0:3edb3708c8c5 1854 const int SPM_LSB = 3; const int SPM_BITS = 0x03; // ADC_CONFIGURATION.SPM[1:0]
whismanoid 0:3edb3708c8c5 1855 const int ECHO_LSB = 2; const int ECHO_BITS = 0x01; // ADC_CONFIGURATION.ECHO
whismanoid 0:3edb3708c8c5 1856
whismanoid 0:3edb3708c8c5 1857 const int REFSEL = ((registerData >> REFSEL_LSB) & REFSEL_BITS);
whismanoid 0:3edb3708c8c5 1858 const int AVGON = ((registerData >> AVGON_LSB) & AVGON_BITS);
whismanoid 0:3edb3708c8c5 1859 const int NAVG = ((registerData >> NAVG_LSB) & NAVG_BITS);
whismanoid 0:3edb3708c8c5 1860 const int NSCAN = ((registerData >> NSCAN_LSB) & NSCAN_BITS);
whismanoid 0:3edb3708c8c5 1861 const int SPM = ((registerData >> SPM_LSB) & SPM_BITS);
whismanoid 0:3edb3708c8c5 1862 const int ECHO = ((registerData >> ECHO_LSB) & ECHO_BITS);
whismanoid 0:3edb3708c8c5 1863
whismanoid 0:3edb3708c8c5 1864 if (REFSEL) {
whismanoid 0:3edb3708c8c5 1865 cmdLine.serial().printf(" REFSEL=%d", REFSEL);
whismanoid 0:3edb3708c8c5 1866 }
whismanoid 0:3edb3708c8c5 1867 if (AVGON) {
whismanoid 0:3edb3708c8c5 1868 cmdLine.serial().printf(" AVGON=%d", AVGON);
whismanoid 0:3edb3708c8c5 1869 }
whismanoid 0:3edb3708c8c5 1870 if (NAVG) {
whismanoid 0:3edb3708c8c5 1871 cmdLine.serial().printf(" NAVG=%d", NAVG);
whismanoid 0:3edb3708c8c5 1872 }
whismanoid 0:3edb3708c8c5 1873 if (NSCAN) {
whismanoid 0:3edb3708c8c5 1874 cmdLine.serial().printf(" NSCAN=%d", NSCAN);
whismanoid 0:3edb3708c8c5 1875 }
whismanoid 0:3edb3708c8c5 1876 if (SPM) {
whismanoid 0:3edb3708c8c5 1877 cmdLine.serial().printf(" SPM=%d", SPM);
whismanoid 0:3edb3708c8c5 1878 }
whismanoid 0:3edb3708c8c5 1879 if (ECHO) {
whismanoid 0:3edb3708c8c5 1880 cmdLine.serial().printf(" ECHO=%d", ECHO);
whismanoid 0:3edb3708c8c5 1881 }
whismanoid 0:3edb3708c8c5 1882 }
whismanoid 0:3edb3708c8c5 1883 break;
whismanoid 0:3edb3708c8c5 1884 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 1885 cmdLine.serial().printf(" UNIPOLAR 0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 1886 if ((registerData >> 2) & 0x01) {
whismanoid 0:3edb3708c8c5 1887 cmdLine.serial().printf(" PDIFF_COM");
whismanoid 0:3edb3708c8c5 1888 }
whismanoid 0:3edb3708c8c5 1889 break;
whismanoid 0:3edb3708c8c5 1890 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 1891 cmdLine.serial().printf(" BIPOLAR 0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 1892 break;
whismanoid 0:3edb3708c8c5 1893 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 1894 cmdLine.serial().printf(" RANGE 0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 1895 break;
whismanoid 0:3edb3708c8c5 1896 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 1897 cmdLine.serial().printf(" CSCAN0 0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 1898 break;
whismanoid 0:3edb3708c8c5 1899 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 1900 cmdLine.serial().printf(" CSCAN1 0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 1901 break;
whismanoid 0:3edb3708c8c5 1902 case 0xB000: // SAMPLESET 0xB000..0xB7FF format: 1 0 1 1 0 SEQ_LENGTH[7:0] x x x
whismanoid 0:3edb3708c8c5 1903 cmdLine.serial().printf(" SAMPLESET SEQ_LENGTH[7:0]=0x%4.4x", ((registerData >> 3) & 0xFF));
whismanoid 0:3edb3708c8c5 1904 cmdLine.serial().printf(" so length=%d channels", (((registerData >> 3) & 0xFF) + 1));
whismanoid 0:3edb3708c8c5 1905 break;
whismanoid 0:3edb3708c8c5 1906 default:
whismanoid 0:3edb3708c8c5 1907 cmdLine.serial().printf(" ???");
whismanoid 0:3edb3708c8c5 1908 break;
whismanoid 0:3edb3708c8c5 1909 }
whismanoid 0:3edb3708c8c5 1910 }
whismanoid 0:3edb3708c8c5 1911 else
whismanoid 0:3edb3708c8c5 1912 {
whismanoid 0:3edb3708c8c5 1913 // 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 1914 cmdLine.serial().printf(" ADC_MODE_CONTROL");
whismanoid 0:3edb3708c8c5 1915
whismanoid 0:3edb3708c8c5 1916 // define write-only register ADC_MODE_CONTROL
whismanoid 0:3edb3708c8c5 1917 //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 1918 const int SCAN_LSB = 11; const int SCAN_BITS = 0x0F; //!< ADC_MODE_CONTROL.SCAN[3:0] ADC Scan Control (command)
whismanoid 0:3edb3708c8c5 1919 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 1920 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 1921 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 1922 const int CHAN_ID_LSB = 2; const int CHAN_ID_BITS = 0x01; //!< ADC_MODE_CONTROL.CHAN_ID
whismanoid 0:3edb3708c8c5 1923 const int SWCNV_LSB = 1; const int SWCNV_BITS = 0x01; //!< ADC_MODE_CONTROL.SWCNV
whismanoid 0:3edb3708c8c5 1924
whismanoid 0:3edb3708c8c5 1925 const int SCAN = ((registerData >> SCAN_LSB) & SCAN_BITS);
whismanoid 0:3edb3708c8c5 1926 const int CHSEL = ((registerData >> CHSEL_LSB) & CHSEL_BITS);
whismanoid 0:3edb3708c8c5 1927 const int RESET = ((registerData >> RESET_LSB) & RESET_BITS);
whismanoid 0:3edb3708c8c5 1928 const int PM = ((registerData >> PM_LSB) & PM_BITS);
whismanoid 0:3edb3708c8c5 1929 const int CHANID = ((registerData >> CHAN_ID_LSB) & CHAN_ID_BITS);
whismanoid 0:3edb3708c8c5 1930 const int SWCNV = ((registerData >> SWCNV_LSB) & SWCNV_BITS);
whismanoid 0:3edb3708c8c5 1931
whismanoid 0:3edb3708c8c5 1932 switch (SCAN)
whismanoid 0:3edb3708c8c5 1933 {
whismanoid 0:3edb3708c8c5 1934 case MAX11131::SCAN_0000_NOP:
whismanoid 0:3edb3708c8c5 1935 cmdLine.serial().printf(" SCAN_0000_NOP");
whismanoid 0:3edb3708c8c5 1936 break;
whismanoid 0:3edb3708c8c5 1937 case MAX11131::SCAN_0001_Manual:
whismanoid 0:3edb3708c8c5 1938 cmdLine.serial().printf(" SCAN_0001_Manual CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 1939 break;
whismanoid 0:3edb3708c8c5 1940 case MAX11131::SCAN_0010_Repeat:
whismanoid 0:3edb3708c8c5 1941 cmdLine.serial().printf(" SCAN_0010_Repeat CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 1942 break;
whismanoid 0:3edb3708c8c5 1943 case MAX11131::SCAN_0011_StandardInternalClock:
whismanoid 0:3edb3708c8c5 1944 cmdLine.serial().printf(" SCAN_0011_StandardInt CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 1945 break;
whismanoid 0:3edb3708c8c5 1946 case MAX11131::SCAN_0100_StandardExternalClock:
whismanoid 0:3edb3708c8c5 1947 cmdLine.serial().printf(" SCAN_0100_StandardExt CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 1948 break;
whismanoid 0:3edb3708c8c5 1949 case MAX11131::SCAN_0101_UpperInternalClock:
whismanoid 0:3edb3708c8c5 1950 cmdLine.serial().printf(" SCAN_0101_UpperInt CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 1951 break;
whismanoid 0:3edb3708c8c5 1952 case MAX11131::SCAN_0110_UpperExternalClock:
whismanoid 0:3edb3708c8c5 1953 cmdLine.serial().printf(" SCAN_0110_UpperExt CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 1954 break;
whismanoid 0:3edb3708c8c5 1955 case MAX11131::SCAN_0111_CustomInternalClock:
whismanoid 0:3edb3708c8c5 1956 cmdLine.serial().printf(" SCAN_0111_CustomInt");
whismanoid 0:3edb3708c8c5 1957 break;
whismanoid 0:3edb3708c8c5 1958 case MAX11131::SCAN_1000_CustomExternalClock:
whismanoid 0:3edb3708c8c5 1959 cmdLine.serial().printf(" SCAN_1000_CustomExt");
whismanoid 0:3edb3708c8c5 1960 break;
whismanoid 0:3edb3708c8c5 1961 case MAX11131::SCAN_1001_SampleSetExternalClock:
whismanoid 0:3edb3708c8c5 1962 cmdLine.serial().printf(" SCAN_1001_SampleSetExt");
whismanoid 0:3edb3708c8c5 1963 break;
whismanoid 0:3edb3708c8c5 1964 default:
whismanoid 0:3edb3708c8c5 1965 cmdLine.serial().printf(" SCAN=%d", SCAN);
whismanoid 0:3edb3708c8c5 1966 cmdLine.serial().printf(" CHSEL=%d", CHSEL);
whismanoid 0:3edb3708c8c5 1967 }
whismanoid 0:3edb3708c8c5 1968 if (RESET) {
whismanoid 0:3edb3708c8c5 1969 cmdLine.serial().printf(" RESET=%d", RESET);
whismanoid 0:3edb3708c8c5 1970 }
whismanoid 0:3edb3708c8c5 1971 if (PM) {
whismanoid 0:3edb3708c8c5 1972 cmdLine.serial().printf(" PM=%d", PM);
whismanoid 0:3edb3708c8c5 1973 }
whismanoid 0:3edb3708c8c5 1974 if (SCAN != MAX11131::SCAN_0000_NOP)
whismanoid 0:3edb3708c8c5 1975 {
whismanoid 0:3edb3708c8c5 1976 if (g_MAX11131_device.isExternalClock)
whismanoid 0:3edb3708c8c5 1977 {
whismanoid 0:3edb3708c8c5 1978 // if external clock mode, print CHANID
whismanoid 0:3edb3708c8c5 1979 cmdLine.serial().printf(" CHANID=%d", CHANID);
whismanoid 0:3edb3708c8c5 1980 }
whismanoid 0:3edb3708c8c5 1981 else
whismanoid 0:3edb3708c8c5 1982 {
whismanoid 0:3edb3708c8c5 1983 // if internal clock mode, print SWCNV
whismanoid 0:3edb3708c8c5 1984 cmdLine.serial().printf(" SWCNV=%d", SWCNV);
whismanoid 0:3edb3708c8c5 1985 }
whismanoid 0:3edb3708c8c5 1986 }
whismanoid 0:3edb3708c8c5 1987 }
whismanoid 0:3edb3708c8c5 1988 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 1989 }
whismanoid 0:3edb3708c8c5 1990 #endif
whismanoid 0:3edb3708c8c5 1991
whismanoid 0:3edb3708c8c5 1992
whismanoid 0:3edb3708c8c5 1993 #if APPLICATION_MAX5171 // hardware interface functions
whismanoid 0:3edb3708c8c5 1994 #endif
whismanoid 0:3edb3708c8c5 1995
whismanoid 0:3edb3708c8c5 1996
whismanoid 0:3edb3708c8c5 1997 #if APPLICATION_MAX11410 // hardware interface functions
whismanoid 0:3edb3708c8c5 1998 #endif
whismanoid 0:3edb3708c8c5 1999
whismanoid 0:3edb3708c8c5 2000
whismanoid 0:3edb3708c8c5 2001 #if APPLICATION_MAX12345 // hardware interface functions
whismanoid 0:3edb3708c8c5 2002 #endif
whismanoid 0:3edb3708c8c5 2003
whismanoid 0:3edb3708c8c5 2004
whismanoid 0:3edb3708c8c5 2005 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2006 // print banner message to serial port
whismanoid 0:3edb3708c8c5 2007 void print_banner()
whismanoid 0:3edb3708c8c5 2008 {
whismanoid 0:3edb3708c8c5 2009 #if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 2010 DAPLINKserial.printf("\r\n");
whismanoid 0:3edb3708c8c5 2011 # if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 2012 DAPLINKserial.printf("MAX32630");
whismanoid 0:3edb3708c8c5 2013 # elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 2014 DAPLINKserial.printf("MAX32625MBED");
whismanoid 0:3edb3708c8c5 2015 # elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 2016 DAPLINKserial.printf("NUCLEO_F446RE");
whismanoid 0:3edb3708c8c5 2017 # elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 2018 DAPLINKserial.printf("NUCLEO_F401RE");
whismanoid 0:3edb3708c8c5 2019 # elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 2020 DAPLINKserial.printf("LPC1768");
whismanoid 0:3edb3708c8c5 2021 # else
whismanoid 0:3edb3708c8c5 2022 // unknown target
whismanoid 0:3edb3708c8c5 2023 DAPLINKserial.printf("unknownTarget");
whismanoid 0:3edb3708c8c5 2024 # endif
whismanoid 0:3edb3708c8c5 2025 DAPLINKserial.printf(" DAPLINKserial\r\n");
whismanoid 0:3edb3708c8c5 2026 #endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 2027
whismanoid 7:bf501f8cb637 2028 serial.printf("\r\n");
whismanoid 0:3edb3708c8c5 2029 # if defined(TARGET_MAX32630)
whismanoid 7:bf501f8cb637 2030 serial.printf("MAX32630");
whismanoid 0:3edb3708c8c5 2031 # elif defined(TARGET_MAX32625MBED)
whismanoid 7:bf501f8cb637 2032 serial.printf("MAX32625MBED");
whismanoid 0:3edb3708c8c5 2033 # elif defined(TARGET_NUCLEO_F446RE)
whismanoid 7:bf501f8cb637 2034 serial.printf("NUCLEO_F446RE");
whismanoid 0:3edb3708c8c5 2035 # elif defined(TARGET_NUCLEO_F401RE)
whismanoid 7:bf501f8cb637 2036 serial.printf("NUCLEO_F401RE");
whismanoid 0:3edb3708c8c5 2037 # elif defined(TARGET_LPC1768)
whismanoid 7:bf501f8cb637 2038 serial.printf("LPC1768");
whismanoid 0:3edb3708c8c5 2039 # else
whismanoid 0:3edb3708c8c5 2040 // unknown target
whismanoid 7:bf501f8cb637 2041 serial.printf("unknownTarget");
whismanoid 0:3edb3708c8c5 2042 # endif
whismanoid 7:bf501f8cb637 2043 serial.printf(" Tester\r\n");
whismanoid 0:3edb3708c8c5 2044 }
whismanoid 0:3edb3708c8c5 2045
whismanoid 7:bf501f8cb637 2046 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:3edb3708c8c5 2047 #if HAS_digitalInOuts
whismanoid 0:3edb3708c8c5 2048 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:3edb3708c8c5 2049 {
whismanoid 0:3edb3708c8c5 2050 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 2051 serialStream.printf(" 0");
whismanoid 0:3edb3708c8c5 2052 #endif
whismanoid 0:3edb3708c8c5 2053 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 2054 serialStream.printf(" 1");
whismanoid 0:3edb3708c8c5 2055 #endif
whismanoid 0:3edb3708c8c5 2056 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 2057 serialStream.printf(" 2");
whismanoid 0:3edb3708c8c5 2058 #endif
whismanoid 0:3edb3708c8c5 2059 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 2060 serialStream.printf(" 3");
whismanoid 0:3edb3708c8c5 2061 #endif
whismanoid 0:3edb3708c8c5 2062 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 2063 serialStream.printf(" 4");
whismanoid 0:3edb3708c8c5 2064 #endif
whismanoid 0:3edb3708c8c5 2065 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 2066 serialStream.printf(" 5");
whismanoid 0:3edb3708c8c5 2067 #endif
whismanoid 0:3edb3708c8c5 2068 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 2069 serialStream.printf(" 6");
whismanoid 0:3edb3708c8c5 2070 #endif
whismanoid 0:3edb3708c8c5 2071 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 2072 serialStream.printf(" 7");
whismanoid 0:3edb3708c8c5 2073 #endif
whismanoid 0:3edb3708c8c5 2074 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 2075 serialStream.printf(" 8");
whismanoid 0:3edb3708c8c5 2076 #endif
whismanoid 0:3edb3708c8c5 2077 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 2078 serialStream.printf(" 9");
whismanoid 0:3edb3708c8c5 2079 #endif
whismanoid 0:3edb3708c8c5 2080 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 2081 serialStream.printf(" 10");
whismanoid 0:3edb3708c8c5 2082 #endif
whismanoid 0:3edb3708c8c5 2083 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 2084 serialStream.printf(" 11");
whismanoid 0:3edb3708c8c5 2085 #endif
whismanoid 0:3edb3708c8c5 2086 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 2087 serialStream.printf(" 12");
whismanoid 0:3edb3708c8c5 2088 #endif
whismanoid 0:3edb3708c8c5 2089 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 2090 serialStream.printf(" 13");
whismanoid 0:3edb3708c8c5 2091 #endif
whismanoid 0:3edb3708c8c5 2092 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 2093 serialStream.printf(" 14");
whismanoid 0:3edb3708c8c5 2094 #endif
whismanoid 0:3edb3708c8c5 2095 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 2096 serialStream.printf(" 15");
whismanoid 0:3edb3708c8c5 2097 #endif
whismanoid 0:3edb3708c8c5 2098 #if HAS_digitalInOut16
whismanoid 0:3edb3708c8c5 2099 serialStream.printf(" 16");
whismanoid 0:3edb3708c8c5 2100 #endif
whismanoid 0:3edb3708c8c5 2101 #if HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 2102 serialStream.printf(" 17");
whismanoid 0:3edb3708c8c5 2103 #endif
whismanoid 0:3edb3708c8c5 2104 }
whismanoid 0:3edb3708c8c5 2105 #endif
whismanoid 0:3edb3708c8c5 2106
whismanoid 0:3edb3708c8c5 2107 // DigitalInOut pin resource: present?
whismanoid 0:3edb3708c8c5 2108 #if HAS_digitalInOuts
whismanoid 0:3edb3708c8c5 2109 bool has_digitalInOutPin(int cPinIndex)
whismanoid 0:3edb3708c8c5 2110 {
whismanoid 0:3edb3708c8c5 2111 switch (cPinIndex)
whismanoid 0:3edb3708c8c5 2112 {
whismanoid 0:3edb3708c8c5 2113 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 2114 case '0': case 0x00: return true;
whismanoid 0:3edb3708c8c5 2115 #endif
whismanoid 0:3edb3708c8c5 2116 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 2117 case '1': case 0x01: return true;
whismanoid 0:3edb3708c8c5 2118 #endif
whismanoid 0:3edb3708c8c5 2119 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 2120 case '2': case 0x02: return true;
whismanoid 0:3edb3708c8c5 2121 #endif
whismanoid 0:3edb3708c8c5 2122 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 2123 case '3': case 0x03: return true;
whismanoid 0:3edb3708c8c5 2124 #endif
whismanoid 0:3edb3708c8c5 2125 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 2126 case '4': case 0x04: return true;
whismanoid 0:3edb3708c8c5 2127 #endif
whismanoid 0:3edb3708c8c5 2128 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 2129 case '5': case 0x05: return true;
whismanoid 0:3edb3708c8c5 2130 #endif
whismanoid 0:3edb3708c8c5 2131 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 2132 case '6': case 0x06: return true;
whismanoid 0:3edb3708c8c5 2133 #endif
whismanoid 0:3edb3708c8c5 2134 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 2135 case '7': case 0x07: return true;
whismanoid 0:3edb3708c8c5 2136 #endif
whismanoid 0:3edb3708c8c5 2137 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 2138 case '8': case 0x08: return true;
whismanoid 0:3edb3708c8c5 2139 #endif
whismanoid 0:3edb3708c8c5 2140 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 2141 case '9': case 0x09: return true;
whismanoid 0:3edb3708c8c5 2142 #endif
whismanoid 0:3edb3708c8c5 2143 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 2144 case 'a': case 0x0a: return true;
whismanoid 0:3edb3708c8c5 2145 #endif
whismanoid 0:3edb3708c8c5 2146 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 2147 case 'b': case 0x0b: return true;
whismanoid 0:3edb3708c8c5 2148 #endif
whismanoid 0:3edb3708c8c5 2149 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 2150 case 'c': case 0x0c: return true;
whismanoid 0:3edb3708c8c5 2151 #endif
whismanoid 0:3edb3708c8c5 2152 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 2153 case 'd': case 0x0d: return true;
whismanoid 0:3edb3708c8c5 2154 #endif
whismanoid 0:3edb3708c8c5 2155 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 2156 case 'e': case 0x0e: return true;
whismanoid 0:3edb3708c8c5 2157 #endif
whismanoid 0:3edb3708c8c5 2158 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 2159 case 'f': case 0x0f: return true;
whismanoid 0:3edb3708c8c5 2160 #endif
whismanoid 0:3edb3708c8c5 2161 default:
whismanoid 0:3edb3708c8c5 2162 return false;
whismanoid 0:3edb3708c8c5 2163 }
whismanoid 0:3edb3708c8c5 2164 }
whismanoid 0:3edb3708c8c5 2165 #endif
whismanoid 0:3edb3708c8c5 2166
whismanoid 0:3edb3708c8c5 2167 // DigitalInOut pin resource: search index
whismanoid 0:3edb3708c8c5 2168 #if HAS_digitalInOuts
whismanoid 0:3edb3708c8c5 2169 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:3edb3708c8c5 2170 {
whismanoid 0:3edb3708c8c5 2171 switch (cPinIndex)
whismanoid 0:3edb3708c8c5 2172 {
whismanoid 0:3edb3708c8c5 2173 default: // default to the first defined digitalInOut pin
whismanoid 0:3edb3708c8c5 2174 #if HAS_digitalInOut0
whismanoid 0:3edb3708c8c5 2175 case '0': case 0x00: return digitalInOut0;
whismanoid 0:3edb3708c8c5 2176 #endif
whismanoid 0:3edb3708c8c5 2177 #if HAS_digitalInOut1
whismanoid 0:3edb3708c8c5 2178 case '1': case 0x01: return digitalInOut1;
whismanoid 0:3edb3708c8c5 2179 #endif
whismanoid 0:3edb3708c8c5 2180 #if HAS_digitalInOut2
whismanoid 0:3edb3708c8c5 2181 case '2': case 0x02: return digitalInOut2;
whismanoid 0:3edb3708c8c5 2182 #endif
whismanoid 0:3edb3708c8c5 2183 #if HAS_digitalInOut3
whismanoid 0:3edb3708c8c5 2184 case '3': case 0x03: return digitalInOut3;
whismanoid 0:3edb3708c8c5 2185 #endif
whismanoid 0:3edb3708c8c5 2186 #if HAS_digitalInOut4
whismanoid 0:3edb3708c8c5 2187 case '4': case 0x04: return digitalInOut4;
whismanoid 0:3edb3708c8c5 2188 #endif
whismanoid 0:3edb3708c8c5 2189 #if HAS_digitalInOut5
whismanoid 0:3edb3708c8c5 2190 case '5': case 0x05: return digitalInOut5;
whismanoid 0:3edb3708c8c5 2191 #endif
whismanoid 0:3edb3708c8c5 2192 #if HAS_digitalInOut6
whismanoid 0:3edb3708c8c5 2193 case '6': case 0x06: return digitalInOut6;
whismanoid 0:3edb3708c8c5 2194 #endif
whismanoid 0:3edb3708c8c5 2195 #if HAS_digitalInOut7
whismanoid 0:3edb3708c8c5 2196 case '7': case 0x07: return digitalInOut7;
whismanoid 0:3edb3708c8c5 2197 #endif
whismanoid 0:3edb3708c8c5 2198 #if HAS_digitalInOut8
whismanoid 0:3edb3708c8c5 2199 case '8': case 0x08: return digitalInOut8;
whismanoid 0:3edb3708c8c5 2200 #endif
whismanoid 0:3edb3708c8c5 2201 #if HAS_digitalInOut9
whismanoid 0:3edb3708c8c5 2202 case '9': case 0x09: return digitalInOut9;
whismanoid 0:3edb3708c8c5 2203 #endif
whismanoid 0:3edb3708c8c5 2204 #if HAS_digitalInOut10
whismanoid 0:3edb3708c8c5 2205 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:3edb3708c8c5 2206 #endif
whismanoid 0:3edb3708c8c5 2207 #if HAS_digitalInOut11
whismanoid 0:3edb3708c8c5 2208 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:3edb3708c8c5 2209 #endif
whismanoid 0:3edb3708c8c5 2210 #if HAS_digitalInOut12
whismanoid 0:3edb3708c8c5 2211 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:3edb3708c8c5 2212 #endif
whismanoid 0:3edb3708c8c5 2213 #if HAS_digitalInOut13
whismanoid 0:3edb3708c8c5 2214 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:3edb3708c8c5 2215 #endif
whismanoid 0:3edb3708c8c5 2216 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 2217 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:3edb3708c8c5 2218 #endif
whismanoid 0:3edb3708c8c5 2219 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 2220 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:3edb3708c8c5 2221 #endif
whismanoid 0:3edb3708c8c5 2222 #if HAS_digitalInOut16
whismanoid 0:3edb3708c8c5 2223 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:3edb3708c8c5 2224 #endif
whismanoid 0:3edb3708c8c5 2225 #if HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 2226 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:3edb3708c8c5 2227 #endif
whismanoid 0:3edb3708c8c5 2228 }
whismanoid 0:3edb3708c8c5 2229 }
whismanoid 0:3edb3708c8c5 2230 #endif
whismanoid 0:3edb3708c8c5 2231
whismanoid 7:bf501f8cb637 2232 // AnalogIn pin resource: print the pin index names to serial
whismanoid 0:3edb3708c8c5 2233 #if HAS_analogIns
whismanoid 0:3edb3708c8c5 2234 void list_analogInPins(Stream& serialStream)
whismanoid 0:3edb3708c8c5 2235 {
whismanoid 0:3edb3708c8c5 2236 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 2237 serialStream.printf(" 0");
whismanoid 0:3edb3708c8c5 2238 #endif
whismanoid 0:3edb3708c8c5 2239 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 2240 serialStream.printf(" 1");
whismanoid 0:3edb3708c8c5 2241 #endif
whismanoid 0:3edb3708c8c5 2242 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 2243 serialStream.printf(" 2");
whismanoid 0:3edb3708c8c5 2244 #endif
whismanoid 0:3edb3708c8c5 2245 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 2246 serialStream.printf(" 3");
whismanoid 0:3edb3708c8c5 2247 #endif
whismanoid 0:3edb3708c8c5 2248 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 2249 serialStream.printf(" 4");
whismanoid 0:3edb3708c8c5 2250 #endif
whismanoid 0:3edb3708c8c5 2251 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 2252 serialStream.printf(" 5");
whismanoid 0:3edb3708c8c5 2253 #endif
whismanoid 0:3edb3708c8c5 2254 #if HAS_analogIn6
whismanoid 0:3edb3708c8c5 2255 serialStream.printf(" 6");
whismanoid 0:3edb3708c8c5 2256 #endif
whismanoid 0:3edb3708c8c5 2257 #if HAS_analogIn7
whismanoid 0:3edb3708c8c5 2258 serialStream.printf(" 7");
whismanoid 0:3edb3708c8c5 2259 #endif
whismanoid 0:3edb3708c8c5 2260 #if HAS_analogIn8
whismanoid 0:3edb3708c8c5 2261 serialStream.printf(" 8");
whismanoid 0:3edb3708c8c5 2262 #endif
whismanoid 0:3edb3708c8c5 2263 #if HAS_analogIn9
whismanoid 0:3edb3708c8c5 2264 serialStream.printf(" 9");
whismanoid 0:3edb3708c8c5 2265 #endif
whismanoid 0:3edb3708c8c5 2266 #if HAS_analogIn10
whismanoid 0:3edb3708c8c5 2267 serialStream.printf(" a");
whismanoid 0:3edb3708c8c5 2268 #endif
whismanoid 0:3edb3708c8c5 2269 #if HAS_analogIn11
whismanoid 0:3edb3708c8c5 2270 serialStream.printf(" b");
whismanoid 0:3edb3708c8c5 2271 #endif
whismanoid 0:3edb3708c8c5 2272 #if HAS_analogIn12
whismanoid 0:3edb3708c8c5 2273 serialStream.printf(" c");
whismanoid 0:3edb3708c8c5 2274 #endif
whismanoid 0:3edb3708c8c5 2275 #if HAS_analogIn13
whismanoid 0:3edb3708c8c5 2276 serialStream.printf(" d");
whismanoid 0:3edb3708c8c5 2277 #endif
whismanoid 0:3edb3708c8c5 2278 #if HAS_analogIn14
whismanoid 0:3edb3708c8c5 2279 serialStream.printf(" e");
whismanoid 0:3edb3708c8c5 2280 #endif
whismanoid 0:3edb3708c8c5 2281 #if HAS_analogIn15
whismanoid 0:3edb3708c8c5 2282 serialStream.printf(" f");
whismanoid 0:3edb3708c8c5 2283 #endif
whismanoid 0:3edb3708c8c5 2284 }
whismanoid 0:3edb3708c8c5 2285 #endif
whismanoid 0:3edb3708c8c5 2286
whismanoid 0:3edb3708c8c5 2287 // AnalogIn pin resource: present?
whismanoid 0:3edb3708c8c5 2288 #if HAS_analogIns
whismanoid 0:3edb3708c8c5 2289 bool has_analogInPin(int cPinIndex)
whismanoid 0:3edb3708c8c5 2290 {
whismanoid 0:3edb3708c8c5 2291 switch (cPinIndex)
whismanoid 0:3edb3708c8c5 2292 {
whismanoid 0:3edb3708c8c5 2293 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 2294 case '0': case 0x00: return true;
whismanoid 0:3edb3708c8c5 2295 #endif
whismanoid 0:3edb3708c8c5 2296 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 2297 case '1': case 0x01: return true;
whismanoid 0:3edb3708c8c5 2298 #endif
whismanoid 0:3edb3708c8c5 2299 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 2300 case '2': case 0x02: return true;
whismanoid 0:3edb3708c8c5 2301 #endif
whismanoid 0:3edb3708c8c5 2302 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 2303 case '3': case 0x03: return true;
whismanoid 0:3edb3708c8c5 2304 #endif
whismanoid 0:3edb3708c8c5 2305 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 2306 case '4': case 0x04: return true;
whismanoid 0:3edb3708c8c5 2307 #endif
whismanoid 0:3edb3708c8c5 2308 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 2309 case '5': case 0x05: return true;
whismanoid 0:3edb3708c8c5 2310 #endif
whismanoid 0:3edb3708c8c5 2311 #if HAS_analogIn6
whismanoid 0:3edb3708c8c5 2312 case '6': case 0x06: return true;
whismanoid 0:3edb3708c8c5 2313 #endif
whismanoid 0:3edb3708c8c5 2314 #if HAS_analogIn7
whismanoid 0:3edb3708c8c5 2315 case '7': case 0x07: return true;
whismanoid 0:3edb3708c8c5 2316 #endif
whismanoid 0:3edb3708c8c5 2317 #if HAS_analogIn8
whismanoid 0:3edb3708c8c5 2318 case '8': case 0x08: return true;
whismanoid 0:3edb3708c8c5 2319 #endif
whismanoid 0:3edb3708c8c5 2320 #if HAS_analogIn9
whismanoid 0:3edb3708c8c5 2321 case '9': case 0x09: return true;
whismanoid 0:3edb3708c8c5 2322 #endif
whismanoid 0:3edb3708c8c5 2323 #if HAS_analogIn10
whismanoid 0:3edb3708c8c5 2324 case 'a': case 0x0a: return true;
whismanoid 0:3edb3708c8c5 2325 #endif
whismanoid 0:3edb3708c8c5 2326 #if HAS_analogIn11
whismanoid 0:3edb3708c8c5 2327 case 'b': case 0x0b: return true;
whismanoid 0:3edb3708c8c5 2328 #endif
whismanoid 0:3edb3708c8c5 2329 #if HAS_analogIn12
whismanoid 0:3edb3708c8c5 2330 case 'c': case 0x0c: return true;
whismanoid 0:3edb3708c8c5 2331 #endif
whismanoid 0:3edb3708c8c5 2332 #if HAS_analogIn13
whismanoid 0:3edb3708c8c5 2333 case 'd': case 0x0d: return true;
whismanoid 0:3edb3708c8c5 2334 #endif
whismanoid 0:3edb3708c8c5 2335 #if HAS_analogIn14
whismanoid 0:3edb3708c8c5 2336 case 'e': case 0x0e: return true;
whismanoid 0:3edb3708c8c5 2337 #endif
whismanoid 0:3edb3708c8c5 2338 #if HAS_analogIn15
whismanoid 0:3edb3708c8c5 2339 case 'f': case 0x0f: return true;
whismanoid 0:3edb3708c8c5 2340 #endif
whismanoid 0:3edb3708c8c5 2341 default:
whismanoid 0:3edb3708c8c5 2342 return false;
whismanoid 0:3edb3708c8c5 2343 }
whismanoid 0:3edb3708c8c5 2344 }
whismanoid 0:3edb3708c8c5 2345 #endif
whismanoid 0:3edb3708c8c5 2346
whismanoid 0:3edb3708c8c5 2347 // AnalogIn pin resource: search index
whismanoid 0:3edb3708c8c5 2348 #if HAS_analogIns
whismanoid 0:3edb3708c8c5 2349 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:3edb3708c8c5 2350 {
whismanoid 0:3edb3708c8c5 2351 switch (cPinIndex)
whismanoid 0:3edb3708c8c5 2352 {
whismanoid 0:3edb3708c8c5 2353 default: // default to the first defined analogIn pin
whismanoid 0:3edb3708c8c5 2354 #if HAS_analogIn0
whismanoid 0:3edb3708c8c5 2355 case '0': case 0x00: return analogIn0;
whismanoid 0:3edb3708c8c5 2356 #endif
whismanoid 0:3edb3708c8c5 2357 #if HAS_analogIn1
whismanoid 0:3edb3708c8c5 2358 case '1': case 0x01: return analogIn1;
whismanoid 0:3edb3708c8c5 2359 #endif
whismanoid 0:3edb3708c8c5 2360 #if HAS_analogIn2
whismanoid 0:3edb3708c8c5 2361 case '2': case 0x02: return analogIn2;
whismanoid 0:3edb3708c8c5 2362 #endif
whismanoid 0:3edb3708c8c5 2363 #if HAS_analogIn3
whismanoid 0:3edb3708c8c5 2364 case '3': case 0x03: return analogIn3;
whismanoid 0:3edb3708c8c5 2365 #endif
whismanoid 0:3edb3708c8c5 2366 #if HAS_analogIn4
whismanoid 0:3edb3708c8c5 2367 case '4': case 0x04: return analogIn4;
whismanoid 0:3edb3708c8c5 2368 #endif
whismanoid 0:3edb3708c8c5 2369 #if HAS_analogIn5
whismanoid 0:3edb3708c8c5 2370 case '5': case 0x05: return analogIn5;
whismanoid 0:3edb3708c8c5 2371 #endif
whismanoid 0:3edb3708c8c5 2372 #if HAS_analogIn6
whismanoid 0:3edb3708c8c5 2373 case '6': case 0x06: return analogIn6;
whismanoid 0:3edb3708c8c5 2374 #endif
whismanoid 0:3edb3708c8c5 2375 #if HAS_analogIn7
whismanoid 0:3edb3708c8c5 2376 case '7': case 0x07: return analogIn7;
whismanoid 0:3edb3708c8c5 2377 #endif
whismanoid 0:3edb3708c8c5 2378 #if HAS_analogIn8
whismanoid 0:3edb3708c8c5 2379 case '8': case 0x08: return analogIn8;
whismanoid 0:3edb3708c8c5 2380 #endif
whismanoid 0:3edb3708c8c5 2381 #if HAS_analogIn9
whismanoid 0:3edb3708c8c5 2382 case '9': case 0x09: return analogIn9;
whismanoid 0:3edb3708c8c5 2383 #endif
whismanoid 0:3edb3708c8c5 2384 #if HAS_analogIn10
whismanoid 0:3edb3708c8c5 2385 case 'a': case 0x0a: return analogIn10;
whismanoid 0:3edb3708c8c5 2386 #endif
whismanoid 0:3edb3708c8c5 2387 #if HAS_analogIn11
whismanoid 0:3edb3708c8c5 2388 case 'b': case 0x0b: return analogIn11;
whismanoid 0:3edb3708c8c5 2389 #endif
whismanoid 0:3edb3708c8c5 2390 #if HAS_analogIn12
whismanoid 0:3edb3708c8c5 2391 case 'c': case 0x0c: return analogIn12;
whismanoid 0:3edb3708c8c5 2392 #endif
whismanoid 0:3edb3708c8c5 2393 #if HAS_analogIn13
whismanoid 0:3edb3708c8c5 2394 case 'd': case 0x0d: return analogIn13;
whismanoid 0:3edb3708c8c5 2395 #endif
whismanoid 0:3edb3708c8c5 2396 #if HAS_analogIn14
whismanoid 0:3edb3708c8c5 2397 case 'e': case 0x0e: return analogIn14;
whismanoid 0:3edb3708c8c5 2398 #endif
whismanoid 0:3edb3708c8c5 2399 #if HAS_analogIn15
whismanoid 0:3edb3708c8c5 2400 case 'f': case 0x0f: return analogIn15;
whismanoid 0:3edb3708c8c5 2401 #endif
whismanoid 0:3edb3708c8c5 2402 }
whismanoid 0:3edb3708c8c5 2403 }
whismanoid 0:3edb3708c8c5 2404 #endif
whismanoid 0:3edb3708c8c5 2405
whismanoid 0:3edb3708c8c5 2406 #if HAS_analogIns
whismanoid 0:3edb3708c8c5 2407 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:3edb3708c8c5 2408 # if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 2409 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:3edb3708c8c5 2410 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:3edb3708c8c5 2411 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:3edb3708c8c5 2412 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:3edb3708c8c5 2413 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 2414 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 2415 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2416 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2417 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2418 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:3edb3708c8c5 2419 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:3edb3708c8c5 2420 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2421 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2422 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:3edb3708c8c5 2423 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:3edb3708c8c5 2424 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:3edb3708c8c5 2425 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 2426 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2427 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2428 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2429 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2430 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 2431 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 2432 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2433 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2434 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:3edb3708c8c5 2435 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:3edb3708c8c5 2436 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:3edb3708c8c5 2437 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2438 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:3edb3708c8c5 2439 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:3edb3708c8c5 2440 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:3edb3708c8c5 2441 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:3edb3708c8c5 2442 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:3edb3708c8c5 2443 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:3edb3708c8c5 2444 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:3edb3708c8c5 2445 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:3edb3708c8c5 2446 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:3edb3708c8c5 2447 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:3edb3708c8c5 2448 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:3edb3708c8c5 2449 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:3edb3708c8c5 2450 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:3edb3708c8c5 2451 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:3edb3708c8c5 2452 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:3edb3708c8c5 2453 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:3edb3708c8c5 2454 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:3edb3708c8c5 2455 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:3edb3708c8c5 2456 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:3edb3708c8c5 2457 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:3edb3708c8c5 2458 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:3edb3708c8c5 2459 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:3edb3708c8c5 2460 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:3edb3708c8c5 2461 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:3edb3708c8c5 2462 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:3edb3708c8c5 2463 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:3edb3708c8c5 2464 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:3edb3708c8c5 2465 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:3edb3708c8c5 2466 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:3edb3708c8c5 2467 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:3edb3708c8c5 2468 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:3edb3708c8c5 2469 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:3edb3708c8c5 2470 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:3edb3708c8c5 2471 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:3edb3708c8c5 2472 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:3edb3708c8c5 2473 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:3edb3708c8c5 2474 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:3edb3708c8c5 2475 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:3edb3708c8c5 2476 //#elif defined(TARGET_LPC1768)
whismanoid 0:3edb3708c8c5 2477 #else
whismanoid 0:3edb3708c8c5 2478 // unknown target
whismanoid 0:3edb3708c8c5 2479 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:3edb3708c8c5 2480 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:3edb3708c8c5 2481 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:3edb3708c8c5 2482 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:3edb3708c8c5 2483 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:3edb3708c8c5 2484 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:3edb3708c8c5 2485 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:3edb3708c8c5 2486 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:3edb3708c8c5 2487 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:3edb3708c8c5 2488 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:3edb3708c8c5 2489 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:3edb3708c8c5 2490 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:3edb3708c8c5 2491 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:3edb3708c8c5 2492 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:3edb3708c8c5 2493 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:3edb3708c8c5 2494 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:3edb3708c8c5 2495 # endif
whismanoid 0:3edb3708c8c5 2496 };
whismanoid 0:3edb3708c8c5 2497 #endif
whismanoid 0:3edb3708c8c5 2498
whismanoid 0:3edb3708c8c5 2499 #if HAS_I2C // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 2500 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2501 // Search I2C device address list
whismanoid 0:3edb3708c8c5 2502 //
whismanoid 0:3edb3708c8c5 2503 // @param[in] deviceAddress7First = I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified.
whismanoid 0:3edb3708c8c5 2504 // @param[in] deviceAddress7Last = I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified.
whismanoid 0:3edb3708c8c5 2505 // @param[in] numDevicesFoundLimit = maximum number of devices to detect before halting search; in case SCL stuck low or pullups missing.
whismanoid 0:3edb3708c8c5 2506 // @returns deviceAddress on success; 0 on failure
whismanoid 0:3edb3708c8c5 2507 // @post g_I2C_deviceAddress7 is updated with any device that did ACK
whismanoid 0:3edb3708c8c5 2508 //
whismanoid 0:3edb3708c8c5 2509 void HuntAttachedI2CDevices(CmdLine& cmdLine, uint8_t deviceAddress7First, uint8_t deviceAddress7Last,
whismanoid 0:3edb3708c8c5 2510 const uint8_t numDevicesFoundLimit = 20)
whismanoid 0:3edb3708c8c5 2511 {
whismanoid 0:3edb3708c8c5 2512 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 0:3edb3708c8c5 2513 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 0:3edb3708c8c5 2514 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 0:3edb3708c8c5 2515
whismanoid 0:3edb3708c8c5 2516 // %IP -- I2C probe
whismanoid 0:3edb3708c8c5 2517 // TODO: i2c transfer
whismanoid 0:3edb3708c8c5 2518 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 0:3edb3708c8c5 2519 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 0:3edb3708c8c5 2520 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 0:3edb3708c8c5 2521 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 0:3edb3708c8c5 2522 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 0:3edb3708c8c5 2523 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 0:3edb3708c8c5 2524 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 0:3edb3708c8c5 2525 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 0:3edb3708c8c5 2526 // /* 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 2527 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 0:3edb3708c8c5 2528
whismanoid 0:3edb3708c8c5 2529 //const char probeWriteData[] = { 0x00 };
whismanoid 0:3edb3708c8c5 2530 //int probeWriteDataLength = 1;
whismanoid 0:3edb3708c8c5 2531 //bool isRepeatedStart = false;
whismanoid 0:3edb3708c8c5 2532 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 2533 deviceAddress7First,
whismanoid 0:3edb3708c8c5 2534 deviceAddress7First << 1,
whismanoid 0:3edb3708c8c5 2535 deviceAddress7Last,
whismanoid 0:3edb3708c8c5 2536 deviceAddress7Last << 1,
whismanoid 0:3edb3708c8c5 2537 numDevicesFoundLimit); // HuntAttachedI2CDevices
whismanoid 0:3edb3708c8c5 2538 //~ const int i2cFileDescriptor = i2c_open_adapter(1);
whismanoid 0:3edb3708c8c5 2539 uint8_t numDevicesFound = 0;
whismanoid 0:3edb3708c8c5 2540 uint8_t last_valid_deviceAddress7 = 0;
whismanoid 0:3edb3708c8c5 2541 for (uint8_t deviceAddress7 = deviceAddress7First; deviceAddress7 <= deviceAddress7Last; deviceAddress7++)
whismanoid 0:3edb3708c8c5 2542 {
whismanoid 0:3edb3708c8c5 2543 //cmdLine.serial().printf(" (0x%2.2X >> 1) ", (deviceAddress7 << 1));
whismanoid 0:3edb3708c8c5 2544 //if (i2c_ioctl_I2C_SLAVE_i2cDeviceAddress7bits(i2cFileDescriptor, deviceAddress7) == 0)
whismanoid 0:3edb3708c8c5 2545 int addr8bit = deviceAddress7 * 2;
whismanoid 0:3edb3708c8c5 2546 //
whismanoid 0:3edb3708c8c5 2547 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 0:3edb3708c8c5 2548 // Returns 0 on success (ack), nonzero on failure (nack)
whismanoid 0:3edb3708c8c5 2549 //bool gotACK = (i2cMaster.write (addr8bit, probeWriteData, probeWriteDataLength, isRepeatedStart) == 0);
whismanoid 0:3edb3708c8c5 2550 //
whismanoid 0:3edb3708c8c5 2551 // SMBusQuick test
whismanoid 0:3edb3708c8c5 2552 i2cMaster.start();
whismanoid 0:3edb3708c8c5 2553 // /** Write single byte out on the I2C bus
whismanoid 0:3edb3708c8c5 2554 // *
whismanoid 0:3edb3708c8c5 2555 // * @param data data to write out on bus
whismanoid 0:3edb3708c8c5 2556 // *
whismanoid 0:3edb3708c8c5 2557 // * @returns
whismanoid 0:3edb3708c8c5 2558 // * '0' - NAK was received
whismanoid 0:3edb3708c8c5 2559 // * '1' - ACK was received,
whismanoid 0:3edb3708c8c5 2560 // * '2' - timeout
whismanoid 0:3edb3708c8c5 2561 // */
whismanoid 0:3edb3708c8c5 2562 // int write(int data);
whismanoid 0:3edb3708c8c5 2563 int writeStatus = i2cMaster.write(addr8bit);
whismanoid 0:3edb3708c8c5 2564 i2cMaster.stop();
whismanoid 0:3edb3708c8c5 2565 bool gotACK = (writeStatus == 1); // ACK was received
whismanoid 0:3edb3708c8c5 2566 if (writeStatus == 2) // timeout
whismanoid 0:3edb3708c8c5 2567 {
whismanoid 0:3edb3708c8c5 2568 cmdLine.serial().printf("- timeout\r\n");
whismanoid 0:3edb3708c8c5 2569 }
whismanoid 0:3edb3708c8c5 2570 //
whismanoid 0:3edb3708c8c5 2571 if (gotACK)
whismanoid 0:3edb3708c8c5 2572 {
whismanoid 0:3edb3708c8c5 2573 // @return status; error if (fileDescriptor < 0)
whismanoid 0:3edb3708c8c5 2574 cmdLine.serial().printf("+ ADDR=0x%2.2X (0x%2.2X >> 1) ACK\r\n", deviceAddress7, (deviceAddress7 << 1));
whismanoid 0:3edb3708c8c5 2575 numDevicesFound++;
whismanoid 0:3edb3708c8c5 2576 last_valid_deviceAddress7 = deviceAddress7;
whismanoid 0:3edb3708c8c5 2577 if (numDevicesFound > numDevicesFoundLimit)
whismanoid 0:3edb3708c8c5 2578 {
whismanoid 0:3edb3708c8c5 2579 break;
whismanoid 0:3edb3708c8c5 2580 }
whismanoid 0:3edb3708c8c5 2581 continue;
whismanoid 0:3edb3708c8c5 2582 }
whismanoid 0:3edb3708c8c5 2583 }
whismanoid 0:3edb3708c8c5 2584 if (numDevicesFound == 0)
whismanoid 0:3edb3708c8c5 2585 {
whismanoid 0:3edb3708c8c5 2586 cmdLine.serial().printf("- No I2C devices found. Maybe SCL/SDA are swapped?\r\n");
whismanoid 0:3edb3708c8c5 2587 }
whismanoid 0:3edb3708c8c5 2588 else if (numDevicesFound > numDevicesFoundLimit)
whismanoid 0:3edb3708c8c5 2589 {
whismanoid 0:3edb3708c8c5 2590 cmdLine.serial().printf("- Many I2C devices found. SCL/SDA missing pullup resistors? SCL stuck low?\r\n");
whismanoid 0:3edb3708c8c5 2591 }
whismanoid 0:3edb3708c8c5 2592 else
whismanoid 0:3edb3708c8c5 2593 {
whismanoid 0:3edb3708c8c5 2594 //~ i2c_ioctl_I2C_SLAVE_i2cDeviceAddress7bits(i2cFileDescriptor, last_valid_deviceAddress7);
whismanoid 0:3edb3708c8c5 2595 g_I2C_deviceAddress7 = last_valid_deviceAddress7;
whismanoid 0:3edb3708c8c5 2596 }
whismanoid 0:3edb3708c8c5 2597 //~ i2c_close(i2cFileDescriptor);
whismanoid 0:3edb3708c8c5 2598 }
whismanoid 0:3edb3708c8c5 2599 #endif // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 2600
whismanoid 0:3edb3708c8c5 2601 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2602 // periodic interrupt timer onTimerTick handler triggered by Ticker
whismanoid 0:3edb3708c8c5 2603 // analogIn0 (MAX32630:AIN_4 = AIN0 / 5.0) controls angular speed
whismanoid 0:3edb3708c8c5 2604 // analogIn1 (MAX32630:AIN_5 = AIN1 / 5.0) controls PWM duty cycle
whismanoid 0:3edb3708c8c5 2605 // note: measured 500ns overhead for MAX32630FTHR digitalInOut1.write(0); digitalInOut1.write(1);
whismanoid 0:3edb3708c8c5 2606 #if USE_PERIODIC_TIMER
whismanoid 0:3edb3708c8c5 2607 void onTimerTick() {
whismanoid 0:3edb3708c8c5 2608 } // onTimerTick
whismanoid 0:3edb3708c8c5 2609 #endif
whismanoid 0:3edb3708c8c5 2610
whismanoid 0:3edb3708c8c5 2611 #if USE_PERIODIC_TIMER
whismanoid 0:3edb3708c8c5 2612 // periodic interrupt timer command handlers -- enable timer
whismanoid 0:3edb3708c8c5 2613 void cmd_TE()
whismanoid 0:3edb3708c8c5 2614 {
whismanoid 0:3edb3708c8c5 2615 //us_timestamp_t interval_usec = 100000; // 100ms
whismanoid 0:3edb3708c8c5 2616 periodicInterruptTimer_interval_usec = 100000; // 100ms
whismanoid 0:3edb3708c8c5 2617 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 2618 DAPLINKserial.printf(" Timer Enable %d us\r\n", periodicInterruptTimer_interval_usec);
whismanoid 0:3edb3708c8c5 2619 # endif
whismanoid 7:bf501f8cb637 2620 serial.printf(" Timer Enable %d us", periodicInterruptTimer_interval_usec);
whismanoid 0:3edb3708c8c5 2621 periodicInterruptTimer.attach_us(&onTimerTick, periodicInterruptTimer_interval_usec);
whismanoid 0:3edb3708c8c5 2622 // -- periodicInterruptTimer.attach(&onTimerTick, interval_sec); // the address of the function to be attached (onTimerTick) and the interval (2 seconds)
whismanoid 0:3edb3708c8c5 2623 // -- periodicInterruptTimer.attach_us(&onTimerTick, interval_usec); // the address of the function to be attached (onTimerTick) and the interval (2 seconds)
whismanoid 0:3edb3708c8c5 2624 // -- periodicInterruptTimer.attach(Callback<void()> func, float t);
whismanoid 0:3edb3708c8c5 2625 // -- periodicInterruptTimer.attach_us(Callback<void()> func, us_timestamp_t t);
whismanoid 0:3edb3708c8c5 2626 // TODO1: cmd_T add cSubCommand to change interval of Ticker periodic interrupt timer
whismanoid 0:3edb3708c8c5 2627 }
whismanoid 0:3edb3708c8c5 2628 #endif
whismanoid 0:3edb3708c8c5 2629
whismanoid 0:3edb3708c8c5 2630 #if USE_PERIODIC_TIMER
whismanoid 0:3edb3708c8c5 2631 // periodic interrupt timer command handlers -- disable timer
whismanoid 0:3edb3708c8c5 2632 void cmd_TD()
whismanoid 0:3edb3708c8c5 2633 {
whismanoid 0:3edb3708c8c5 2634 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 2635 DAPLINKserial.printf(" Timer Disable\r\n");
whismanoid 0:3edb3708c8c5 2636 # endif
whismanoid 7:bf501f8cb637 2637 serial.printf(" Timer Disable ");
whismanoid 0:3edb3708c8c5 2638 periodicInterruptTimer.detach(); // Detach the function
whismanoid 0:3edb3708c8c5 2639 }
whismanoid 0:3edb3708c8c5 2640 #endif
whismanoid 0:3edb3708c8c5 2641
whismanoid 0:3edb3708c8c5 2642 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2643 // When user presses button BUTTON1, perform a demo configuration
whismanoid 0:3edb3708c8c5 2644 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 2645 void onButton1FallingEdge(void)
whismanoid 0:3edb3708c8c5 2646 {
whismanoid 0:3edb3708c8c5 2647 void SelfTest(CmdLine & cmdLine);
whismanoid 0:3edb3708c8c5 2648
whismanoid 7:bf501f8cb637 2649 SelfTest(cmdLine_serial);
whismanoid 0:3edb3708c8c5 2650
whismanoid 0:3edb3708c8c5 2651 #if 0 // APPLICATION_MAX5715 // onButton1FallingEdge BUTTON1 demo configuration MAX5715BOB
whismanoid 0:3edb3708c8c5 2652 //~ cmdLine.serial().printf("MAX5715_REF(REF_AlwaysOn_2V500)");
whismanoid 0:3edb3708c8c5 2653 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500);
whismanoid 0:3edb3708c8c5 2654
whismanoid 0:3edb3708c8c5 2655 uint16_t code = 4095;
whismanoid 0:3edb3708c8c5 2656 //~ cmdLine.serial().printf("CODEallLOADall code=%d", code);
whismanoid 0:3edb3708c8c5 2657 g_MAX5715_device.CODEallLOADall(code);
whismanoid 0:3edb3708c8c5 2658 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 2659
whismanoid 0:3edb3708c8c5 2660 }
whismanoid 0:3edb3708c8c5 2661 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 2662
whismanoid 0:3edb3708c8c5 2663 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2664 // When user presses button BUTTON2, perform a demo configuration
whismanoid 0:3edb3708c8c5 2665 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 2666 void onButton2FallingEdge(void)
whismanoid 0:3edb3708c8c5 2667 {
whismanoid 0:3edb3708c8c5 2668 // TODO1: BUTTON2 demo configuration LED blink
whismanoid 0:3edb3708c8c5 2669
whismanoid 0:3edb3708c8c5 2670 #if APPLICATION_MAX5715 // onButton2FallingEdge BUTTON2 demo configuration MAX5715BOB
whismanoid 0:3edb3708c8c5 2671 //~ cmdLine.serial().printf("MAX5715_REF(REF_AlwaysOn_2V048)");
whismanoid 0:3edb3708c8c5 2672 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048);
whismanoid 0:3edb3708c8c5 2673 //
whismanoid 0:3edb3708c8c5 2674 uint16_t ch = 0;
whismanoid 0:3edb3708c8c5 2675 uint16_t code = 0xccc;
whismanoid 0:3edb3708c8c5 2676 //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 2677 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2678 //
whismanoid 0:3edb3708c8c5 2679 ch = 1;
whismanoid 0:3edb3708c8c5 2680 code = 0x800;
whismanoid 0:3edb3708c8c5 2681 //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 2682 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2683 //
whismanoid 0:3edb3708c8c5 2684 ch = 2;
whismanoid 0:3edb3708c8c5 2685 code = 0x666;
whismanoid 0:3edb3708c8c5 2686 //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 2687 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2688 //
whismanoid 0:3edb3708c8c5 2689 ch = 3;
whismanoid 0:3edb3708c8c5 2690 code = 0xFFF;
whismanoid 0:3edb3708c8c5 2691 //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 2692 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2693 #elif APPLICATION_MAX11131 // onButton2FallingEdge BUTTON2 demo configuration MAX11131BOB
whismanoid 0:3edb3708c8c5 2694 // TODO1: demo
whismanoid 0:3edb3708c8c5 2695 // MAX11131 > 4
whismanoid 0:3edb3708c8c5 2696 // ScanStandardExternalClock ch=9 pm=0 id=1
whismanoid 0:3edb3708c8c5 2697 // ScanRead_nWords_chanID nWords=10
whismanoid 0:3edb3708c8c5 2698 // ch=0 xu=2964 = 0x0b94 = 1.8091V
whismanoid 0:3edb3708c8c5 2699 // ch=1 xu=2227 = 0x08b3 = 1.3593V
whismanoid 0:3edb3708c8c5 2700 // ch=2 xu=1570 = 0x0622 = 0.9583V
whismanoid 0:3edb3708c8c5 2701 // ch=3 xu=865 = 0x0361 = 0.5280V
whismanoid 0:3edb3708c8c5 2702 // ch=4 xu=630 = 0x0276 = 0.3845V
whismanoid 0:3edb3708c8c5 2703 // ch=5 xu=594 = 0x0252 = 0.3625V
whismanoid 0:3edb3708c8c5 2704 // ch=6 xu=461 = 0x01cd = 0.2814V
whismanoid 0:3edb3708c8c5 2705 // ch=7 xu=364 = 0x016c = 0.2222V
whismanoid 0:3edb3708c8c5 2706 // ch=8 xu=480 = 0x01e0 = 0.2930V
whismanoid 0:3edb3708c8c5 2707 // ch=9 xu=616 = 0x0268 = 0.3760V
whismanoid 0:3edb3708c8c5 2708 g_MAX11131_device.channelNumber_0_15 = 9;
whismanoid 0:3edb3708c8c5 2709 g_MAX11131_device.PowerManagement_0_2 = 0;
whismanoid 0:3edb3708c8c5 2710 g_MAX11131_device.chan_id_0_1 = 1;
whismanoid 0:3edb3708c8c5 2711 g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock();
whismanoid 0:3edb3708c8c5 2712 //
whismanoid 0:3edb3708c8c5 2713 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 2714 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 2715 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 2716 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 2717 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 2718 //
whismanoid 0:3edb3708c8c5 2719 // TODO: compare with mbed/Arduino AIN0-AIN3
whismanoid 0:3edb3708c8c5 2720 //
whismanoid 0:3edb3708c8c5 2721 #elif APPLICATION_MAX5171 // onButton2FallingEdge BUTTON2 demo configuration MAX5171BOB
whismanoid 0:3edb3708c8c5 2722 // TODO: demo
whismanoid 0:3edb3708c8c5 2723 uint16_t code = 0xccc;
whismanoid 0:3edb3708c8c5 2724 g_MAX5171_device.CODE(code);
whismanoid 0:3edb3708c8c5 2725 #elif APPLICATION_MAX11410 // onButton2FallingEdge BUTTON2 demo configuration MAX11410BOB
whismanoid 0:3edb3708c8c5 2726 // TODO: demo
whismanoid 0:3edb3708c8c5 2727 g_MAX11410_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2728 #elif APPLICATION_MAX12345 // onButton2FallingEdge BUTTON2 demo configuration MAX12345BOB
whismanoid 0:3edb3708c8c5 2729 // TODO: demo
whismanoid 0:3edb3708c8c5 2730 g_MAX12345_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 2731 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 2732 rgb_led.blue(); // diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 2733
whismanoid 0:3edb3708c8c5 2734 }
whismanoid 0:3edb3708c8c5 2735 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 2736
whismanoid 0:3edb3708c8c5 2737 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2738 // TODO1: use MaximTinyTester encapsulate SelfTest support functions
whismanoid 0:3edb3708c8c5 2739 //--------------------------------------------------
whismanoid 2:b3a8a0ca0a94 2740 #if APPLICATION_MAX5715 // SelfTest
whismanoid 2:b3a8a0ca0a94 2741 //
whismanoid 2:b3a8a0ca0a94 2742 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 2:b3a8a0ca0a94 2743 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 2:b3a8a0ca0a94 2744 //
whismanoid 2:b3a8a0ca0a94 2745 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2746 // uint8_t MAX5715::Init(void)
whismanoid 2:b3a8a0ca0a94 2747 // uint8_t (*fn_MAX5715_Init)() = [](){ return g_MAX5715_device.Init(); };
whismanoid 2:b3a8a0ca0a94 2748 uint8_t fn_MAX5715_Init() { return g_MAX5715_device.Init(); };
whismanoid 2:b3a8a0ca0a94 2749 //
whismanoid 2:b3a8a0ca0a94 2750 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2751 // uint16_t MAX5715::DACCodeOfVoltage(double voltageV)
whismanoid 2:b3a8a0ca0a94 2752 // uint16_t (*fn_MAX5715_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5715_device.DACCodeOfVoltage(voltageV); };
whismanoid 2:b3a8a0ca0a94 2753 uint16_t fn_MAX5715_DACCodeOfVoltage(double voltageV) { return g_MAX5715_device.DACCodeOfVoltage(voltageV); };
whismanoid 2:b3a8a0ca0a94 2754 //
whismanoid 2:b3a8a0ca0a94 2755 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2756 // double MAX5715::VoltageOfCode(uint16_t value_u14)
whismanoid 2:b3a8a0ca0a94 2757 //double (*fn_MAX5715_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5715_device.VoltageOfCode(value_u14); };
whismanoid 2:b3a8a0ca0a94 2758 double fn_MAX5715_VoltageOfCode(uint16_t value_u14) { return g_MAX5715_device.VoltageOfCode(value_u14); };
whismanoid 2:b3a8a0ca0a94 2759 //
whismanoid 2:b3a8a0ca0a94 2760 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2761 // void MAX5715::CODEnLOADn(uint8_t channel_0_3, uint16_t dacCodeLsbs)
whismanoid 2:b3a8a0ca0a94 2762 // 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 2763 void fn_MAX5715_CODEnLOADn (uint8_t channel_0_3, uint16_t dacCodeLsbs) { return g_MAX5715_device.CODEnLOADn(channel_0_3, dacCodeLsbs); };
whismanoid 2:b3a8a0ca0a94 2764 //
whismanoid 2:b3a8a0ca0a94 2765 #endif // APPLICATION_MAX5715 // SelfTest
whismanoid 2:b3a8a0ca0a94 2766 //--------------------------------------------------
whismanoid 2:b3a8a0ca0a94 2767 #if APPLICATION_MAX11131 // SelfTest
whismanoid 2:b3a8a0ca0a94 2768 //
whismanoid 2:b3a8a0ca0a94 2769 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 2:b3a8a0ca0a94 2770 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 2:b3a8a0ca0a94 2771 //
whismanoid 2:b3a8a0ca0a94 2772 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2773 //
whismanoid 2:b3a8a0ca0a94 2774 #endif // APPLICATION_MAX11131 // SelfTest
whismanoid 2:b3a8a0ca0a94 2775 //--------------------------------------------------
whismanoid 2:b3a8a0ca0a94 2776 #if APPLICATION_MAX5171 // SelfTest
whismanoid 2:b3a8a0ca0a94 2777 //
whismanoid 2:b3a8a0ca0a94 2778 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 2:b3a8a0ca0a94 2779 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 2:b3a8a0ca0a94 2780 //
whismanoid 2:b3a8a0ca0a94 2781 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2782 // uint8_t MAX5171::Init(void)
whismanoid 2:b3a8a0ca0a94 2783 // uint8_t (*fn_MAX5171_Init)() = [](){ return g_MAX5171_device.Init(); };
whismanoid 2:b3a8a0ca0a94 2784 uint8_t fn_MAX5171_Init() { return g_MAX5171_device.Init(); };
whismanoid 2:b3a8a0ca0a94 2785 //
whismanoid 2:b3a8a0ca0a94 2786 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2787 // uint16_t MAX5171::DACCodeOfVoltage(double voltageV)
whismanoid 2:b3a8a0ca0a94 2788 // uint16_t (*fn_MAX5171_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5171_device.DACCodeOfVoltage(voltageV); };
whismanoid 2:b3a8a0ca0a94 2789 uint16_t fn_MAX5171_DACCodeOfVoltage(double voltageV) { return g_MAX5171_device.DACCodeOfVoltage(voltageV); };
whismanoid 2:b3a8a0ca0a94 2790 //
whismanoid 2:b3a8a0ca0a94 2791 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2792 // double MAX5171::VoltageOfCode(uint16_t value_u14)
whismanoid 2:b3a8a0ca0a94 2793 // double (*fn_MAX5171_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5171_device.VoltageOfCode(value_u14); };
whismanoid 2:b3a8a0ca0a94 2794 double fn_MAX5171_VoltageOfCode(uint16_t value_u14) { return g_MAX5171_device.VoltageOfCode(value_u14); };
whismanoid 2:b3a8a0ca0a94 2795 //
whismanoid 2:b3a8a0ca0a94 2796 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2797 // uint8_t MAX5171::CODE_LOAD(uint16_t dacCodeLsbs)
whismanoid 2:b3a8a0ca0a94 2798 // uint8_t (*fn_MAX5171_CODE_LOAD)(uint16_t dacCodeLsbs) = [](uint16_t dacCodeLsbs){ return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); };
whismanoid 2:b3a8a0ca0a94 2799 uint8_t fn_MAX5171_CODE_LOAD(uint16_t dacCodeLsbs) { return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); };
whismanoid 2:b3a8a0ca0a94 2800 //
whismanoid 2:b3a8a0ca0a94 2801 //
whismanoid 2:b3a8a0ca0a94 2802 #endif // APPLICATION_MAX5171 // SelfTest
whismanoid 2:b3a8a0ca0a94 2803 //--------------------------------------------------
whismanoid 2:b3a8a0ca0a94 2804 #if APPLICATION_MAX11410 // SelfTest
whismanoid 2:b3a8a0ca0a94 2805 //
whismanoid 2:b3a8a0ca0a94 2806 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 2:b3a8a0ca0a94 2807 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 2:b3a8a0ca0a94 2808 //
whismanoid 2:b3a8a0ca0a94 2809 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2810 //
whismanoid 2:b3a8a0ca0a94 2811 #endif // APPLICATION_MAX11410 // SelfTest
whismanoid 2:b3a8a0ca0a94 2812 //--------------------------------------------------
whismanoid 2:b3a8a0ca0a94 2813 #if APPLICATION_MAX12345 // SelfTest
whismanoid 2:b3a8a0ca0a94 2814 //
whismanoid 2:b3a8a0ca0a94 2815 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 2:b3a8a0ca0a94 2816 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 2:b3a8a0ca0a94 2817 //
whismanoid 2:b3a8a0ca0a94 2818 // define function under test using C++11 lambda expression [](){}
whismanoid 2:b3a8a0ca0a94 2819 //
whismanoid 2:b3a8a0ca0a94 2820 #endif // APPLICATION_MAX12345 // SelfTest
whismanoid 2:b3a8a0ca0a94 2821 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2822 void SelfTest_print_DACCodeOfVoltage(CmdLine& cmdLine, double voltageV)
whismanoid 0:3edb3708c8c5 2823 {
whismanoid 0:3edb3708c8c5 2824 cmdLine.serial().printf("DACCodeOfVoltage(%6.4fV)", voltageV);
whismanoid 0:3edb3708c8c5 2825 // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001
whismanoid 0:3edb3708c8c5 2826 // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001
whismanoid 0:3edb3708c8c5 2827 //~ dtostrf(voltageV, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer
whismanoid 0:3edb3708c8c5 2828 //~ cmdLine.serial().printf(strOutLineBuffer);
whismanoid 0:3edb3708c8c5 2829 //~ cmdLine.serial().printf("V)");
whismanoid 0:3edb3708c8c5 2830 }
whismanoid 0:3edb3708c8c5 2831 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2832 #if APPLICATION_MAX5171 // SelfTest
whismanoid 0:3edb3708c8c5 2833 void SelfTest_print_VoltageOfCode(CmdLine& cmdLine, uint16_t value_u14)
whismanoid 0:3edb3708c8c5 2834 {
whismanoid 0:3edb3708c8c5 2835 cmdLine.serial().printf("VoltageOfCode(%d)", value_u14);
whismanoid 0:3edb3708c8c5 2836 }
whismanoid 0:3edb3708c8c5 2837 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 2838 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2839 #if APPLICATION_MAX5715 // SelfTest
whismanoid 0:3edb3708c8c5 2840 void SelfTest_print_Vref(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 2841 {
whismanoid 0:3edb3708c8c5 2842 cmdLine.serial().printf("VRef = %6.4fV LSB=%6.4fV", g_MAX5715_device.VRef, (g_MAX5715_device.VRef / 4095));
whismanoid 0:3edb3708c8c5 2843 //~ dtostrf(g_MAX5715_device.VRef, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer
whismanoid 0:3edb3708c8c5 2844 //~ cmdLine.serial().printf(strOutLineBuffer);
whismanoid 0:3edb3708c8c5 2845 //~ cmdLine.serial().printf("V LSB=");
whismanoid 0:3edb3708c8c5 2846 // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001
whismanoid 0:3edb3708c8c5 2847 // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001
whismanoid 0:3edb3708c8c5 2848 //~ dtostrf( (g_MAX5715_device.VRef / 4095), 6, 4, strOutLineBuffer); // value, width, precision, char* buffer
whismanoid 0:3edb3708c8c5 2849 //~ cmdLine.serial().printf(strOutLineBuffer);
whismanoid 0:3edb3708c8c5 2850 //~ cmdLine.serial().printf("V");
whismanoid 0:3edb3708c8c5 2851 }
whismanoid 0:3edb3708c8c5 2852 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 2853 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2854 #if APPLICATION_MAX5171 // SelfTest
whismanoid 0:3edb3708c8c5 2855 void SelfTest_print_Vref(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 2856 {
whismanoid 0:3edb3708c8c5 2857 cmdLine.serial().printf("VRef = %7.5fV LSB=%7.5fV", g_MAX5171_device.VRef, (g_MAX5171_device.VRef / 16383));
whismanoid 0:3edb3708c8c5 2858 // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001
whismanoid 0:3edb3708c8c5 2859 // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001
whismanoid 0:3edb3708c8c5 2860 }
whismanoid 0:3edb3708c8c5 2861 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 2862 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2863 #if HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 2864 MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 0:3edb3708c8c5 2865 #endif
whismanoid 0:3edb3708c8c5 2866 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2867 bool SelfTest_MAX541_Voltage(CmdLine & cmdLine, MAX541 &max541, double voltageV)
whismanoid 0:3edb3708c8c5 2868 {
whismanoid 0:3edb3708c8c5 2869 max541.Set_Voltage(voltageV);
whismanoid 0:3edb3708c8c5 2870 // 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 2871 cmdLine.serial().printf("\r\n Test Fixture: MAX541 set output to 0x%4.4x = %1.3fV",
whismanoid 0:3edb3708c8c5 2872 max541.Get_Code(), max541.Get_Voltage());
whismanoid 0:3edb3708c8c5 2873 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 0:3edb3708c8c5 2874 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 8:6bdfb1376fed 2875 MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4, led1, led2, led3);
whismanoid 0:3edb3708c8c5 2876 tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support
whismanoid 0:3edb3708c8c5 2877 tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support
whismanoid 0:3edb3708c8c5 2878 tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support
whismanoid 0:3edb3708c8c5 2879 tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support
whismanoid 0:3edb3708c8c5 2880 tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support
whismanoid 0:3edb3708c8c5 2881 tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support
whismanoid 0:3edb3708c8c5 2882 // low range channels AIN0, AIN1, AIN2, AIN3
whismanoid 0:3edb3708c8c5 2883 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 0:3edb3708c8c5 2884 // Platform board uses simple analog inputs
whismanoid 8:6bdfb1376fed 2885 MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5, led1, led2, led3);
whismanoid 0:3edb3708c8c5 2886 tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support
whismanoid 0:3edb3708c8c5 2887 tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support
whismanoid 0:3edb3708c8c5 2888 tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support
whismanoid 0:3edb3708c8c5 2889 tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support
whismanoid 0:3edb3708c8c5 2890 tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support
whismanoid 0:3edb3708c8c5 2891 tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support
whismanoid 0:3edb3708c8c5 2892 #endif
whismanoid 5:82037e281451 2893 tinyTester.Wait_Output_Settling(); // wait for MAX541 to settle
whismanoid 0:3edb3708c8c5 2894 // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 2895 tinyTester.err_threshold = 0.100;
whismanoid 0:3edb3708c8c5 2896 return tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
whismanoid 0:3edb3708c8c5 2897 }
whismanoid 0:3edb3708c8c5 2898 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2899 void SelfTest(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 2900 {
whismanoid 0:3edb3708c8c5 2901 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 2902 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 0:3edb3708c8c5 2903 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 8:6bdfb1376fed 2904 MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4, led1, led2, led3);
whismanoid 0:3edb3708c8c5 2905 tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support
whismanoid 0:3edb3708c8c5 2906 tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support
whismanoid 0:3edb3708c8c5 2907 tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support
whismanoid 0:3edb3708c8c5 2908 tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support
whismanoid 0:3edb3708c8c5 2909 tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support
whismanoid 0:3edb3708c8c5 2910 tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support
whismanoid 0:3edb3708c8c5 2911 // low range channels AIN0, AIN1, AIN2, AIN3
whismanoid 0:3edb3708c8c5 2912 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 0:3edb3708c8c5 2913 // Platform board uses simple analog inputs
whismanoid 8:6bdfb1376fed 2914 MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5, led1, led2, led3);
whismanoid 0:3edb3708c8c5 2915 tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support
whismanoid 0:3edb3708c8c5 2916 tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support
whismanoid 0:3edb3708c8c5 2917 tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support
whismanoid 0:3edb3708c8c5 2918 tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support
whismanoid 0:3edb3708c8c5 2919 tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support
whismanoid 0:3edb3708c8c5 2920 tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support
whismanoid 0:3edb3708c8c5 2921 #endif
whismanoid 8:6bdfb1376fed 2922 tinyTester.clear();
whismanoid 0:3edb3708c8c5 2923 #if APPLICATION_MAX5715 // SelfTest
whismanoid 0:3edb3708c8c5 2924 //
whismanoid 5:82037e281451 2925 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 0:3edb3708c8c5 2926 //
whismanoid 1:40369075c365 2927 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 1:40369075c365 2928 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 0:3edb3708c8c5 2929 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 2930 // uint8_t MAX5715::Init(void)
whismanoid 2:b3a8a0ca0a94 2931 //uint8_t (*fn_MAX5715_Init)() = [](){ return g_MAX5715_device.Init(); };
whismanoid 0:3edb3708c8c5 2932 //
whismanoid 0:3edb3708c8c5 2933 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 2934 // uint16_t MAX5715::DACCodeOfVoltage(double voltageV)
whismanoid 2:b3a8a0ca0a94 2935 //uint16_t (*fn_MAX5715_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5715_device.DACCodeOfVoltage(voltageV); };
whismanoid 0:3edb3708c8c5 2936 //
whismanoid 0:3edb3708c8c5 2937 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 2938 // double MAX5715::VoltageOfCode(uint16_t value_u14)
whismanoid 2:b3a8a0ca0a94 2939 //double (*fn_MAX5715_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5715_device.VoltageOfCode(value_u14); };
whismanoid 0:3edb3708c8c5 2940 //
whismanoid 0:3edb3708c8c5 2941 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 2942 // void MAX5715::CODEnLOADn(uint8_t channel_0_3, uint16_t dacCodeLsbs)
whismanoid 2:b3a8a0ca0a94 2943 //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 2944 //
whismanoid 0:3edb3708c8c5 2945 //
whismanoid 0:3edb3708c8c5 2946 //
whismanoid 0:3edb3708c8c5 2947 //
whismanoid 0:3edb3708c8c5 2948 //
whismanoid 0:3edb3708c8c5 2949 //------------------------------------------------------------
whismanoid 0:3edb3708c8c5 2950 g_MAX5715_device.VRef = 4.096; // MAX5715 12-bit LSB = 0.0010V
whismanoid 0:3edb3708c8c5 2951 SelfTest_print_Vref(cmdLine);
whismanoid 0:3edb3708c8c5 2952 //~ cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 2953 //
whismanoid 9:9b4232e20020 2954 tinyTester.blink_time_msec = 20; // quickly speed through the software verification
whismanoid 0:3edb3708c8c5 2955 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 0:3edb3708c8c5 2956 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS
whismanoid 0:3edb3708c8c5 2957 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0950, 0x0FFF);
whismanoid 0:3edb3708c8c5 2958 //
whismanoid 0:3edb3708c8c5 2959 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0945, 0x0FFF);
whismanoid 0:3edb3708c8c5 2960 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0944, 0x0FFE);
whismanoid 0:3edb3708c8c5 2961 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0943, 0x0FFE);
whismanoid 0:3edb3708c8c5 2962 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0942, 0x0FFE);
whismanoid 0:3edb3708c8c5 2963 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0941, 0x0FFE);
whismanoid 0:3edb3708c8c5 2964 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0940, 0x0FFE); // search for code transition
whismanoid 0:3edb3708c8c5 2965 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0939, 0x0FFE);
whismanoid 0:3edb3708c8c5 2966 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0938, 0x0FFE);
whismanoid 0:3edb3708c8c5 2967 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0937, 0x0FFE);
whismanoid 0:3edb3708c8c5 2968 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0936, 0x0FFE);
whismanoid 0:3edb3708c8c5 2969 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0935, 0x0FFD);
whismanoid 0:3edb3708c8c5 2970 //
whismanoid 0:3edb3708c8c5 2971 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0930, 0x0FFD);
whismanoid 0:3edb3708c8c5 2972 //
whismanoid 0:3edb3708c8c5 2973 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0480, 0x0800);
whismanoid 0:3edb3708c8c5 2974 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0470, 0x07FF);
whismanoid 0:3edb3708c8c5 2975 //
whismanoid 0:3edb3708c8c5 2976 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x03E8); // 1.0 volt
whismanoid 0:3edb3708c8c5 2977 //
whismanoid 0:3edb3708c8c5 2978 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0030, 0x0003);
whismanoid 0:3edb3708c8c5 2979 //
whismanoid 0:3edb3708c8c5 2980 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0020, 0x0002);
whismanoid 0:3edb3708c8c5 2981 //
whismanoid 0:3edb3708c8c5 2982 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0001);
whismanoid 0:3edb3708c8c5 2983 //
whismanoid 0:3edb3708c8c5 2984 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000);
whismanoid 0:3edb3708c8c5 2985 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 2986 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 2987 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 2988 //
whismanoid 0:3edb3708c8c5 2989 // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect
whismanoid 0:3edb3708c8c5 2990 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 4.0950);
whismanoid 0:3edb3708c8c5 2991 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 4.0940);
whismanoid 0:3edb3708c8c5 2992 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 2.0480);
whismanoid 0:3edb3708c8c5 2993 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 2.0470);
whismanoid 0:3edb3708c8c5 2994 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x03E8, 1.0000); // 1.0 volt
whismanoid 0:3edb3708c8c5 2995 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0010);
whismanoid 0:3edb3708c8c5 2996 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000);
whismanoid 0:3edb3708c8c5 2997 //
whismanoid 0:3edb3708c8c5 2998 //------------------------------------------------------------
whismanoid 0:3edb3708c8c5 2999 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3000 g_MAX5715_device.VRef = 2.048; // 12-bit LSB = 0.0005V
whismanoid 0:3edb3708c8c5 3001 SelfTest_print_Vref(cmdLine);
whismanoid 0:3edb3708c8c5 3002 //~ cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3003 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 0:3edb3708c8c5 3004 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS
whismanoid 0:3edb3708c8c5 3005 //
whismanoid 0:3edb3708c8c5 3006 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0480, 0x0FFF);
whismanoid 0:3edb3708c8c5 3007 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0479, 0x0FFF);
whismanoid 0:3edb3708c8c5 3008 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0478, 0x0FFF);
whismanoid 0:3edb3708c8c5 3009 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0477, 0x0FFF);
whismanoid 0:3edb3708c8c5 3010 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0476, 0x0FFF);
whismanoid 0:3edb3708c8c5 3011 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0475, 0x0FFF);
whismanoid 0:3edb3708c8c5 3012 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0474, 0x0FFF);
whismanoid 0:3edb3708c8c5 3013 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0473, 0x0FFF);
whismanoid 0:3edb3708c8c5 3014 //
whismanoid 0:3edb3708c8c5 3015 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0472, 0x0FFE);
whismanoid 0:3edb3708c8c5 3016 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0471, 0x0FFE);
whismanoid 0:3edb3708c8c5 3017 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0470, 0x0FFE);
whismanoid 0:3edb3708c8c5 3018 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0469, 0x0FFE);
whismanoid 0:3edb3708c8c5 3019 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0468, 0x0FFE);
whismanoid 0:3edb3708c8c5 3020 //
whismanoid 0:3edb3708c8c5 3021 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0467, 0x0FFD);
whismanoid 0:3edb3708c8c5 3022 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0466, 0x0FFD);
whismanoid 0:3edb3708c8c5 3023 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0465, 0x0FFD);
whismanoid 0:3edb3708c8c5 3024 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0464, 0x0FFD);
whismanoid 0:3edb3708c8c5 3025 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0463, 0x0FFD);
whismanoid 0:3edb3708c8c5 3026 //
whismanoid 0:3edb3708c8c5 3027 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0240, 0x0800);
whismanoid 0:3edb3708c8c5 3028 //
whismanoid 0:3edb3708c8c5 3029 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0235, 0x07FF);
whismanoid 0:3edb3708c8c5 3030 //
whismanoid 0:3edb3708c8c5 3031 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x07D0); // 1.0 volt
whismanoid 0:3edb3708c8c5 3032 //
whismanoid 0:3edb3708c8c5 3033 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0017, 0x0003);
whismanoid 0:3edb3708c8c5 3034 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0016, 0x0003);
whismanoid 0:3edb3708c8c5 3035 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0015, 0x0003);
whismanoid 0:3edb3708c8c5 3036 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0014, 0x0003);
whismanoid 0:3edb3708c8c5 3037 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0013, 0x0003);
whismanoid 0:3edb3708c8c5 3038 //
whismanoid 0:3edb3708c8c5 3039 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0012, 0x0002);
whismanoid 0:3edb3708c8c5 3040 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0011, 0x0002);
whismanoid 0:3edb3708c8c5 3041 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0002);
whismanoid 0:3edb3708c8c5 3042 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0009, 0x0002);
whismanoid 0:3edb3708c8c5 3043 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0008, 0x0002);
whismanoid 0:3edb3708c8c5 3044 //
whismanoid 0:3edb3708c8c5 3045 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0007, 0x0001);
whismanoid 0:3edb3708c8c5 3046 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0006, 0x0001);
whismanoid 0:3edb3708c8c5 3047 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0005, 0x0001);
whismanoid 0:3edb3708c8c5 3048 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0004, 0x0001);
whismanoid 0:3edb3708c8c5 3049 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0003, 0x0001);
whismanoid 0:3edb3708c8c5 3050 //
whismanoid 0:3edb3708c8c5 3051 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0002, 0x0000);
whismanoid 0:3edb3708c8c5 3052 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0001, 0x0000);
whismanoid 0:3edb3708c8c5 3053 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000);
whismanoid 0:3edb3708c8c5 3054 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3055 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3056 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3057 // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect
whismanoid 0:3edb3708c8c5 3058 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 2.0475);
whismanoid 0:3edb3708c8c5 3059 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 2.0470);
whismanoid 0:3edb3708c8c5 3060 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFD, 2.0465);
whismanoid 0:3edb3708c8c5 3061 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 1.0240);
whismanoid 0:3edb3708c8c5 3062 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 1.0235);
whismanoid 0:3edb3708c8c5 3063 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07D0, 1.0000); // 1.0 volt
whismanoid 0:3edb3708c8c5 3064 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0002, 0.0010);
whismanoid 0:3edb3708c8c5 3065 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0005);
whismanoid 0:3edb3708c8c5 3066 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000);
whismanoid 0:3edb3708c8c5 3067 //
whismanoid 0:3edb3708c8c5 3068 //
whismanoid 0:3edb3708c8c5 3069 //------------------------------------------------------------
whismanoid 0:3edb3708c8c5 3070 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3071 g_MAX5715_device.VRef = 2.500; // 12-bit LSB = 0.0006105006105006105V
whismanoid 0:3edb3708c8c5 3072 SelfTest_print_Vref(cmdLine);
whismanoid 0:3edb3708c8c5 3073 //~ cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3074 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 0:3edb3708c8c5 3075 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS
whismanoid 0:3edb3708c8c5 3076 //
whismanoid 0:3edb3708c8c5 3077 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.5000, 0x0FFF);
whismanoid 0:3edb3708c8c5 3078 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4999, 0x0FFF);
whismanoid 0:3edb3708c8c5 3079 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4998, 0x0FFF);
whismanoid 0:3edb3708c8c5 3080 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4997, 0x0FFF);
whismanoid 0:3edb3708c8c5 3081 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4996, 0x0FFF);
whismanoid 0:3edb3708c8c5 3082 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4995, 0x0FFF);
whismanoid 0:3edb3708c8c5 3083 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4994, 0x0FFF);
whismanoid 0:3edb3708c8c5 3084 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4993, 0x0FFF);
whismanoid 0:3edb3708c8c5 3085 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4992, 0x0FFF);
whismanoid 0:3edb3708c8c5 3086 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4991, 0x0FFF);
whismanoid 0:3edb3708c8c5 3087 //
whismanoid 0:3edb3708c8c5 3088 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4990, 0x0FFE); // search for code transitions
whismanoid 0:3edb3708c8c5 3089 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4989, 0x0FFE);
whismanoid 0:3edb3708c8c5 3090 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4988, 0x0FFE);
whismanoid 0:3edb3708c8c5 3091 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4987, 0x0FFE);
whismanoid 0:3edb3708c8c5 3092 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4986, 0x0FFE);
whismanoid 0:3edb3708c8c5 3093 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4985, 0x0FFE);
whismanoid 0:3edb3708c8c5 3094 //
whismanoid 0:3edb3708c8c5 3095 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4984, 0x0FFD);
whismanoid 0:3edb3708c8c5 3096 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4983, 0x0FFD);
whismanoid 0:3edb3708c8c5 3097 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4982, 0x0FFD);
whismanoid 0:3edb3708c8c5 3098 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4981, 0x0FFD);
whismanoid 0:3edb3708c8c5 3099 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4980, 0x0FFD);
whismanoid 0:3edb3708c8c5 3100 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4979, 0x0FFD);
whismanoid 0:3edb3708c8c5 3101 //
whismanoid 0:3edb3708c8c5 3102 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4978, 0x0FFC);
whismanoid 0:3edb3708c8c5 3103 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4977, 0x0FFC);
whismanoid 0:3edb3708c8c5 3104 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4976, 0x0FFC);
whismanoid 0:3edb3708c8c5 3105 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4975, 0x0FFC);
whismanoid 0:3edb3708c8c5 3106 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4974, 0x0FFC);
whismanoid 0:3edb3708c8c5 3107 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4973, 0x0FFC);
whismanoid 0:3edb3708c8c5 3108 //
whismanoid 0:3edb3708c8c5 3109 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4972, 0x0FFB);
whismanoid 0:3edb3708c8c5 3110 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4971, 0x0FFB);
whismanoid 0:3edb3708c8c5 3111 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4970, 0x0FFB);
whismanoid 0:3edb3708c8c5 3112 //
whismanoid 0:3edb3708c8c5 3113 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.2500, 0x0800);
whismanoid 0:3edb3708c8c5 3114 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.2494, 0x07FF);
whismanoid 0:3edb3708c8c5 3115 //
whismanoid 0:3edb3708c8c5 3116 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x0666); // 1.0 volt
whismanoid 0:3edb3708c8c5 3117 //
whismanoid 0:3edb3708c8c5 3118 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0019, 0x0003); // search for code transitions
whismanoid 0:3edb3708c8c5 3119 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0018, 0x0003);
whismanoid 0:3edb3708c8c5 3120 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0017, 0x0003);
whismanoid 0:3edb3708c8c5 3121 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0016, 0x0003);
whismanoid 0:3edb3708c8c5 3122 //
whismanoid 0:3edb3708c8c5 3123 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0015, 0x0002);
whismanoid 0:3edb3708c8c5 3124 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0014, 0x0002);
whismanoid 0:3edb3708c8c5 3125 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0013, 0x0002);
whismanoid 0:3edb3708c8c5 3126 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0012, 0x0002);
whismanoid 0:3edb3708c8c5 3127 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0011, 0x0002);
whismanoid 0:3edb3708c8c5 3128 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0002);
whismanoid 0:3edb3708c8c5 3129 //
whismanoid 0:3edb3708c8c5 3130 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0009, 0x0001);
whismanoid 0:3edb3708c8c5 3131 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0008, 0x0001);
whismanoid 0:3edb3708c8c5 3132 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0007, 0x0001);
whismanoid 0:3edb3708c8c5 3133 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0006, 0x0001);
whismanoid 0:3edb3708c8c5 3134 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0005, 0x0001);
whismanoid 0:3edb3708c8c5 3135 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0004, 0x0001);
whismanoid 0:3edb3708c8c5 3136 //
whismanoid 0:3edb3708c8c5 3137 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0003, 0x0000);
whismanoid 0:3edb3708c8c5 3138 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0002, 0x0000);
whismanoid 0:3edb3708c8c5 3139 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0001, 0x0000);
whismanoid 0:3edb3708c8c5 3140 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000);
whismanoid 0:3edb3708c8c5 3141 //
whismanoid 0:3edb3708c8c5 3142 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3143 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3144 tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS
whismanoid 0:3edb3708c8c5 3145 // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect
whismanoid 0:3edb3708c8c5 3146 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 2.5000);
whismanoid 0:3edb3708c8c5 3147 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 2.4988);
whismanoid 0:3edb3708c8c5 3148 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFD, 2.4976);
whismanoid 0:3edb3708c8c5 3149 //
whismanoid 0:3edb3708c8c5 3150 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 1.2500);
whismanoid 0:3edb3708c8c5 3151 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 1.2494);
whismanoid 0:3edb3708c8c5 3152 //
whismanoid 0:3edb3708c8c5 3153 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0667, 1.0000); // 1.0 volt
whismanoid 0:3edb3708c8c5 3154 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0666, 1.0000); // 1.0 volt
whismanoid 0:3edb3708c8c5 3155 //
whismanoid 0:3edb3708c8c5 3156 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0002, 0.0012);
whismanoid 0:3edb3708c8c5 3157 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0006);
whismanoid 0:3edb3708c8c5 3158 tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000);
whismanoid 0:3edb3708c8c5 3159 //
whismanoid 0:3edb3708c8c5 3160 //
whismanoid 0:3edb3708c8c5 3161 // Device Testing: DAC commands, verify using on-board ADC inputs
whismanoid 0:3edb3708c8c5 3162 //
whismanoid 9:9b4232e20020 3163 tinyTester.blink_time_msec = 75;
whismanoid 0:3edb3708c8c5 3164 cmdLine.serial().printf("\r\n MAX5715.Init()");
whismanoid 0:3edb3708c8c5 3165 g_MAX5715_device.Init();
whismanoid 0:3edb3708c8c5 3166 //
whismanoid 0:3edb3708c8c5 3167 uint16_t ch = 0;
whismanoid 0:3edb3708c8c5 3168 uint16_t code = 0xfff;
whismanoid 0:3edb3708c8c5 3169 double voltageV = 0.5;
whismanoid 0:3edb3708c8c5 3170 //
whismanoid 0:3edb3708c8c5 3171 // full-scale output on ch0, test MAX5715 internal REF options
whismanoid 0:3edb3708c8c5 3172 ch = 0;
whismanoid 0:3edb3708c8c5 3173 cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 3174 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 3175 //
whismanoid 0:3edb3708c8c5 3176 cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_2V048)");
whismanoid 0:3edb3708c8c5 3177 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048);
whismanoid 5:82037e281451 3178 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3179 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3180 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3181 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3182 tinyTester.AnalogIn0_Read_Expect_voltageV(2.048);
whismanoid 0:3edb3708c8c5 3183 //
whismanoid 0:3edb3708c8c5 3184 cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_4V096)");
whismanoid 0:3edb3708c8c5 3185 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_4V096);
whismanoid 0:3edb3708c8c5 3186 // MAX32625MBED 4.096V may be as low as 3.3V supply
whismanoid 5:82037e281451 3187 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3188 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3189 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3190 tinyTester.err_threshold = 0.50; // 30mV
whismanoid 0:3edb3708c8c5 3191 tinyTester.AnalogIn0_Read_Expect_voltageV(3.750); // accept 3.25V to 4.25V
whismanoid 0:3edb3708c8c5 3192 //
whismanoid 0:3edb3708c8c5 3193 cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_2V500)");
whismanoid 0:3edb3708c8c5 3194 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500);
whismanoid 5:82037e281451 3195 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3196 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3197 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3198 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3199 tinyTester.AnalogIn0_Read_Expect_voltageV(2.500);
whismanoid 0:3edb3708c8c5 3200 //
whismanoid 0:3edb3708c8c5 3201 // test the individual channel outputs
whismanoid 0:3edb3708c8c5 3202 ch = 0;
whismanoid 0:3edb3708c8c5 3203 voltageV = 0.5;
whismanoid 0:3edb3708c8c5 3204 code = g_MAX5715_device.DACCodeOfVoltage(voltageV);
whismanoid 0:3edb3708c8c5 3205 cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 3206 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 5:82037e281451 3207 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3208 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3209 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3210 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3211 tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
whismanoid 0:3edb3708c8c5 3212 //
whismanoid 0:3edb3708c8c5 3213 ch = 1;
whismanoid 0:3edb3708c8c5 3214 voltageV = 0.2;
whismanoid 0:3edb3708c8c5 3215 code = g_MAX5715_device.DACCodeOfVoltage(voltageV);
whismanoid 0:3edb3708c8c5 3216 cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 3217 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 5:82037e281451 3218 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3219 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3220 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3221 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3222 tinyTester.AnalogIn1_Read_Expect_voltageV(voltageV);
whismanoid 0:3edb3708c8c5 3223 //
whismanoid 0:3edb3708c8c5 3224 ch = 2;
whismanoid 0:3edb3708c8c5 3225 voltageV = 0.4;
whismanoid 0:3edb3708c8c5 3226 code = g_MAX5715_device.DACCodeOfVoltage(voltageV);
whismanoid 0:3edb3708c8c5 3227 cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 3228 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 5:82037e281451 3229 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3230 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3231 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3232 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3233 tinyTester.AnalogIn2_Read_Expect_voltageV(voltageV);
whismanoid 0:3edb3708c8c5 3234 //
whismanoid 0:3edb3708c8c5 3235 ch = 3;
whismanoid 0:3edb3708c8c5 3236 voltageV = 0.25;
whismanoid 0:3edb3708c8c5 3237 code = g_MAX5715_device.DACCodeOfVoltage(voltageV);
whismanoid 0:3edb3708c8c5 3238 cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 3239 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 5:82037e281451 3240 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3241 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3242 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3243 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3244 tinyTester.AnalogIn3_Read_Expect_voltageV(voltageV);
whismanoid 0:3edb3708c8c5 3245 //
whismanoid 0:3edb3708c8c5 3246 // test that the channels are independent
whismanoid 0:3edb3708c8c5 3247 tinyTester.AnalogIn0_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[0]));
whismanoid 0:3edb3708c8c5 3248 tinyTester.AnalogIn1_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[1]));
whismanoid 0:3edb3708c8c5 3249 tinyTester.AnalogIn2_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[2]));
whismanoid 0:3edb3708c8c5 3250 tinyTester.AnalogIn3_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[3]));
whismanoid 0:3edb3708c8c5 3251 //
whismanoid 0:3edb3708c8c5 3252 #elif APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 3253 //
whismanoid 0:3edb3708c8c5 3254 // MAX11131BOB self-test functions
whismanoid 0:3edb3708c8c5 3255 //~ SelfTest_FAIL(cmdLine);
whismanoid 0:3edb3708c8c5 3256 //~ cmdLine.serial().printf("test program not implemented yet");
whismanoid 0:3edb3708c8c5 3257 int16_t value_u12;
whismanoid 0:3edb3708c8c5 3258 int channelId;
whismanoid 0:3edb3708c8c5 3259 double voltageV = 0.5;
whismanoid 0:3edb3708c8c5 3260 //
whismanoid 0:3edb3708c8c5 3261 //cmdLine.serial().printf("\r\n 0.0: MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3262 //g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3263 //
whismanoid 0:3edb3708c8c5 3264 // Device Testing: ADC commands, verify with on-board ADC and SPI framing
whismanoid 0:3edb3708c8c5 3265 //
whismanoid 9:9b4232e20020 3266 tinyTester.blink_time_msec = 75;
whismanoid 0:3edb3708c8c5 3267 // MAX11131 SelfTest: MAX11131 SPI connections (Power Supply and GND, SCLK, MOSI, MISO, CS)
whismanoid 0:3edb3708c8c5 3268 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3269 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 3270 "\r\n 1.0: Test SCAN_0100_StandardExt -- verify SPI (VDD, GND, SCLK, MOSI, MISO, CS)");
whismanoid 0:3edb3708c8c5 3271 cmdLine.serial().printf("\r\n MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3272 g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3273 // Send MOSI data Expect MISO data Description
whismanoid 0:3edb3708c8c5 3274 // 1000_0000_0000_0000 xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0
whismanoid 0:3edb3708c8c5 3275 // 0010_0111_1010_0100 xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL SCAN_0100_StandardExt CHSEL=15 RESET=1 CHANID=1
whismanoid 0:3edb3708c8c5 3276 // 0000_0000_0000_0000 0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0
whismanoid 0:3edb3708c8c5 3277 // 0000_0000_0000_0000 0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1
whismanoid 0:3edb3708c8c5 3278 // 0000_0000_0000_0000 0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2
whismanoid 0:3edb3708c8c5 3279 // 0000_0000_0000_0000 0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3
whismanoid 0:3edb3708c8c5 3280 //
whismanoid 0:3edb3708c8c5 3281 cmdLine.serial().printf("\r\n MOSI <-- 1000_0000_0000_0000 ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0");
whismanoid 0:3edb3708c8c5 3282 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3283 g_MAX11131_device.SPIwrite16bits(0x8000);
whismanoid 0:3edb3708c8c5 3284 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 0:3edb3708c8c5 3285 //
whismanoid 0:3edb3708c8c5 3286 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 3287 "\r\n MOSI <-- 0010_0111_1010_0100 ADC_MODE_CONTROL SCAN_0100_StandardExt CHSEL=15 RESET=1 CHANID=1");
whismanoid 0:3edb3708c8c5 3288 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3289 g_MAX11131_device.SPIwrite16bits(0x27a4);
whismanoid 0:3edb3708c8c5 3290 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 0:3edb3708c8c5 3291 //
whismanoid 0:3edb3708c8c5 3292 for (int channelIndex = 0; channelIndex < 16; channelIndex++) {
whismanoid 0:3edb3708c8c5 3293 //~ cmdLine.serial().printf("\r\n MISO --> expect 0000_xxxx_xxxx_xxxx");
whismanoid 0:3edb3708c8c5 3294 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3295 g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits();
whismanoid 0:3edb3708c8c5 3296 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 0:3edb3708c8c5 3297 int expect_channelId = channelIndex;
whismanoid 0:3edb3708c8c5 3298 int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F;
whismanoid 0:3edb3708c8c5 3299 if (actual_channelId != expect_channelId)
whismanoid 0:3edb3708c8c5 3300 {
whismanoid 3:8913cb4a8b9f 3301 tinyTester.FAIL();
whismanoid 0:3edb3708c8c5 3302 cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
whismanoid 0:3edb3708c8c5 3303 cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
whismanoid 0:3edb3708c8c5 3304 cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId);
whismanoid 0:3edb3708c8c5 3305 }
whismanoid 0:3edb3708c8c5 3306 else
whismanoid 0:3edb3708c8c5 3307 {
whismanoid 3:8913cb4a8b9f 3308 tinyTester.PASS();
whismanoid 0:3edb3708c8c5 3309 cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
whismanoid 0:3edb3708c8c5 3310 cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
whismanoid 0:3edb3708c8c5 3311 }
whismanoid 0:3edb3708c8c5 3312 }
whismanoid 0:3edb3708c8c5 3313 //
whismanoid 5:82037e281451 3314 // MAX11131 SelfTest: MAX11131 Supports Internal Clock Modes (CNVST, EOC)
whismanoid 0:3edb3708c8c5 3315 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3316 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 3317 "\r\n 1.1: Test SCAN_0011_StandardInt -- verify Internal Clock signals (CNVST, EOC)");
whismanoid 0:3edb3708c8c5 3318 cmdLine.serial().printf("\r\n MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3319 g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3320 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3321 g_MAX11131_device.RAW_misoData16[0] = g_MAX11131_device.SPIread16bits();
whismanoid 0:3edb3708c8c5 3322 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 3:8913cb4a8b9f 3323 //
whismanoid 5:82037e281451 3324 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
whismanoid 3:8913cb4a8b9f 3325 tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "initial value before sending commands");
whismanoid 3:8913cb4a8b9f 3326 //
whismanoid 0:3edb3708c8c5 3327 // Send MOSI data Expect MISO data Description
whismanoid 0:3edb3708c8c5 3328 // 1000_0000_0000_0000 xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0 No Averaging
whismanoid 0:3edb3708c8c5 3329 // 0001_1001_1010_0000 xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL SCAN_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0
whismanoid 0:3edb3708c8c5 3330 // 0000_0000_0000_0000 0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0
whismanoid 0:3edb3708c8c5 3331 // 0000_0000_0000_0000 0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1
whismanoid 0:3edb3708c8c5 3332 // 0000_0000_0000_0000 0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2
whismanoid 0:3edb3708c8c5 3333 // 0000_0000_0000_0000 0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3
whismanoid 0:3edb3708c8c5 3334 //
whismanoid 0:3edb3708c8c5 3335 cmdLine.serial().printf("\r\n MOSI <-- 1000_0000_0000_0000 ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0");
whismanoid 0:3edb3708c8c5 3336 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3337 g_MAX11131_device.SPIwrite16bits(0x8000);
whismanoid 0:3edb3708c8c5 3338 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 0:3edb3708c8c5 3339 //
whismanoid 0:3edb3708c8c5 3340 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 3341 "\r\n MOSI <-- 0001_1001_1010_0000 ADC_MODE_CONTROL SCAN_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0");
whismanoid 0:3edb3708c8c5 3342 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3343 g_MAX11131_device.SPIwrite16bits(0x19a0);
whismanoid 0:3edb3708c8c5 3344 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 0:3edb3708c8c5 3345 //
whismanoid 0:3edb3708c8c5 3346 for (int channelIndex = 0; channelIndex < 4; channelIndex++) {
whismanoid 0:3edb3708c8c5 3347 //~ cmdLine.serial().printf("\r\n MISO --> expect 0000_xxxx_xxxx_xxxx");
whismanoid 0:3edb3708c8c5 3348 //~ wait_ms(200); // delay
whismanoid 0:3edb3708c8c5 3349 g_MAX11131_device.CNVSToutputPulseLow();
whismanoid 0:3edb3708c8c5 3350 //~ g_MAX11131_device.CNVSToutputValue(0);
whismanoid 0:3edb3708c8c5 3351 //~ wait_ms(100); // delay
whismanoid 0:3edb3708c8c5 3352 //~ g_MAX11131_device.CNVSToutputValue(1);
whismanoid 0:3edb3708c8c5 3353 // g_MAX11131_device.EOCinputWaitUntilLow(); // infinite wait hazard, need to fail if timeout exceeded
whismanoid 5:82037e281451 3354 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
whismanoid 3:8913cb4a8b9f 3355 tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 0, "after CNVST pulse");
whismanoid 0:3edb3708c8c5 3356 g_MAX11131_device.SPIoutputCS(0); // drive CS low
whismanoid 0:3edb3708c8c5 3357 g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits();
whismanoid 0:3edb3708c8c5 3358 g_MAX11131_device.SPIoutputCS(1); // drive CS high
whismanoid 5:82037e281451 3359 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
whismanoid 3:8913cb4a8b9f 3360 tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "after SPI read");
whismanoid 0:3edb3708c8c5 3361 int expect_channelId = channelIndex;
whismanoid 0:3edb3708c8c5 3362 int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F;
whismanoid 0:3edb3708c8c5 3363 if (actual_channelId != expect_channelId)
whismanoid 0:3edb3708c8c5 3364 {
whismanoid 3:8913cb4a8b9f 3365 tinyTester.FAIL();
whismanoid 0:3edb3708c8c5 3366 cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
whismanoid 0:3edb3708c8c5 3367 cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
whismanoid 0:3edb3708c8c5 3368 cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId);
whismanoid 0:3edb3708c8c5 3369 }
whismanoid 0:3edb3708c8c5 3370 else
whismanoid 0:3edb3708c8c5 3371 {
whismanoid 3:8913cb4a8b9f 3372 tinyTester.PASS();
whismanoid 0:3edb3708c8c5 3373 cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
whismanoid 0:3edb3708c8c5 3374 cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
whismanoid 0:3edb3708c8c5 3375 }
whismanoid 0:3edb3708c8c5 3376 }
whismanoid 0:3edb3708c8c5 3377 //
whismanoid 5:82037e281451 3378 // MAX11131 SelfTest: Test Fixture: MAX541ACPA+ to MAX32625MBED.AIN0/AIN4
whismanoid 0:3edb3708c8c5 3379 // Test Fixture: MAX541 connected to spi2
whismanoid 0:3edb3708c8c5 3380 // 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 3381 // DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header
whismanoid 0:3edb3708c8c5 3382 // Test Fixture: MAX541 spi2 init
whismanoid 0:3edb3708c8c5 3383 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3384 cmdLine.serial().printf("\r\n 2.0: Test Fixture: MAX541 connected to spi2 (P2.4 P2.5 P2.7)?");
whismanoid 0:3edb3708c8c5 3385 bool SelfTest_has_max541 = false;
whismanoid 0:3edb3708c8c5 3386 // Check actual MAX541 reference voltage
whismanoid 0:3edb3708c8c5 3387 cmdLine.serial().printf("\r\n Test Fixture: MAX541 midscale voltage measure with MAX32625MBED AIN0/4");
whismanoid 0:3edb3708c8c5 3388 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 5:82037e281451 3389 tinyTester.Wait_Output_Settling(); // wait for MAX541 to settle
whismanoid 5:82037e281451 3390 //
whismanoid 0:3edb3708c8c5 3391 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 3392 const int average_count = 100;
whismanoid 0:3edb3708c8c5 3393 const double average_K = 0.25;
whismanoid 0:3edb3708c8c5 3394 for (int count = 0; count < average_count; count++) {
whismanoid 0:3edb3708c8c5 3395 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:3edb3708c8c5 3396 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 0:3edb3708c8c5 3397 }
whismanoid 0:3edb3708c8c5 3398 if (max541_midscale_V > 1.0f) {
whismanoid 0:3edb3708c8c5 3399 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 0:3edb3708c8c5 3400 cmdLine.serial().printf("\r\n Test Fixture: MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 0:3edb3708c8c5 3401 max541_midscale_V, max541.VRef);
whismanoid 0:3edb3708c8c5 3402 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 0:3edb3708c8c5 3403 voltageV = 1.0f;
whismanoid 0:3edb3708c8c5 3404 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3405 }
whismanoid 0:3edb3708c8c5 3406 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3407 voltageV = 0.0f;
whismanoid 0:3edb3708c8c5 3408 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3409 }
whismanoid 0:3edb3708c8c5 3410 if (SelfTest_has_max541) {
whismanoid 5:82037e281451 3411 voltageV = 2.7f;
whismanoid 0:3edb3708c8c5 3412 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3413 }
whismanoid 0:3edb3708c8c5 3414 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3415 voltageV = 1.65f;
whismanoid 0:3edb3708c8c5 3416 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3417 }
whismanoid 0:3edb3708c8c5 3418 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3419 voltageV = 2.0f;
whismanoid 0:3edb3708c8c5 3420 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3421 }
whismanoid 0:3edb3708c8c5 3422 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3423 voltageV = 0.25f;
whismanoid 0:3edb3708c8c5 3424 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3425 }
whismanoid 0:3edb3708c8c5 3426 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3427 voltageV = 0.5f;
whismanoid 0:3edb3708c8c5 3428 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3429 }
whismanoid 0:3edb3708c8c5 3430 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3431 voltageV = 1.0f;
whismanoid 0:3edb3708c8c5 3432 SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3433 }
whismanoid 0:3edb3708c8c5 3434 if (SelfTest_has_max541 == false) {
whismanoid 0:3edb3708c8c5 3435 // don't fail just because we're missing the test fixture...
whismanoid 0:3edb3708c8c5 3436 cmdLine.serial().printf("\r\n Test Fixture: MAX541 not present");
whismanoid 0:3edb3708c8c5 3437 //~ g_SelfTest_nFail--;
whismanoid 0:3edb3708c8c5 3438 }
whismanoid 0:3edb3708c8c5 3439 //
whismanoid 0:3edb3708c8c5 3440 // TODO1: MAX11131 SelfTest: if Test Fixture: drive MAX541, compare MAX32625MBED.AIN0/AIN4 and MAX11131 AIN0
whismanoid 0:3edb3708c8c5 3441 // indirectly verify the reference voltage by reading a known input voltage
whismanoid 0:3edb3708c8c5 3442 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3443 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3444 cmdLine.serial().printf("\r\n 2.1: TODO1: Check MAX11131 reference voltage using SCAN_0001_Manual");
whismanoid 0:3edb3708c8c5 3445 voltageV = 1.0f;
whismanoid 0:3edb3708c8c5 3446 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3447 cmdLine.serial().printf("\r\n MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3448 g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3449 // 1 ScanManual ch=0 pm=0 id=1
whismanoid 0:3edb3708c8c5 3450 g_MAX11131_device.channelNumber_0_15 = 0;
whismanoid 0:3edb3708c8c5 3451 g_MAX11131_device.PowerManagement_0_2 = 0;
whismanoid 0:3edb3708c8c5 3452 g_MAX11131_device.chan_id_0_1 = 1;
whismanoid 0:3edb3708c8c5 3453 cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15);
whismanoid 0:3edb3708c8c5 3454 cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2);
whismanoid 0:3edb3708c8c5 3455 cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1);
whismanoid 0:3edb3708c8c5 3456 g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
whismanoid 0:3edb3708c8c5 3457 cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d",
whismanoid 0:3edb3708c8c5 3458 g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3459 g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
whismanoid 0:3edb3708c8c5 3460 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 3461 cmdLine.serial().printf("\r\n MAX11131.ReadAINcode");
whismanoid 0:3edb3708c8c5 3462 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3463 //
whismanoid 0:3edb3708c8c5 3464 // 2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here?
whismanoid 0:3edb3708c8c5 3465 //
whismanoid 0:3edb3708c8c5 3466 cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d",
whismanoid 0:3edb3708c8c5 3467 g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3468 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 3469 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 3470 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 3471 cmdLine.serial().printf("\r\n MAX11131.ReadAINcode");
whismanoid 0:3edb3708c8c5 3472 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3473 //
whismanoid 0:3edb3708c8c5 3474 // 2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here?
whismanoid 0:3edb3708c8c5 3475 //
whismanoid 0:3edb3708c8c5 3476 // compare with mbed/Arduino AIN0-AIN3
whismanoid 0:3edb3708c8c5 3477 // MAX32625MBED.AIN4 = MAX11131.AIN0
whismanoid 0:3edb3708c8c5 3478 channelId = 0;
whismanoid 0:3edb3708c8c5 3479 value_u12 = g_MAX11131_device.AINcode[channelId];
whismanoid 0:3edb3708c8c5 3480 voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
whismanoid 3:8913cb4a8b9f 3481 //
whismanoid 5:82037e281451 3482 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 3:8913cb4a8b9f 3483 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3484 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 3:8913cb4a8b9f 3485 tinyTester.err_threshold = 0.100;
whismanoid 3:8913cb4a8b9f 3486 tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
whismanoid 3:8913cb4a8b9f 3487 //
whismanoid 0:3edb3708c8c5 3488 }
whismanoid 0:3edb3708c8c5 3489 //
whismanoid 0:3edb3708c8c5 3490 if (SelfTest_has_max541) {
whismanoid 0:3edb3708c8c5 3491 voltageV = 1.0f;
whismanoid 0:3edb3708c8c5 3492 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 0:3edb3708c8c5 3493 }
whismanoid 0:3edb3708c8c5 3494 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3495 cmdLine.serial().printf("\r\n 3.1: Test SCAN_0001_Manual");
whismanoid 0:3edb3708c8c5 3496 cmdLine.serial().printf("\r\n MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3497 g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3498 // 1 ScanManual ch=0 pm=0 id=1
whismanoid 0:3edb3708c8c5 3499 g_MAX11131_device.channelNumber_0_15 = 0;
whismanoid 0:3edb3708c8c5 3500 g_MAX11131_device.PowerManagement_0_2 = 0;
whismanoid 0:3edb3708c8c5 3501 g_MAX11131_device.chan_id_0_1 = 1;
whismanoid 0:3edb3708c8c5 3502 cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15);
whismanoid 0:3edb3708c8c5 3503 cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2);
whismanoid 0:3edb3708c8c5 3504 cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1);
whismanoid 0:3edb3708c8c5 3505 g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
whismanoid 0:3edb3708c8c5 3506 cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d",
whismanoid 0:3edb3708c8c5 3507 g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3508 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 3509 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 3510 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 3511 cmdLine.serial().printf("\r\n MAX11131.ReadAINcode");
whismanoid 0:3edb3708c8c5 3512 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3513 // compare with mbed/Arduino AIN0-AIN3
whismanoid 0:3edb3708c8c5 3514 // MAX32625MBED.AIN4 = MAX11131.AIN0
whismanoid 0:3edb3708c8c5 3515 channelId = 0;
whismanoid 0:3edb3708c8c5 3516 value_u12 = g_MAX11131_device.AINcode[channelId];
whismanoid 0:3edb3708c8c5 3517 voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
whismanoid 3:8913cb4a8b9f 3518 //
whismanoid 5:82037e281451 3519 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 3:8913cb4a8b9f 3520 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3521 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 3:8913cb4a8b9f 3522 tinyTester.err_threshold = 0.100;
whismanoid 3:8913cb4a8b9f 3523 tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
whismanoid 3:8913cb4a8b9f 3524 //
whismanoid 0:3edb3708c8c5 3525 //
whismanoid 0:3edb3708c8c5 3526 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 3527 cmdLine.serial().printf("\r\n 3.4: Test SCAN_0100_StandardExternalClock");
whismanoid 0:3edb3708c8c5 3528 cmdLine.serial().printf("\r\n MAX11131.Init()");
whismanoid 0:3edb3708c8c5 3529 g_MAX11131_device.Init();
whismanoid 0:3edb3708c8c5 3530 // MAX11131 > 4
whismanoid 0:3edb3708c8c5 3531 // ScanStandardExternalClock ch=9 pm=0 id=1
whismanoid 0:3edb3708c8c5 3532 // ScanRead_nWords_chanID nWords=10
whismanoid 0:3edb3708c8c5 3533 // ch=0 xu=2964 = 0x0b94 = 1.8091V
whismanoid 0:3edb3708c8c5 3534 // ch=1 xu=2227 = 0x08b3 = 1.3593V
whismanoid 0:3edb3708c8c5 3535 // ch=2 xu=1570 = 0x0622 = 0.9583V
whismanoid 0:3edb3708c8c5 3536 // ch=3 xu=865 = 0x0361 = 0.5280V
whismanoid 0:3edb3708c8c5 3537 // ch=4 xu=630 = 0x0276 = 0.3845V
whismanoid 0:3edb3708c8c5 3538 // ch=5 xu=594 = 0x0252 = 0.3625V
whismanoid 0:3edb3708c8c5 3539 // ch=6 xu=461 = 0x01cd = 0.2814V
whismanoid 0:3edb3708c8c5 3540 // ch=7 xu=364 = 0x016c = 0.2222V
whismanoid 0:3edb3708c8c5 3541 // ch=8 xu=480 = 0x01e0 = 0.2930V
whismanoid 0:3edb3708c8c5 3542 // ch=9 xu=616 = 0x0268 = 0.3760V
whismanoid 0:3edb3708c8c5 3543 g_MAX11131_device.channelNumber_0_15 = 9;
whismanoid 0:3edb3708c8c5 3544 g_MAX11131_device.PowerManagement_0_2 = 0;
whismanoid 0:3edb3708c8c5 3545 g_MAX11131_device.chan_id_0_1 = 1;
whismanoid 0:3edb3708c8c5 3546 cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15);
whismanoid 0:3edb3708c8c5 3547 cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2);
whismanoid 0:3edb3708c8c5 3548 cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1);
whismanoid 0:3edb3708c8c5 3549 g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock();
whismanoid 0:3edb3708c8c5 3550 cmdLine.serial().printf("\r\n MAX11131.ScanStandardExternalClock -- NumWords = %d",
whismanoid 0:3edb3708c8c5 3551 g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 3552 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 3553 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 3554 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 3555 cmdLine.serial().printf("\r\n MAX11131.ReadAINcode");
whismanoid 0:3edb3708c8c5 3556 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 3557 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 5:82037e281451 3558 // expect g_MAX11131_device.NumWords == g_MAX11131_device.channelNumber_0_15 + 1;
whismanoid 5:82037e281451 3559 // expect RAW_misoData16[index] msnybble 0,1,2,3,...
whismanoid 0:3edb3708c8c5 3560 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 5:82037e281451 3561 // compare with mbed/Arduino AIN0-AIN3
whismanoid 0:3edb3708c8c5 3562 // MAX32625MBED.AIN4 = MAX11131.AIN0
whismanoid 0:3edb3708c8c5 3563 channelId = 0;
whismanoid 0:3edb3708c8c5 3564 value_u12 = g_MAX11131_device.AINcode[channelId];
whismanoid 0:3edb3708c8c5 3565 voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
whismanoid 5:82037e281451 3566 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 3:8913cb4a8b9f 3567 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3568 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 3:8913cb4a8b9f 3569 tinyTester.err_threshold = 0.100;
whismanoid 3:8913cb4a8b9f 3570 tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
whismanoid 5:82037e281451 3571 // compare MAX32625MBED.AIN5 = MAX11131.AIN1
whismanoid 0:3edb3708c8c5 3572 //channelId = 1;
whismanoid 0:3edb3708c8c5 3573 //value_u12 = g_MAX11131_device.AINcode[channelId];
whismanoid 0:3edb3708c8c5 3574 //voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
whismanoid 0:3edb3708c8c5 3575 //SelfTest_AnalogInput_Expect_ch_V(cmdLine, 5, voltageV, 0.100);
whismanoid 0:3edb3708c8c5 3576 //
whismanoid 0:3edb3708c8c5 3577 #elif APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 3578
whismanoid 5:82037e281451 3579 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 0:3edb3708c8c5 3580 //
whismanoid 1:40369075c365 3581 // Note: ide.mbed.com does not support C++11 Lambda Expressions
whismanoid 1:40369075c365 3582 // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/
whismanoid 0:3edb3708c8c5 3583 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3584 // uint8_t MAX5171::Init(void)
whismanoid 2:b3a8a0ca0a94 3585 //uint8_t (*fn_MAX5171_Init)() = [](){ return g_MAX5171_device.Init(); };
whismanoid 0:3edb3708c8c5 3586 //
whismanoid 0:3edb3708c8c5 3587 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3588 // uint16_t MAX5171::DACCodeOfVoltage(double voltageV)
whismanoid 2:b3a8a0ca0a94 3589 //uint16_t (*fn_MAX5171_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5171_device.DACCodeOfVoltage(voltageV); };
whismanoid 0:3edb3708c8c5 3590 //
whismanoid 0:3edb3708c8c5 3591 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3592 // double MAX5171::VoltageOfCode(uint16_t value_u14)
whismanoid 2:b3a8a0ca0a94 3593 //double (*fn_MAX5171_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5171_device.VoltageOfCode(value_u14); };
whismanoid 0:3edb3708c8c5 3594 //
whismanoid 0:3edb3708c8c5 3595 // define function under test using C++11 lambda expression [](){}
whismanoid 0:3edb3708c8c5 3596 // uint8_t MAX5171::CODE_LOAD(uint16_t dacCodeLsbs)
whismanoid 2:b3a8a0ca0a94 3597 //uint8_t (*fn_MAX5171_CODE_LOAD)(uint16_t dacCodeLsbs) = [](uint16_t dacCodeLsbs){ return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); };
whismanoid 0:3edb3708c8c5 3598 //
whismanoid 0:3edb3708c8c5 3599 //double one_LSB = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS
whismanoid 5:82037e281451 3600 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3601 tinyTester.settle_time_msec = 250;
whismanoid 0:3edb3708c8c5 3602
whismanoid 0:3edb3708c8c5 3603 g_MAX5171_device.VRef = 2.500; // MAX5171 14-bit LSB = 0.00015V
whismanoid 0:3edb3708c8c5 3604 SelfTest_print_Vref(cmdLine);
whismanoid 8:6bdfb1376fed 3605 tinyTester.err_threshold = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS
whismanoid 0:3edb3708c8c5 3606 //
whismanoid 5:82037e281451 3607 // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect
whismanoid 9:9b4232e20020 3608 tinyTester.blink_time_msec = 20; // quickly speed through the software verification
whismanoid 0:3edb3708c8c5 3609 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.499847412109375, 0x3FFF);
whismanoid 0:3edb3708c8c5 3610 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.49969482421875, 0x3FFE);
whismanoid 0:3edb3708c8c5 3611 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.499542236328125, 0x3FFD);
whismanoid 0:3edb3708c8c5 3612 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.4993896484375, 0x3FFC);
whismanoid 0:3edb3708c8c5 3613 //
whismanoid 0:3edb3708c8c5 3614 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.250152587890625, 0x2001);
whismanoid 0:3edb3708c8c5 3615 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.25, 0x2000);
whismanoid 0:3edb3708c8c5 3616 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.249847412109375, 0x1FFF);
whismanoid 0:3edb3708c8c5 3617 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.24969482421875, 0x1FFE);
whismanoid 0:3edb3708c8c5 3618 //
whismanoid 0:3edb3708c8c5 3619 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.000457763671875, 0x0003);
whismanoid 0:3edb3708c8c5 3620 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.00030517578125, 0x0002);
whismanoid 0:3edb3708c8c5 3621 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.000152587890625, 0x0001);
whismanoid 0:3edb3708c8c5 3622 tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.00000, 0x0000);
whismanoid 0:3edb3708c8c5 3623 //
whismanoid 5:82037e281451 3624 // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect
whismanoid 0:3edb3708c8c5 3625 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFF, 2.499847412109375);
whismanoid 0:3edb3708c8c5 3626 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFE, 2.49969482421875);
whismanoid 0:3edb3708c8c5 3627 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFD, 2.499542236328125);
whismanoid 0:3edb3708c8c5 3628 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFC, 2.4993896484375);
whismanoid 0:3edb3708c8c5 3629 //
whismanoid 0:3edb3708c8c5 3630 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x2001, 1.250152587890625);
whismanoid 0:3edb3708c8c5 3631 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x2000, 1.25);
whismanoid 0:3edb3708c8c5 3632 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x1FFF, 1.249847412109375);
whismanoid 0:3edb3708c8c5 3633 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x1FFE, 1.24969482421875);
whismanoid 0:3edb3708c8c5 3634 //
whismanoid 0:3edb3708c8c5 3635 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0003, 0.000457763671875);
whismanoid 0:3edb3708c8c5 3636 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0002, 0.00030517578125);
whismanoid 0:3edb3708c8c5 3637 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0001, 0.000152587890625);
whismanoid 0:3edb3708c8c5 3638 tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0000, 0.00000);
whismanoid 0:3edb3708c8c5 3639 //
whismanoid 0:3edb3708c8c5 3640 // Device Testing: DAC commands, verify using on-board ADC inputs
whismanoid 0:3edb3708c8c5 3641 //
whismanoid 9:9b4232e20020 3642 tinyTester.blink_time_msec = 75;
whismanoid 0:3edb3708c8c5 3643 cmdLine.serial().printf("\r\n MAX5171.Init()");
whismanoid 0:3edb3708c8c5 3644 g_MAX5171_device.Init();
whismanoid 0:3edb3708c8c5 3645 //
whismanoid 0:3edb3708c8c5 3646 tinyTester.err_threshold = 0.030; // 30mV
whismanoid 0:3edb3708c8c5 3647 uint16_t code = 0x3FFF;
whismanoid 0:3edb3708c8c5 3648 //~ double voltageV = 0.5;
whismanoid 0:3edb3708c8c5 3649 //
whismanoid 0:3edb3708c8c5 3650 cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code);
whismanoid 0:3edb3708c8c5 3651 g_MAX5171_device.CODE_LOAD(code);
whismanoid 5:82037e281451 3652 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3653 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3654 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3655 tinyTester.AnalogIn0_Read_Expect_voltageV(2.500);
whismanoid 0:3edb3708c8c5 3656 //
whismanoid 0:3edb3708c8c5 3657 code = 0x0000;
whismanoid 0:3edb3708c8c5 3658 cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code);
whismanoid 0:3edb3708c8c5 3659 g_MAX5171_device.CODE_LOAD(code);
whismanoid 5:82037e281451 3660 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3661 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3662 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3663 tinyTester.AnalogIn0_Read_Expect_voltageV(0.0000);
whismanoid 0:3edb3708c8c5 3664 //
whismanoid 0:3edb3708c8c5 3665 code = 0x1FFF;
whismanoid 0:3edb3708c8c5 3666 cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code);
whismanoid 0:3edb3708c8c5 3667 g_MAX5171_device.CODE_LOAD(code);
whismanoid 5:82037e281451 3668 // tinyTester.Wait_Output_Settling replaces wait_ms
whismanoid 0:3edb3708c8c5 3669 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3670 // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
whismanoid 0:3edb3708c8c5 3671 tinyTester.AnalogIn0_Read_Expect_voltageV(1.2500);
whismanoid 0:3edb3708c8c5 3672 //
whismanoid 0:3edb3708c8c5 3673 // test UPO User Programmable Output, verify using digital input D2
whismanoid 0:3edb3708c8c5 3674 //
whismanoid 0:3edb3708c8c5 3675 cmdLine.serial().printf("\r\n MAX5171.UPO_HIGH");
whismanoid 0:3edb3708c8c5 3676 g_MAX5171_device.UPO_HIGH();
whismanoid 0:3edb3708c8c5 3677 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3678 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin
whismanoid 0:3edb3708c8c5 3679 tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command");
whismanoid 0:3edb3708c8c5 3680 //
whismanoid 0:3edb3708c8c5 3681 cmdLine.serial().printf("\r\n MAX5171.UPO_LOW");
whismanoid 0:3edb3708c8c5 3682 g_MAX5171_device.UPO_LOW();
whismanoid 0:3edb3708c8c5 3683 tinyTester.Wait_Output_Settling();
whismanoid 5:82037e281451 3684 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin
whismanoid 0:3edb3708c8c5 3685 tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 0, "UPO_pin is low after MAX5171 UPO_LOW command");
whismanoid 0:3edb3708c8c5 3686 //
whismanoid 0:3edb3708c8c5 3687 cmdLine.serial().printf("\r\n MAX5171.UPO_HIGH");
whismanoid 0:3edb3708c8c5 3688 g_MAX5171_device.UPO_HIGH();
whismanoid 0:3edb3708c8c5 3689 tinyTester.Wait_Output_Settling(); // wait_ms(100); // delay
whismanoid 5:82037e281451 3690 // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin
whismanoid 0:3edb3708c8c5 3691 tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command");
whismanoid 0:3edb3708c8c5 3692 //
whismanoid 0:3edb3708c8c5 3693 #elif APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 3694 //
whismanoid 0:3edb3708c8c5 3695 // TODO: placeholder for self-test functions
whismanoid 0:3edb3708c8c5 3696 SelfTest_FAIL(cmdLine);
whismanoid 0:3edb3708c8c5 3697 cmdLine.serial().printf("test program not implemented yet");
whismanoid 0:3edb3708c8c5 3698 //
whismanoid 0:3edb3708c8c5 3699 #elif APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 3700 //
whismanoid 0:3edb3708c8c5 3701 // TODO: placeholder for self-test functions
whismanoid 0:3edb3708c8c5 3702 SelfTest_FAIL(cmdLine);
whismanoid 0:3edb3708c8c5 3703 cmdLine.serial().printf("test program not implemented yet");
whismanoid 0:3edb3708c8c5 3704 //
whismanoid 0:3edb3708c8c5 3705 #else // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 3706 // TODO: placeholder for self-test functions
whismanoid 0:3edb3708c8c5 3707 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 3708 //
whismanoid 8:6bdfb1376fed 3709 #if INJECT_SELFTEST_FAIL
whismanoid 0:3edb3708c8c5 3710 // Test of the pass/fail report mechanism
whismanoid 0:3edb3708c8c5 3711 SelfTest_FAIL(cmdLine);
whismanoid 0:3edb3708c8c5 3712 cmdLine.serial().printf("injecting one false failure for test reporting");
whismanoid 0:3edb3708c8c5 3713 #endif
whismanoid 0:3edb3708c8c5 3714 //
whismanoid 0:3edb3708c8c5 3715 // Report number of pass and number of fail test results
whismanoid 0:3edb3708c8c5 3716 tinyTester.Report_Summary();
whismanoid 0:3edb3708c8c5 3717 }
whismanoid 0:3edb3708c8c5 3718
whismanoid 0:3edb3708c8c5 3719
whismanoid 0:3edb3708c8c5 3720 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 3721 void main_menu_status(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 3722 {
whismanoid 0:3edb3708c8c5 3723 cmdLine.serial().printf("\r\nMain menu");
whismanoid 0:3edb3708c8c5 3724 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 0:3edb3708c8c5 3725 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 0:3edb3708c8c5 3726 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 0:3edb3708c8c5 3727 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 0:3edb3708c8c5 3728 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 0:3edb3708c8c5 3729 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 0:3edb3708c8c5 3730 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 0:3edb3708c8c5 3731 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 0:3edb3708c8c5 3732 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 0:3edb3708c8c5 3733 cmdLine.serial().printf(" MAX12345");
whismanoid 0:3edb3708c8c5 3734 #else
whismanoid 0:3edb3708c8c5 3735 //cmdLine.serial().printf(" ");
whismanoid 0:3edb3708c8c5 3736 #endif
whismanoid 0:3edb3708c8c5 3737 cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 0:3edb3708c8c5 3738 if (cmdLine.nameStr())
whismanoid 0:3edb3708c8c5 3739 {
whismanoid 0:3edb3708c8c5 3740 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 0:3edb3708c8c5 3741 }
whismanoid 0:3edb3708c8c5 3742 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 3743 cmdLine.serial().printf(" [Button1=DemoConfig1]");
whismanoid 0:3edb3708c8c5 3744 #endif
whismanoid 0:3edb3708c8c5 3745 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 3746 cmdLine.serial().printf(" [Button2=DemoConfig2]");
whismanoid 0:3edb3708c8c5 3747 #endif
whismanoid 0:3edb3708c8c5 3748 #if HAS_BUTTON1_DEMO
whismanoid 0:3edb3708c8c5 3749 // print BUTTON1 status
whismanoid 0:3edb3708c8c5 3750 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 0:3edb3708c8c5 3751 #endif
whismanoid 0:3edb3708c8c5 3752 #if HAS_BUTTON2_DEMO
whismanoid 0:3edb3708c8c5 3753 // print BUTTON1 status
whismanoid 0:3edb3708c8c5 3754 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 0:3edb3708c8c5 3755 #endif
whismanoid 0:3edb3708c8c5 3756 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 0:3edb3708c8c5 3757 }
whismanoid 0:3edb3708c8c5 3758
whismanoid 0:3edb3708c8c5 3759 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 3760 void main_menu_help(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 3761 {
whismanoid 0:3edb3708c8c5 3762 // ? -- help
whismanoid 0:3edb3708c8c5 3763 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 0:3edb3708c8c5 3764 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 0:3edb3708c8c5 3765 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 0:3edb3708c8c5 3766 //cmdLine.serial().printf("\r\n ! -- Initial Configuration");
whismanoid 0:3edb3708c8c5 3767 //
whismanoid 0:3edb3708c8c5 3768 // % standardize diagnostic commands
whismanoid 0:3edb3708c8c5 3769 // %Hpin -- digital output high
whismanoid 0:3edb3708c8c5 3770 // %Lpin -- digital output low
whismanoid 0:3edb3708c8c5 3771 // %?pin -- digital input
whismanoid 0:3edb3708c8c5 3772 // %A %Apin -- analog input
whismanoid 0:3edb3708c8c5 3773 // %Ppin df=xx -- pwm output
whismanoid 0:3edb3708c8c5 3774 // %Wpin -- measure high pulsewidth input in usec
whismanoid 0:3edb3708c8c5 3775 // %wpin -- measure low pulsewidth input in usec
whismanoid 0:3edb3708c8c5 3776 // %I... -- I2C diagnostics
whismanoid 0:3edb3708c8c5 3777 // %IP -- I2C probe
whismanoid 0:3edb3708c8c5 3778 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 0:3edb3708c8c5 3779 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 0:3edb3708c8c5 3780 // %IR ADDR=? RD=? -- read
whismanoid 0:3edb3708c8c5 3781 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 0:3edb3708c8c5 3782 // %S... -- SPI diagnostics
whismanoid 0:3edb3708c8c5 3783 // %SC sclk=1Mhz -- SPI configure
whismanoid 0:3edb3708c8c5 3784 // %SW -- write (write and read)
whismanoid 0:3edb3708c8c5 3785 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 0:3edb3708c8c5 3786 // A-Z,a-z,0-9 reserved for application use
whismanoid 0:3edb3708c8c5 3787 //
whismanoid 0:3edb3708c8c5 3788 #if HAS_digitalInOuts
whismanoid 0:3edb3708c8c5 3789 // %Hpin -- digital output high
whismanoid 0:3edb3708c8c5 3790 // %Lpin -- digital output low
whismanoid 0:3edb3708c8c5 3791 // %?pin -- digital input
whismanoid 0:3edb3708c8c5 3792 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 0:3edb3708c8c5 3793 list_digitalInOutPins(cmdLine.serial());
whismanoid 0:3edb3708c8c5 3794 cmdLine.serial().printf("} -- High Output");
whismanoid 0:3edb3708c8c5 3795 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 0:3edb3708c8c5 3796 list_digitalInOutPins(cmdLine.serial());
whismanoid 0:3edb3708c8c5 3797 cmdLine.serial().printf("} -- Low Output");
whismanoid 0:3edb3708c8c5 3798 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 0:3edb3708c8c5 3799 list_digitalInOutPins(cmdLine.serial());
whismanoid 0:3edb3708c8c5 3800 cmdLine.serial().printf("} -- Input");
whismanoid 0:3edb3708c8c5 3801 #endif
whismanoid 0:3edb3708c8c5 3802
whismanoid 0:3edb3708c8c5 3803 #if HAS_analogIns
whismanoid 0:3edb3708c8c5 3804 // Menu A) analogRead A0..7
whismanoid 0:3edb3708c8c5 3805 // %A %Apin -- analog input
whismanoid 0:3edb3708c8c5 3806 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 0:3edb3708c8c5 3807 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 0:3edb3708c8c5 3808 #endif
whismanoid 0:3edb3708c8c5 3809
whismanoid 0:3edb3708c8c5 3810 #if HAS_SPI2_MAX541
whismanoid 0:3edb3708c8c5 3811 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 0:3edb3708c8c5 3812 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 0:3edb3708c8c5 3813 #endif
whismanoid 0:3edb3708c8c5 3814
whismanoid 0:3edb3708c8c5 3815 #if HAS_I2C // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 3816 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 3817 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 0:3edb3708c8c5 3818 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 0:3edb3708c8c5 3819 // %I... -- I2C diagnostics
whismanoid 0:3edb3708c8c5 3820 // %IP -- I2C probe
whismanoid 0:3edb3708c8c5 3821 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 0:3edb3708c8c5 3822 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 0:3edb3708c8c5 3823 // %IR ADDR=? RD=? -- read
whismanoid 0:3edb3708c8c5 3824 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 0:3edb3708c8c5 3825 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 0:3edb3708c8c5 3826 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 0:3edb3708c8c5 3827 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 0:3edb3708c8c5 3828 (g_I2C_SCL_Hz / 1000.));
whismanoid 0:3edb3708c8c5 3829 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 0:3edb3708c8c5 3830 g_I2C_deviceAddress7);
whismanoid 0:3edb3708c8c5 3831 //
whismanoid 0:3edb3708c8c5 3832 #if SUPPORT_I2C
whismanoid 0:3edb3708c8c5 3833 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 0:3edb3708c8c5 3834 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 0:3edb3708c8c5 3835 // test low-level I2C i2c_smbus_read_word_data
whismanoid 0:3edb3708c8c5 3836 #endif // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 3837 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 0:3edb3708c8c5 3838 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 0:3edb3708c8c5 3839 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 0:3edb3708c8c5 3840 #endif // SUPPORT_I2C
whismanoid 0:3edb3708c8c5 3841
whismanoid 0:3edb3708c8c5 3842 #if HAS_SPI // SUPPORT_SPI
whismanoid 0:3edb3708c8c5 3843 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 0:3edb3708c8c5 3844 // SPI test command S (mosiData)+
whismanoid 0:3edb3708c8c5 3845 // %S... -- SPI diagnostics
whismanoid 0:3edb3708c8c5 3846 // %SC sclk=1Mhz -- SPI configure
whismanoid 0:3edb3708c8c5 3847 // %SW -- write (write and read)
whismanoid 0:3edb3708c8c5 3848 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 0:3edb3708c8c5 3849 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 0:3edb3708c8c5 3850 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 0:3edb3708c8c5 3851 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 0:3edb3708c8c5 3852 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 0:3edb3708c8c5 3853 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 0:3edb3708c8c5 3854 // mode | POL PHA
whismanoid 0:3edb3708c8c5 3855 // -----+--------
whismanoid 0:3edb3708c8c5 3856 // 0 | 0 0
whismanoid 0:3edb3708c8c5 3857 // 1 | 0 1
whismanoid 0:3edb3708c8c5 3858 // 2 | 1 0
whismanoid 0:3edb3708c8c5 3859 // 3 | 1 1
whismanoid 0:3edb3708c8c5 3860 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 0:3edb3708c8c5 3861 // 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 3862 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 0:3edb3708c8c5 3863 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 0:3edb3708c8c5 3864 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 0:3edb3708c8c5 3865 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 0:3edb3708c8c5 3866 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 0:3edb3708c8c5 3867 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 0:3edb3708c8c5 3868 #endif // SUPPORT_SPI
whismanoid 0:3edb3708c8c5 3869 //
whismanoid 0:3edb3708c8c5 3870 // Application-specific commands (help text) here
whismanoid 0:3edb3708c8c5 3871 //
whismanoid 0:3edb3708c8c5 3872 #if APPLICATION_ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 3873 # if APPLICATION_MAX5715 // main_menu_help
whismanoid 0:3edb3708c8c5 3874 # elif APPLICATION_MAX11131 // main_menu_help
whismanoid 0:3edb3708c8c5 3875 # elif APPLICATION_MAX5171 // main_menu_help
whismanoid 0:3edb3708c8c5 3876 # elif APPLICATION_MAX11410 // main_menu_help
whismanoid 0:3edb3708c8c5 3877 # elif APPLICATION_MAX12345 // main_menu_help
whismanoid 0:3edb3708c8c5 3878 # else
whismanoid 0:3edb3708c8c5 3879 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 3880 # endif
whismanoid 0:3edb3708c8c5 3881 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 3882 //
whismanoid 0:3edb3708c8c5 3883 #if APPLICATION_MAX5715 // main_menu_help
whismanoid 0:3edb3708c8c5 3884 cmdLine.serial().printf("\r\n 0 ch=? code=? -- CODEn");
whismanoid 0:3edb3708c8c5 3885 cmdLine.serial().printf("\r\n 1 ch=? -- LOADn");
whismanoid 0:3edb3708c8c5 3886 cmdLine.serial().printf("\r\n 2 ch=? code=? -- CODEnLOADall");
whismanoid 0:3edb3708c8c5 3887 cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn");
whismanoid 0:3edb3708c8c5 3888 cmdLine.serial().printf("\r\n 40 ch=? -- POWERn_Normal");
whismanoid 0:3edb3708c8c5 3889 cmdLine.serial().printf("\r\n 41 ch=? -- POWERn_PD1k");
whismanoid 0:3edb3708c8c5 3890 cmdLine.serial().printf("\r\n 42 ch=? -- POWERn_PD100k");
whismanoid 0:3edb3708c8c5 3891 cmdLine.serial().printf("\r\n 43 ch=? -- POWERn_PDHiZ");
whismanoid 0:3edb3708c8c5 3892 cmdLine.serial().printf("\r\n 50 -- SW_CLEAR");
whismanoid 0:3edb3708c8c5 3893 cmdLine.serial().printf("\r\n 51 -- SW_RESET");
whismanoid 0:3edb3708c8c5 3894 cmdLine.serial().printf("\r\n 60 ch=? -- CONFIGn_LATCHED");
whismanoid 0:3edb3708c8c5 3895 cmdLine.serial().printf("\r\n 61 ch=? -- CONFIGn_TRANSPARENT");
whismanoid 0:3edb3708c8c5 3896 cmdLine.serial().printf("\r\n 68 -- CONFIGall_LATCHED");
whismanoid 0:3edb3708c8c5 3897 cmdLine.serial().printf("\r\n 69 -- CONFIGall_TRANSPARENT");
whismanoid 0:3edb3708c8c5 3898 cmdLine.serial().printf("\r\n 70 -- REF_EXT");
whismanoid 0:3edb3708c8c5 3899 cmdLine.serial().printf("\r\n 71 -- REF_2V500");
whismanoid 0:3edb3708c8c5 3900 cmdLine.serial().printf("\r\n 72 -- REF_2V048");
whismanoid 0:3edb3708c8c5 3901 cmdLine.serial().printf("\r\n 73 -- REF_4V096");
whismanoid 0:3edb3708c8c5 3902 cmdLine.serial().printf("\r\n 74 -- REF_AlwaysOn_EXT");
whismanoid 0:3edb3708c8c5 3903 cmdLine.serial().printf("\r\n 75 -- REF_AlwaysOn_2V500");
whismanoid 0:3edb3708c8c5 3904 cmdLine.serial().printf("\r\n 76 -- REF_AlwaysOn_2V048");
whismanoid 0:3edb3708c8c5 3905 cmdLine.serial().printf("\r\n 77 -- REF_AlwaysOn_4V096");
whismanoid 0:3edb3708c8c5 3906 cmdLine.serial().printf("\r\n 80 code=? -- CODEall");
whismanoid 0:3edb3708c8c5 3907 cmdLine.serial().printf("\r\n 81 -- LOADall");
whismanoid 0:3edb3708c8c5 3908 cmdLine.serial().printf("\r\n 82 code=? -- CODEallLOADall");
whismanoid 0:3edb3708c8c5 3909 //cmdLine.serial().printf("\r\n 83 code=? -- CODEallLOADall");
whismanoid 0:3edb3708c8c5 3910 //
whismanoid 0:3edb3708c8c5 3911 // Menu @ -- print device configuration
whismanoid 0:3edb3708c8c5 3912 cmdLine.serial().printf("\r\n @ -- print MAX5715 configuration");
whismanoid 0:3edb3708c8c5 3913 //
whismanoid 0:3edb3708c8c5 3914 // MAX5717 menu function to drive MAX5717_LDACb_Pin LDAC#
whismanoid 0:3edb3708c8c5 3915 // Note: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 3916 cmdLine.serial().printf("\r\n L -- LDAC# pulse LH high LL low");
whismanoid 0:3edb3708c8c5 3917 // MAX5717 menu function to drive MAX5717_CLRb_Pin CLR#
whismanoid 0:3edb3708c8c5 3918 cmdLine.serial().printf("\r\n C -- CLR# pulse CH high CL low");
whismanoid 0:3edb3708c8c5 3919 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 3920 //
whismanoid 0:3edb3708c8c5 3921 #if APPLICATION_MAX11131 // main_menu_help
whismanoid 0:3edb3708c8c5 3922 // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void);
whismanoid 0:3edb3708c8c5 3923 cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead");
whismanoid 0:3edb3708c8c5 3924 // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 3925 cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual");
whismanoid 0:3edb3708c8c5 3926 // 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 3927 cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat");
whismanoid 0:3edb3708c8c5 3928 // 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 3929 cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock");
whismanoid 0:3edb3708c8c5 3930 // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 3931 cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock");
whismanoid 0:3edb3708c8c5 3932 // 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 3933 cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock");
whismanoid 0:3edb3708c8c5 3934 // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 3935 cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock");
whismanoid 0:3edb3708c8c5 3936 // 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 3937 cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock");
whismanoid 0:3edb3708c8c5 3938 // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 3939 cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock");
whismanoid 0:3edb3708c8c5 3940 // 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 3941 cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock");
whismanoid 0:3edb3708c8c5 3942 cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration");
whismanoid 0:3edb3708c8c5 3943 cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range");
whismanoid 0:3edb3708c8c5 3944 // cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual");
whismanoid 0:3edb3708c8c5 3945 // Note: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 3946 #endif // APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 3947 //
whismanoid 0:3edb3708c8c5 3948 #if APPLICATION_MAX5171 // main_menu_help
whismanoid 0:3edb3708c8c5 3949 // TODO1: MAX5171 main_menu_help
whismanoid 0:3edb3708c8c5 3950 cmdLine.serial().printf("\r\n 0 code=? -- CODE");
whismanoid 0:3edb3708c8c5 3951 cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD");
whismanoid 0:3edb3708c8c5 3952 cmdLine.serial().printf("\r\n 8 -- LOAD");
whismanoid 0:3edb3708c8c5 3953 cmdLine.serial().printf("\r\n c -- NOP");
whismanoid 0:3edb3708c8c5 3954 cmdLine.serial().printf("\r\n d -- SHUTDOWN");
whismanoid 0:3edb3708c8c5 3955 cmdLine.serial().printf("\r\n e0 -- UPO_LOW");
whismanoid 0:3edb3708c8c5 3956 cmdLine.serial().printf("\r\n e8 -- UPO_HIGH");
whismanoid 0:3edb3708c8c5 3957 cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE");
whismanoid 0:3edb3708c8c5 3958 cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE");
whismanoid 0:3edb3708c8c5 3959 // Note: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 3960 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 3961 //
whismanoid 0:3edb3708c8c5 3962 #if APPLICATION_MAX11410 // main_menu_help
whismanoid 0:3edb3708c8c5 3963 // TODO1: MAX11410 main_menu_help
whismanoid 0:3edb3708c8c5 3964 cmdLine.serial().printf("\r\n w reg=? data=? -- write register");
whismanoid 0:3edb3708c8c5 3965 cmdLine.serial().printf("\r\n r reg=? -- read register");
whismanoid 0:3edb3708c8c5 3966 cmdLine.serial().printf("\r\n TC -- thermocouple config");
whismanoid 0:3edb3708c8c5 3967 cmdLine.serial().printf("\r\n T -- RTD measurement");
whismanoid 0:3edb3708c8c5 3968 cmdLine.serial().printf("\r\n RC -- thermocouple config");
whismanoid 0:3edb3708c8c5 3969 cmdLine.serial().printf("\r\n R -- RTD measurement");
whismanoid 0:3edb3708c8c5 3970 // Note: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 3971 #endif // APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 3972 //
whismanoid 0:3edb3708c8c5 3973 #if APPLICATION_MAX12345 // main_menu_help
whismanoid 0:3edb3708c8c5 3974 cmdLine.serial().printf("\r\n 0 -- something");
whismanoid 0:3edb3708c8c5 3975 cmdLine.serial().printf("\r\n 1 -- something");
whismanoid 0:3edb3708c8c5 3976 cmdLine.serial().printf("\r\n 2 -- something");
whismanoid 0:3edb3708c8c5 3977 cmdLine.serial().printf("\r\n A -- something");
whismanoid 0:3edb3708c8c5 3978 cmdLine.serial().printf("\r\n B -- something");
whismanoid 0:3edb3708c8c5 3979 cmdLine.serial().printf("\r\n C -- something");
whismanoid 0:3edb3708c8c5 3980 // Note: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 3981 #endif // APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 3982 //
whismanoid 0:3edb3708c8c5 3983 }
whismanoid 0:3edb3708c8c5 3984
whismanoid 0:3edb3708c8c5 3985 //--------------------------------------------------
whismanoid 10:228a52f8107d 3986 // diagnostic commands submenu
whismanoid 10:228a52f8107d 3987 // invoked by main_menu_onEOLcommandParser case '%'
whismanoid 10:228a52f8107d 3988 void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 3989 {
whismanoid 10:228a52f8107d 3990 // % diagnostic commands submenu
whismanoid 10:228a52f8107d 3991 // %Hpin -- digital output high
whismanoid 10:228a52f8107d 3992 // %Lpin -- digital output low
whismanoid 10:228a52f8107d 3993 // %?pin -- digital input
whismanoid 10:228a52f8107d 3994 // %A %Apin -- analog input
whismanoid 10:228a52f8107d 3995 // %Ppin df=xx -- pwm output
whismanoid 10:228a52f8107d 3996 // %Wpin -- measure high pulsewidth input in usec
whismanoid 10:228a52f8107d 3997 // %wpin -- measure low pulsewidth input in usec
whismanoid 10:228a52f8107d 3998 // %I... -- I2C diagnostics
whismanoid 10:228a52f8107d 3999 // %IP -- I2C probe
whismanoid 10:228a52f8107d 4000 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 10:228a52f8107d 4001 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 10:228a52f8107d 4002 // %IR ADDR=? RD=? -- read
whismanoid 10:228a52f8107d 4003 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 10:228a52f8107d 4004 // %S... -- SPI diagnostics
whismanoid 10:228a52f8107d 4005 // %SC sclk=1Mhz -- SPI configure
whismanoid 10:228a52f8107d 4006 // %SW -- write (write and read)
whismanoid 10:228a52f8107d 4007 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 10:228a52f8107d 4008 // A-Z,a-z,0-9 reserved for application use
whismanoid 10:228a52f8107d 4009 //
whismanoid 10:228a52f8107d 4010 // get pinIndex from cmdLine[2]
whismanoid 10:228a52f8107d 4011 //int pinIndex = cmdLine[2];
whismanoid 10:228a52f8107d 4012 // *** warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
whismanoid 10:228a52f8107d 4013 //int pinIndex = strtoul((char *)((void *)(cmdLine.str()) + 2), NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 10:228a52f8107d 4014 // ^
whismanoid 10:228a52f8107d 4015 char strPinIndex[3];
whismanoid 10:228a52f8107d 4016 strPinIndex[0] = cmdLine[2];
whismanoid 10:228a52f8107d 4017 strPinIndex[1] = cmdLine[3];
whismanoid 10:228a52f8107d 4018 strPinIndex[2] = '\0';
whismanoid 10:228a52f8107d 4019 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 10:228a52f8107d 4020 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 0:3edb3708c8c5 4021 //
whismanoid 10:228a52f8107d 4022 // get next character
whismanoid 10:228a52f8107d 4023 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4024 {
whismanoid 10:228a52f8107d 4025 #if HAS_digitalInOuts
whismanoid 10:228a52f8107d 4026 case 'H': case 'h':
whismanoid 10:228a52f8107d 4027 {
whismanoid 10:228a52f8107d 4028 // %Hpin -- digital output high
whismanoid 10:228a52f8107d 4029 #if ARDUINO_STYLE
whismanoid 10:228a52f8107d 4030 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 10:228a52f8107d 4031 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 10:228a52f8107d 4032 #else
whismanoid 10:228a52f8107d 4033 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 10:228a52f8107d 4034 digitalInOutPin.output();
whismanoid 10:228a52f8107d 4035 digitalInOutPin.write(1);
whismanoid 10:228a52f8107d 4036 #endif
whismanoid 10:228a52f8107d 4037 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 10:228a52f8107d 4038 }
whismanoid 10:228a52f8107d 4039 break;
whismanoid 10:228a52f8107d 4040 case 'L': case 'l':
whismanoid 10:228a52f8107d 4041 {
whismanoid 10:228a52f8107d 4042 // %Lpin -- digital output low
whismanoid 10:228a52f8107d 4043 #if ARDUINO_STYLE
whismanoid 10:228a52f8107d 4044 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 10:228a52f8107d 4045 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 10:228a52f8107d 4046 #else
whismanoid 10:228a52f8107d 4047 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 10:228a52f8107d 4048 digitalInOutPin.output();
whismanoid 10:228a52f8107d 4049 digitalInOutPin.write(0);
whismanoid 10:228a52f8107d 4050 #endif
whismanoid 10:228a52f8107d 4051 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 10:228a52f8107d 4052 }
whismanoid 10:228a52f8107d 4053 break;
whismanoid 0:3edb3708c8c5 4054 case '?':
whismanoid 0:3edb3708c8c5 4055 {
whismanoid 10:228a52f8107d 4056 // %?pin -- digital input
whismanoid 10:228a52f8107d 4057 #if ARDUINO_STYLE
whismanoid 10:228a52f8107d 4058 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 10:228a52f8107d 4059 #else
whismanoid 10:228a52f8107d 4060 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 10:228a52f8107d 4061 digitalInOutPin.input();
whismanoid 10:228a52f8107d 4062 #endif
whismanoid 10:228a52f8107d 4063 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 10:228a52f8107d 4064 #if ARDUINO_STYLE
whismanoid 10:228a52f8107d 4065 int value = digitalRead(pinIndex);
whismanoid 10:228a52f8107d 4066 #else
whismanoid 10:228a52f8107d 4067 int value = digitalInOutPin.read();
whismanoid 10:228a52f8107d 4068 #endif
whismanoid 10:228a52f8107d 4069 cmdLine.serial().printf("%d ", value);
whismanoid 0:3edb3708c8c5 4070 }
whismanoid 0:3edb3708c8c5 4071 break;
whismanoid 10:228a52f8107d 4072 #endif
whismanoid 10:228a52f8107d 4073 //
whismanoid 10:228a52f8107d 4074 #if HAS_analogIns
whismanoid 10:228a52f8107d 4075 case 'A': case 'a':
whismanoid 0:3edb3708c8c5 4076 {
whismanoid 0:3edb3708c8c5 4077 // %A %Apin -- analog input
whismanoid 10:228a52f8107d 4078 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 10:228a52f8107d 4079 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 10:228a52f8107d 4080 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 10:228a52f8107d 4081 {
whismanoid 10:228a52f8107d 4082 int cPinIndex = '0' + pinIndex;
whismanoid 10:228a52f8107d 4083 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 10:228a52f8107d 4084 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 10:228a52f8107d 4085 float normValue_0_1 = analogInPin.read();
whismanoid 10:228a52f8107d 4086 //
whismanoid 10:228a52f8107d 4087 int pinIndexH = pinIndex + 4;
whismanoid 10:228a52f8107d 4088 int cPinIndexH = '0' + pinIndexH;
whismanoid 10:228a52f8107d 4089 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 10:228a52f8107d 4090 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 10:228a52f8107d 4091 float normValueH_0_1 = analogInPinH.read();
whismanoid 10:228a52f8107d 4092 //
whismanoid 10:228a52f8107d 4093 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV \r\n",
whismanoid 10:228a52f8107d 4094 cPinIndex,
whismanoid 10:228a52f8107d 4095 normValue_0_1 * 100.0,
whismanoid 10:228a52f8107d 4096 normValue_0_1 * adc_full_scale_voltage,
whismanoid 10:228a52f8107d 4097 cPinIndexH,
whismanoid 10:228a52f8107d 4098 normValueH_0_1 * 100.0,
whismanoid 10:228a52f8107d 4099 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 10:228a52f8107d 4100 );
whismanoid 10:228a52f8107d 4101 }
whismanoid 10:228a52f8107d 4102 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 10:228a52f8107d 4103 {
whismanoid 10:228a52f8107d 4104 int cPinIndex = '0' + pinIndex;
whismanoid 10:228a52f8107d 4105 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 10:228a52f8107d 4106 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 10:228a52f8107d 4107 float normValue_0_1 = analogInPin.read();
whismanoid 10:228a52f8107d 4108 //
whismanoid 10:228a52f8107d 4109 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 10:228a52f8107d 4110 cPinIndex,
whismanoid 10:228a52f8107d 4111 normValue_0_1 * 100.0,
whismanoid 10:228a52f8107d 4112 normValue_0_1 * adc_full_scale_voltage
whismanoid 10:228a52f8107d 4113 );
whismanoid 10:228a52f8107d 4114 }
whismanoid 10:228a52f8107d 4115 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 10:228a52f8107d 4116 // Platform board uses simple analog inputs
whismanoid 10:228a52f8107d 4117 // assume standard Arduino analog inputs A0-A5
whismanoid 10:228a52f8107d 4118 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 10:228a52f8107d 4119 {
whismanoid 10:228a52f8107d 4120 int cPinIndex = '0' + pinIndex;
whismanoid 10:228a52f8107d 4121 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 10:228a52f8107d 4122 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 10:228a52f8107d 4123 float normValue_0_1 = analogInPin.read();
whismanoid 10:228a52f8107d 4124 //
whismanoid 10:228a52f8107d 4125 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 10:228a52f8107d 4126 cPinIndex,
whismanoid 10:228a52f8107d 4127 normValue_0_1 * 100.0,
whismanoid 10:228a52f8107d 4128 normValue_0_1 * adc_full_scale_voltage
whismanoid 10:228a52f8107d 4129 );
whismanoid 10:228a52f8107d 4130 }
whismanoid 10:228a52f8107d 4131 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 10:228a52f8107d 4132 }
whismanoid 10:228a52f8107d 4133 break;
whismanoid 10:228a52f8107d 4134 #endif
whismanoid 10:228a52f8107d 4135 //
whismanoid 10:228a52f8107d 4136 #if HAS_SPI2_MAX541
whismanoid 10:228a52f8107d 4137 case 'D': case 'd':
whismanoid 10:228a52f8107d 4138 {
whismanoid 10:228a52f8107d 4139 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 10:228a52f8107d 4140 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 10:228a52f8107d 4141 float voltageV = max541.Get_Voltage();
whismanoid 10:228a52f8107d 4142 // if (cmdLine[2] == '+') {
whismanoid 10:228a52f8107d 4143 // // %D+
whismanoid 10:228a52f8107d 4144 // voltageV = voltageV * 1.25f;
whismanoid 10:228a52f8107d 4145 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 10:228a52f8107d 4146 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 10:228a52f8107d 4147 // }
whismanoid 10:228a52f8107d 4148 // else if (cmdLine[2] == '-') {
whismanoid 10:228a52f8107d 4149 // // %D-
whismanoid 10:228a52f8107d 4150 // voltageV = voltageV * 0.75f;
whismanoid 10:228a52f8107d 4151 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 10:228a52f8107d 4152 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 10:228a52f8107d 4153 // }
whismanoid 10:228a52f8107d 4154 if (cmdLine.parse_float("V", voltageV))
whismanoid 10:228a52f8107d 4155 {
whismanoid 10:228a52f8107d 4156 // %D V=1.234 -- set voltage
whismanoid 10:228a52f8107d 4157 max541.Set_Voltage(voltageV);
whismanoid 10:228a52f8107d 4158 }
whismanoid 10:228a52f8107d 4159 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 10:228a52f8107d 4160 {
whismanoid 10:228a52f8107d 4161 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 10:228a52f8107d 4162 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 10:228a52f8107d 4163 }
whismanoid 10:228a52f8107d 4164 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 10:228a52f8107d 4165 {
whismanoid 10:228a52f8107d 4166 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 10:228a52f8107d 4167
whismanoid 10:228a52f8107d 4168 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 10:228a52f8107d 4169 double max541_midscale_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 10:228a52f8107d 4170 const int average_count = 100;
whismanoid 10:228a52f8107d 4171 const double average_K = 0.25;
whismanoid 10:228a52f8107d 4172 for (int count = 0; count < average_count; count++) {
whismanoid 10:228a52f8107d 4173 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 10:228a52f8107d 4174 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 10:228a52f8107d 4175 }
whismanoid 10:228a52f8107d 4176 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 10:228a52f8107d 4177 cmdLine.serial().printf(
whismanoid 10:228a52f8107d 4178 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 10:228a52f8107d 4179 max541_midscale_V, max541.VRef);
whismanoid 10:228a52f8107d 4180 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 10:228a52f8107d 4181 voltageV = 1.0f;
whismanoid 10:228a52f8107d 4182 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 10:228a52f8107d 4183 }
whismanoid 10:228a52f8107d 4184 else {
whismanoid 10:228a52f8107d 4185 // %D -- print MAX541 DAC status
whismanoid 10:228a52f8107d 4186 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 10:228a52f8107d 4187 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 10:228a52f8107d 4188 }
whismanoid 10:228a52f8107d 4189 }
whismanoid 10:228a52f8107d 4190 break;
whismanoid 10:228a52f8107d 4191 #endif
whismanoid 10:228a52f8107d 4192
whismanoid 10:228a52f8107d 4193 //
whismanoid 10:228a52f8107d 4194 #if HAS_I2C // SUPPORT_I2C
whismanoid 10:228a52f8107d 4195 case 'I': case 'i':
whismanoid 0:3edb3708c8c5 4196 // %I... -- I2C diagnostics
whismanoid 0:3edb3708c8c5 4197 // %IP -- I2C probe
whismanoid 0:3edb3708c8c5 4198 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 0:3edb3708c8c5 4199 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 0:3edb3708c8c5 4200 // %IR ADDR=? RD=? -- read
whismanoid 0:3edb3708c8c5 4201 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 10:228a52f8107d 4202 // get next character
whismanoid 10:228a52f8107d 4203 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 10:228a52f8107d 4204 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 10:228a52f8107d 4205 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 10:228a52f8107d 4206 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 10:228a52f8107d 4207 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 10:228a52f8107d 4208 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 10:228a52f8107d 4209 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 10:228a52f8107d 4210 switch (cmdLine[2])
whismanoid 10:228a52f8107d 4211 {
whismanoid 10:228a52f8107d 4212 case 'P': case 'p':
whismanoid 10:228a52f8107d 4213 {
whismanoid 10:228a52f8107d 4214 // %IP -- I2C probe
whismanoid 10:228a52f8107d 4215 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 10:228a52f8107d 4216 }
whismanoid 10:228a52f8107d 4217 break;
whismanoid 10:228a52f8107d 4218 case 'C': case 'c':
whismanoid 10:228a52f8107d 4219 {
whismanoid 10:228a52f8107d 4220 bool isUpdatedI2CConfig = false;
whismanoid 10:228a52f8107d 4221 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 10:228a52f8107d 4222 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 10:228a52f8107d 4223 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 10:228a52f8107d 4224 {
whismanoid 10:228a52f8107d 4225 isUpdatedI2CConfig = true;
whismanoid 10:228a52f8107d 4226 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 10:228a52f8107d 4227 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 10:228a52f8107d 4228 {
whismanoid 10:228a52f8107d 4229 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 10:228a52f8107d 4230 }
whismanoid 10:228a52f8107d 4231 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 10:228a52f8107d 4232 {
whismanoid 10:228a52f8107d 4233 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 10:228a52f8107d 4234 }
whismanoid 10:228a52f8107d 4235 }
whismanoid 10:228a52f8107d 4236 if (isUpdatedI2CConfig)
whismanoid 10:228a52f8107d 4237 {
whismanoid 10:228a52f8107d 4238 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 10:228a52f8107d 4239 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 10:228a52f8107d 4240 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 10:228a52f8107d 4241 i2cMaster.start();
whismanoid 10:228a52f8107d 4242 i2cMaster.stop();
whismanoid 10:228a52f8107d 4243 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 10:228a52f8107d 4244 cmdLine.serial().printf(
whismanoid 10:228a52f8107d 4245 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 10:228a52f8107d 4246 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 10:228a52f8107d 4247 (g_I2C_SCL_Hz / 1000.));
whismanoid 10:228a52f8107d 4248 i2cMaster.start();
whismanoid 10:228a52f8107d 4249 i2cMaster.stop();
whismanoid 10:228a52f8107d 4250 }
whismanoid 10:228a52f8107d 4251 }
whismanoid 10:228a52f8107d 4252 break;
whismanoid 10:228a52f8107d 4253 case 'W': case 'w':
whismanoid 10:228a52f8107d 4254 {
whismanoid 10:228a52f8107d 4255 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 10:228a52f8107d 4256 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 10:228a52f8107d 4257 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 10:228a52f8107d 4258 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 10:228a52f8107d 4259 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 10:228a52f8107d 4260 #define MAX_I2C_BYTE_COUNT 32
whismanoid 10:228a52f8107d 4261 size_t byteCount = byteCount;
whismanoid 10:228a52f8107d 4262 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 10:228a52f8107d 4263 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 10:228a52f8107d 4264 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 10:228a52f8107d 4265 MAX_I2C_BYTE_COUNT))
whismanoid 10:228a52f8107d 4266 {
whismanoid 10:228a52f8107d 4267 // hex dump mosiData[0..byteCount-1]
whismanoid 10:228a52f8107d 4268 cmdLine.serial().printf(
whismanoid 10:228a52f8107d 4269 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 10:228a52f8107d 4270 g_I2C_deviceAddress7,
whismanoid 10:228a52f8107d 4271 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 10:228a52f8107d 4272 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 10:228a52f8107d 4273 {
whismanoid 10:228a52f8107d 4274 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 10:228a52f8107d 4275 }
whismanoid 10:228a52f8107d 4276 //
whismanoid 10:228a52f8107d 4277 // TODO: i2c transfer
whismanoid 10:228a52f8107d 4278 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 10:228a52f8107d 4279 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 10:228a52f8107d 4280 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 10:228a52f8107d 4281 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 10:228a52f8107d 4282 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 10:228a52f8107d 4283 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 10:228a52f8107d 4284 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 10:228a52f8107d 4285 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 10:228a52f8107d 4286 // /* 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 10:228a52f8107d 4287 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 10:228a52f8107d 4288 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 10:228a52f8107d 4289 unsigned int misoLength = 0;
whismanoid 10:228a52f8107d 4290 bool repeated = (g_I2C_read_count > 0);
whismanoid 10:228a52f8107d 4291 //
whismanoid 10:228a52f8107d 4292 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 10:228a52f8107d 4293 switch (writeStatus)
whismanoid 10:228a52f8107d 4294 {
whismanoid 10:228a52f8107d 4295 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 10:228a52f8107d 4296 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 10:228a52f8107d 4297 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 10:228a52f8107d 4298 writeStatus);
whismanoid 10:228a52f8107d 4299 }
whismanoid 10:228a52f8107d 4300 if (repeated)
whismanoid 10:228a52f8107d 4301 {
whismanoid 10:228a52f8107d 4302 int readStatus =
whismanoid 10:228a52f8107d 4303 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 10:228a52f8107d 4304 switch (readStatus)
whismanoid 10:228a52f8107d 4305 {
whismanoid 10:228a52f8107d 4306 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 10:228a52f8107d 4307 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 10:228a52f8107d 4308 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 10:228a52f8107d 4309 readStatus);
whismanoid 10:228a52f8107d 4310 }
whismanoid 10:228a52f8107d 4311 }
whismanoid 10:228a52f8107d 4312 //
whismanoid 10:228a52f8107d 4313 if (misoLength > 0)
whismanoid 10:228a52f8107d 4314 {
whismanoid 10:228a52f8107d 4315 // hex dump misoData[0..byteCount-1]
whismanoid 10:228a52f8107d 4316 cmdLine.serial().printf(" MISO<-");
whismanoid 10:228a52f8107d 4317 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 10:228a52f8107d 4318 byteIndex++)
whismanoid 10:228a52f8107d 4319 {
whismanoid 10:228a52f8107d 4320 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 10:228a52f8107d 4321 }
whismanoid 10:228a52f8107d 4322 }
whismanoid 10:228a52f8107d 4323 cmdLine.serial().printf(" ");
whismanoid 10:228a52f8107d 4324 }
whismanoid 10:228a52f8107d 4325 }
whismanoid 10:228a52f8107d 4326 break;
whismanoid 10:228a52f8107d 4327 case 'R': case 'r':
whismanoid 10:228a52f8107d 4328 {
whismanoid 10:228a52f8107d 4329 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 10:228a52f8107d 4330 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 10:228a52f8107d 4331 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 10:228a52f8107d 4332 // %IR ADDR=? RD=? -- read
whismanoid 10:228a52f8107d 4333 // TODO: i2c transfer
whismanoid 10:228a52f8107d 4334 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 10:228a52f8107d 4335 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 10:228a52f8107d 4336 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 10:228a52f8107d 4337 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 10:228a52f8107d 4338 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 10:228a52f8107d 4339 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 10:228a52f8107d 4340 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 10:228a52f8107d 4341 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 10:228a52f8107d 4342 // /* 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 10:228a52f8107d 4343 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 10:228a52f8107d 4344 }
whismanoid 10:228a52f8107d 4345 break;
whismanoid 10:228a52f8107d 4346 case '^':
whismanoid 10:228a52f8107d 4347 {
whismanoid 10:228a52f8107d 4348 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 10:228a52f8107d 4349 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 10:228a52f8107d 4350 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 10:228a52f8107d 4351 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 10:228a52f8107d 4352 // TODO: i2c transfer
whismanoid 10:228a52f8107d 4353 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 10:228a52f8107d 4354 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 10:228a52f8107d 4355 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 10:228a52f8107d 4356 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 10:228a52f8107d 4357 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 10:228a52f8107d 4358 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 10:228a52f8107d 4359 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 10:228a52f8107d 4360 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 10:228a52f8107d 4361 // /* 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 10:228a52f8107d 4362 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 10:228a52f8107d 4363 }
whismanoid 10:228a52f8107d 4364 break;
whismanoid 10:228a52f8107d 4365 } // switch(cmdLine[2])
whismanoid 10:228a52f8107d 4366 break;
whismanoid 10:228a52f8107d 4367 #endif
whismanoid 10:228a52f8107d 4368 //
whismanoid 10:228a52f8107d 4369 #if HAS_SPI // SUPPORT_SPI
whismanoid 10:228a52f8107d 4370 case 'S': case 's':
whismanoid 10:228a52f8107d 4371 {
whismanoid 0:3edb3708c8c5 4372 // %S... -- SPI diagnostics
whismanoid 0:3edb3708c8c5 4373 // %SC sclk=1Mhz -- SPI configure
whismanoid 0:3edb3708c8c5 4374 // %SW -- write (write and read)
whismanoid 0:3edb3708c8c5 4375 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 0:3edb3708c8c5 4376 //
whismanoid 10:228a52f8107d 4377 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 10:228a52f8107d 4378 bool isUpdatedSPIConfig = false;
whismanoid 10:228a52f8107d 4379 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 10:228a52f8107d 4380 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 10:228a52f8107d 4381 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 10:228a52f8107d 4382 {
whismanoid 10:228a52f8107d 4383 isUpdatedSPIConfig = true;
whismanoid 10:228a52f8107d 4384 }
whismanoid 10:228a52f8107d 4385 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 0:3edb3708c8c5 4386 {
whismanoid 10:228a52f8107d 4387 isUpdatedSPIConfig = true;
whismanoid 10:228a52f8107d 4388 }
whismanoid 10:228a52f8107d 4389 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 10:228a52f8107d 4390 {
whismanoid 10:228a52f8107d 4391 isUpdatedSPIConfig = true;
whismanoid 10:228a52f8107d 4392 }
whismanoid 10:228a52f8107d 4393 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 10:228a52f8107d 4394 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 10:228a52f8107d 4395 {
whismanoid 10:228a52f8107d 4396 isUpdatedSPIConfig = true;
whismanoid 10:228a52f8107d 4397 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 10:228a52f8107d 4398 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 0:3edb3708c8c5 4399 {
whismanoid 10:228a52f8107d 4400 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 0:3edb3708c8c5 4401 }
whismanoid 10:228a52f8107d 4402 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 0:3edb3708c8c5 4403 {
whismanoid 10:228a52f8107d 4404 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 10:228a52f8107d 4405 }
whismanoid 10:228a52f8107d 4406 }
whismanoid 10:228a52f8107d 4407 // Update SPI configuration
whismanoid 10:228a52f8107d 4408 if (isUpdatedSPIConfig)
whismanoid 10:228a52f8107d 4409 {
whismanoid 10:228a52f8107d 4410 // %SC sclk=1Mhz -- SPI configure
whismanoid 10:228a52f8107d 4411 spi_cs = g_SPI_cs_state;
whismanoid 10:228a52f8107d 4412 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 10:228a52f8107d 4413 #if APPLICATION_MAX5715
whismanoid 10:228a52f8107d 4414 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 10:228a52f8107d 4415 #elif APPLICATION_MAX11131
whismanoid 10:228a52f8107d 4416 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 10:228a52f8107d 4417 #elif APPLICATION_MAX5171
whismanoid 10:228a52f8107d 4418 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 10:228a52f8107d 4419 #elif APPLICATION_MAX11410
whismanoid 10:228a52f8107d 4420 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 10:228a52f8107d 4421 #elif APPLICATION_MAX12345
whismanoid 10:228a52f8107d 4422 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 0:3edb3708c8c5 4423 #else
whismanoid 10:228a52f8107d 4424 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 0:3edb3708c8c5 4425 #endif
whismanoid 0:3edb3708c8c5 4426 //
whismanoid 10:228a52f8107d 4427 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 10:228a52f8107d 4428 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 10:228a52f8107d 4429 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 10:228a52f8107d 4430 //
whismanoid 10:228a52f8107d 4431 // 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 10:228a52f8107d 4432 cmdLine.serial().printf(
whismanoid 10:228a52f8107d 4433 "\r\n %%SC CPOL=%d CPHA=%d CS=%d SCLK=%ld=%1.3fMHz (%1.1fMHz/%1.2f = actual %1.3fMHz) -- SPI config",
whismanoid 10:228a52f8107d 4434 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 10:228a52f8107d 4435 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 10:228a52f8107d 4436 g_SPI_cs_state,
whismanoid 10:228a52f8107d 4437 g_SPI_SCLK_Hz,
whismanoid 10:228a52f8107d 4438 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 10:228a52f8107d 4439 ((double)(SystemCoreClock / 1000000.)),
whismanoid 10:228a52f8107d 4440 ideal_divisor,
whismanoid 10:228a52f8107d 4441 (actual_SCLK_Hz / 1000000.)
whismanoid 10:228a52f8107d 4442 );
whismanoid 10:228a52f8107d 4443 }
whismanoid 10:228a52f8107d 4444 // get next character
whismanoid 10:228a52f8107d 4445 switch (cmdLine[2])
whismanoid 10:228a52f8107d 4446 {
whismanoid 10:228a52f8107d 4447 case 'C': case 's':
whismanoid 10:228a52f8107d 4448 // %SC sclk=1Mhz -- SPI configure
whismanoid 10:228a52f8107d 4449 break;
whismanoid 10:228a52f8107d 4450 case 'W': case 'R': case 'w': case 'r':
whismanoid 0:3edb3708c8c5 4451 {
whismanoid 10:228a52f8107d 4452 // %SW -- write (write and read)
whismanoid 10:228a52f8107d 4453 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 10:228a52f8107d 4454 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 10:228a52f8107d 4455 #define MAX_SPI_BYTE_COUNT 32
whismanoid 10:228a52f8107d 4456 size_t byteCount = byteCount;
whismanoid 10:228a52f8107d 4457 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 10:228a52f8107d 4458 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 10:228a52f8107d 4459 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 10:228a52f8107d 4460 MAX_SPI_BYTE_COUNT))
whismanoid 0:3edb3708c8c5 4461 {
whismanoid 10:228a52f8107d 4462 // hex dump mosiData[0..byteCount-1]
whismanoid 10:228a52f8107d 4463 cmdLine.serial().printf("\r\nSPI");
whismanoid 10:228a52f8107d 4464 if (byteCount > 7) {
whismanoid 10:228a52f8107d 4465 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 10:228a52f8107d 4466 }
whismanoid 10:228a52f8107d 4467 cmdLine.serial().printf(" MOSI->");
whismanoid 10:228a52f8107d 4468 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 10:228a52f8107d 4469 {
whismanoid 10:228a52f8107d 4470 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 0:3edb3708c8c5 4471 }
whismanoid 10:228a52f8107d 4472 spi_cs = 0;
whismanoid 10:228a52f8107d 4473 unsigned int numBytesTransferred =
whismanoid 10:228a52f8107d 4474 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 10:228a52f8107d 4475 spi_cs = 1;
whismanoid 10:228a52f8107d 4476 // hex dump misoData[0..byteCount-1]
whismanoid 10:228a52f8107d 4477 cmdLine.serial().printf(" MISO<-");
whismanoid 10:228a52f8107d 4478 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 10:228a52f8107d 4479 byteIndex++)
whismanoid 10:228a52f8107d 4480 {
whismanoid 10:228a52f8107d 4481 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 10:228a52f8107d 4482 }
whismanoid 10:228a52f8107d 4483 cmdLine.serial().printf(" ");
whismanoid 0:3edb3708c8c5 4484 }
whismanoid 0:3edb3708c8c5 4485 }
whismanoid 0:3edb3708c8c5 4486 break;
whismanoid 10:228a52f8107d 4487 } // switch(cmdLine[2])
whismanoid 10:228a52f8107d 4488 } // case 'S': // %S... -- SPI diagnostics
whismanoid 10:228a52f8107d 4489 break;
whismanoid 10:228a52f8107d 4490 #endif
whismanoid 10:228a52f8107d 4491 //
whismanoid 10:228a52f8107d 4492 // A-Z,a-z,0-9 reserved for application use
whismanoid 10:228a52f8107d 4493 } // switch(cmdLine[1])
whismanoid 10:228a52f8107d 4494 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 4495
whismanoid 0:3edb3708c8c5 4496
whismanoid 10:228a52f8107d 4497 //--------------------------------------------------
whismanoid 10:228a52f8107d 4498 #if 0 // APPLICATION_MAX5715 // MAX5715_menu_onEOLcommandParser moved to Test_Menu_MAX5715.cpp
whismanoid 10:228a52f8107d 4499 bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 4500 {
whismanoid 10:228a52f8107d 4501 switch (cmdLine[0])
whismanoid 10:228a52f8107d 4502 {
whismanoid 0:3edb3708c8c5 4503 case '0':
whismanoid 0:3edb3708c8c5 4504 {
whismanoid 0:3edb3708c8c5 4505 // recommended for hex command codes 00..0F
whismanoid 0:3edb3708c8c5 4506 // TODO: cmdLine.serial().printf("\r\n 0 ch=? code=? -- CODEn");
whismanoid 0:3edb3708c8c5 4507 // Menu 0 ch=? code=?) CODEn
whismanoid 0:3edb3708c8c5 4508 // MAX5715_CODEn(uint8_t channel, uint16_t dacCodeLsbs);
whismanoid 0:3edb3708c8c5 4509 // VERIFY: parse strCommandArgs for additional arguments including key=value pairs
whismanoid 0:3edb3708c8c5 4510 // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 4511 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 4512 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 4513 {
whismanoid 0:3edb3708c8c5 4514 }
whismanoid 0:3edb3708c8c5 4515 uint16_t code = g_MAX5715_device.CODE[ch];
whismanoid 0:3edb3708c8c5 4516 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 4517 {
whismanoid 0:3edb3708c8c5 4518 }
whismanoid 0:3edb3708c8c5 4519 cmdLine.serial().printf("CODEn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 4520 g_MAX5715_device.CODEn(ch, code);
whismanoid 10:228a52f8107d 4521 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4522 }
whismanoid 0:3edb3708c8c5 4523 break;
whismanoid 0:3edb3708c8c5 4524 case '1':
whismanoid 0:3edb3708c8c5 4525 {
whismanoid 0:3edb3708c8c5 4526 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 4527 // TODO: cmdLine.serial().printf("\r\n 1 ch=? -- LOADn");
whismanoid 0:3edb3708c8c5 4528 // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 4529 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 4530 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 4531 {
whismanoid 0:3edb3708c8c5 4532 }
whismanoid 0:3edb3708c8c5 4533 cmdLine.serial().printf("LOADn ch=%d", ch);
whismanoid 0:3edb3708c8c5 4534 g_MAX5715_device.LOADn(ch);
whismanoid 10:228a52f8107d 4535 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4536 }
whismanoid 0:3edb3708c8c5 4537 break;
whismanoid 0:3edb3708c8c5 4538 case '2':
whismanoid 0:3edb3708c8c5 4539 {
whismanoid 0:3edb3708c8c5 4540 // recommended for hex command codes 20..2F
whismanoid 0:3edb3708c8c5 4541 // TODO: cmdLine.serial().printf("\r\n 2 ch=? code=? -- CODEnLOADall");
whismanoid 0:3edb3708c8c5 4542 // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 4543 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 4544 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 4545 {
whismanoid 0:3edb3708c8c5 4546 }
whismanoid 0:3edb3708c8c5 4547 uint16_t code = g_MAX5715_device.CODE[ch];
whismanoid 0:3edb3708c8c5 4548 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 4549 {
whismanoid 0:3edb3708c8c5 4550 }
whismanoid 0:3edb3708c8c5 4551 cmdLine.serial().printf("CODEnLOADall ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 4552 g_MAX5715_device.CODEnLOADall(ch, code);
whismanoid 10:228a52f8107d 4553 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4554 }
whismanoid 0:3edb3708c8c5 4555 break;
whismanoid 0:3edb3708c8c5 4556 case '3':
whismanoid 0:3edb3708c8c5 4557 {
whismanoid 0:3edb3708c8c5 4558 // recommended for hex command codes 30..3F
whismanoid 0:3edb3708c8c5 4559 // TODO: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn");
whismanoid 0:3edb3708c8c5 4560 // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 4561 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 4562 uint16_t code;
whismanoid 0:3edb3708c8c5 4563 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 4564 {
whismanoid 0:3edb3708c8c5 4565 }
whismanoid 0:3edb3708c8c5 4566 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 4567 {
whismanoid 0:3edb3708c8c5 4568 }
whismanoid 0:3edb3708c8c5 4569 cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 4570 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 10:228a52f8107d 4571 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4572 }
whismanoid 0:3edb3708c8c5 4573 break;
whismanoid 0:3edb3708c8c5 4574 case '4':
whismanoid 0:3edb3708c8c5 4575 {
whismanoid 0:3edb3708c8c5 4576 // recommended for hex command codes 40..4F
whismanoid 0:3edb3708c8c5 4577 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4578 {
whismanoid 0:3edb3708c8c5 4579 case '0':
whismanoid 0:3edb3708c8c5 4580 {
whismanoid 0:3edb3708c8c5 4581 // cmdLine.serial().printf("\r\n 40 ch=? -- POWERn_Normal");
whismanoid 0:3edb3708c8c5 4582 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4583 "channel_dcba=%d, POWERn_Normal)",
whismanoid 0:3edb3708c8c5 4584 g_MAX5715_device.channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4585 g_MAX5715_device.POWER(g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4586 channels_bitmask_DCBA,
whismanoid 0:3edb3708c8c5 4587 MAX5715::POWERn_Normal);
whismanoid 10:228a52f8107d 4588 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4589 }
whismanoid 0:3edb3708c8c5 4590 break;
whismanoid 0:3edb3708c8c5 4591 case '1':
whismanoid 0:3edb3708c8c5 4592 {
whismanoid 0:3edb3708c8c5 4593 // cmdLine.serial().printf("\r\n 41 ch=? -- POWERn_PD1k");
whismanoid 0:3edb3708c8c5 4594 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4595 "channel_dcba=%d, POWERn_PD1k)",
whismanoid 0:3edb3708c8c5 4596 g_MAX5715_device.channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4597 g_MAX5715_device.POWER(g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4598 channels_bitmask_DCBA,
whismanoid 0:3edb3708c8c5 4599 MAX5715::POWERn_PD1k);
whismanoid 10:228a52f8107d 4600 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4601 }
whismanoid 0:3edb3708c8c5 4602 break;
whismanoid 0:3edb3708c8c5 4603 case '2':
whismanoid 0:3edb3708c8c5 4604 {
whismanoid 0:3edb3708c8c5 4605 // cmdLine.serial().printf("\r\n 42 ch=? -- POWERn_PD100k");
whismanoid 0:3edb3708c8c5 4606 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4607 "channel_dcba=%d, POWERn_PD100k)",
whismanoid 0:3edb3708c8c5 4608 g_MAX5715_device.channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4609 g_MAX5715_device.POWER(g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4610 channels_bitmask_DCBA,
whismanoid 0:3edb3708c8c5 4611 MAX5715::POWERn_PD100k);
whismanoid 10:228a52f8107d 4612 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4613 }
whismanoid 0:3edb3708c8c5 4614 break;
whismanoid 0:3edb3708c8c5 4615 case '3':
whismanoid 0:3edb3708c8c5 4616 {
whismanoid 0:3edb3708c8c5 4617 // cmdLine.serial().printf("\r\n 43 ch=? -- POWERn_PDHiZ");
whismanoid 0:3edb3708c8c5 4618 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4619 "channel_dcba=%d, POWERn_PDHiZ)",
whismanoid 0:3edb3708c8c5 4620 g_MAX5715_device.channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4621 g_MAX5715_device.POWER(g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4622 channels_bitmask_DCBA,
whismanoid 0:3edb3708c8c5 4623 MAX5715::POWERn_PDHiZ);
whismanoid 10:228a52f8107d 4624 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4625 }
whismanoid 0:3edb3708c8c5 4626 break;
whismanoid 0:3edb3708c8c5 4627 }
whismanoid 0:3edb3708c8c5 4628 break;
whismanoid 0:3edb3708c8c5 4629 }
whismanoid 0:3edb3708c8c5 4630 break;
whismanoid 0:3edb3708c8c5 4631 case '5':
whismanoid 0:3edb3708c8c5 4632 {
whismanoid 0:3edb3708c8c5 4633 // recommended for hex command codes 50..5F
whismanoid 0:3edb3708c8c5 4634 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4635 {
whismanoid 0:3edb3708c8c5 4636 case '0':
whismanoid 0:3edb3708c8c5 4637 {
whismanoid 0:3edb3708c8c5 4638 // cmdLine.serial().printf("\r\n 50 -- SW_CLEAR");
whismanoid 0:3edb3708c8c5 4639 cmdLine.serial().printf("SW_CLEAR");
whismanoid 0:3edb3708c8c5 4640 g_MAX5715_device.SW_CLEAR();
whismanoid 10:228a52f8107d 4641 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4642 }
whismanoid 0:3edb3708c8c5 4643 break;
whismanoid 0:3edb3708c8c5 4644 case '1':
whismanoid 0:3edb3708c8c5 4645 {
whismanoid 0:3edb3708c8c5 4646 // cmdLine.serial().printf("\r\n 51 -- SW_RESET");
whismanoid 0:3edb3708c8c5 4647 cmdLine.serial().printf("SW_RESET");
whismanoid 0:3edb3708c8c5 4648 g_MAX5715_device.SW_RESET();
whismanoid 10:228a52f8107d 4649 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4650 }
whismanoid 0:3edb3708c8c5 4651 break;
whismanoid 0:3edb3708c8c5 4652 }
whismanoid 0:3edb3708c8c5 4653 }
whismanoid 0:3edb3708c8c5 4654 break;
whismanoid 0:3edb3708c8c5 4655 case '6':
whismanoid 0:3edb3708c8c5 4656 {
whismanoid 0:3edb3708c8c5 4657 // recommended for hex command codes 60..6F
whismanoid 0:3edb3708c8c5 4658 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4659 {
whismanoid 0:3edb3708c8c5 4660 case '0':
whismanoid 0:3edb3708c8c5 4661 {
whismanoid 0:3edb3708c8c5 4662 // cmdLine.serial().printf("\r\n 60 ch=? -- CONFIGn_LATCHED");
whismanoid 0:3edb3708c8c5 4663 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4664 "MAX5715_CONFIGn_LATCHED(channel_dcba=%d)",
whismanoid 0:3edb3708c8c5 4665 g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4666 channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4667 g_MAX5715_device.CONFIGn_LATCHED(g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4668 channels_bitmask_DCBA);
whismanoid 10:228a52f8107d 4669 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4670 }
whismanoid 0:3edb3708c8c5 4671 break;
whismanoid 0:3edb3708c8c5 4672 case '1':
whismanoid 0:3edb3708c8c5 4673 {
whismanoid 0:3edb3708c8c5 4674 // cmdLine.serial().printf("\r\n 61 ch=? -- CONFIGn_TRANSPARENT");
whismanoid 0:3edb3708c8c5 4675 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4676 "MAX5715_CONFIGn_TRANSPARENT(channel_dcba=%d)",
whismanoid 0:3edb3708c8c5 4677 g_MAX5715_device.
whismanoid 0:3edb3708c8c5 4678 channels_bitmask_DCBA);
whismanoid 0:3edb3708c8c5 4679 g_MAX5715_device.CONFIGn_TRANSPARENT(
whismanoid 0:3edb3708c8c5 4680 g_MAX5715_device.channels_bitmask_DCBA);
whismanoid 10:228a52f8107d 4681 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4682 }
whismanoid 0:3edb3708c8c5 4683 break;
whismanoid 0:3edb3708c8c5 4684 case '8':
whismanoid 0:3edb3708c8c5 4685 {
whismanoid 0:3edb3708c8c5 4686 // cmdLine.serial().printf("\r\n 68 -- CONFIGall_LATCHED");
whismanoid 0:3edb3708c8c5 4687 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4688 "MAX5715_CONFIGall_LATCHED()");
whismanoid 0:3edb3708c8c5 4689 g_MAX5715_device.CONFIGall_LATCHED();
whismanoid 10:228a52f8107d 4690 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4691 }
whismanoid 0:3edb3708c8c5 4692 break;
whismanoid 0:3edb3708c8c5 4693 case '9':
whismanoid 0:3edb3708c8c5 4694 {
whismanoid 0:3edb3708c8c5 4695 // cmdLine.serial().printf("\r\n 69 -- CONFIGall_TRANSPARENT");
whismanoid 0:3edb3708c8c5 4696 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4697 "MAX5715_CONFIGall_TRANSPARENT()");
whismanoid 0:3edb3708c8c5 4698 g_MAX5715_device.CONFIGall_TRANSPARENT();
whismanoid 10:228a52f8107d 4699 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4700 }
whismanoid 0:3edb3708c8c5 4701 break;
whismanoid 0:3edb3708c8c5 4702 }
whismanoid 0:3edb3708c8c5 4703 }
whismanoid 0:3edb3708c8c5 4704 break;
whismanoid 0:3edb3708c8c5 4705 case '7':
whismanoid 0:3edb3708c8c5 4706 {
whismanoid 0:3edb3708c8c5 4707 // recommended for hex command codes 70..7F
whismanoid 0:3edb3708c8c5 4708 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4709 {
whismanoid 0:3edb3708c8c5 4710 case '0':
whismanoid 0:3edb3708c8c5 4711 {
whismanoid 0:3edb3708c8c5 4712 // cmdLine.serial().printf("\r\n 70 -- REF_EXT");
whismanoid 0:3edb3708c8c5 4713 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4714 "MAX5715_REF(REF_EXT)");
whismanoid 0:3edb3708c8c5 4715 g_MAX5715_device.REF(MAX5715::REF_EXT);
whismanoid 10:228a52f8107d 4716 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4717 }
whismanoid 0:3edb3708c8c5 4718 break;
whismanoid 0:3edb3708c8c5 4719 case '1':
whismanoid 0:3edb3708c8c5 4720 {
whismanoid 0:3edb3708c8c5 4721 // cmdLine.serial().printf("\r\n 71 -- REF_2V500");
whismanoid 0:3edb3708c8c5 4722 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4723 "MAX5715_REF(REF_2V500)");
whismanoid 0:3edb3708c8c5 4724 g_MAX5715_device.REF(MAX5715::REF_2V500);
whismanoid 10:228a52f8107d 4725 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4726 }
whismanoid 0:3edb3708c8c5 4727 break;
whismanoid 0:3edb3708c8c5 4728 case '2':
whismanoid 0:3edb3708c8c5 4729 {
whismanoid 0:3edb3708c8c5 4730 // cmdLine.serial().printf("\r\n 72 -- REF_2V048");
whismanoid 0:3edb3708c8c5 4731 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4732 "MAX5715_REF(REF_2V048)");
whismanoid 0:3edb3708c8c5 4733 g_MAX5715_device.REF(MAX5715::REF_2V048);
whismanoid 10:228a52f8107d 4734 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4735 }
whismanoid 0:3edb3708c8c5 4736 break;
whismanoid 0:3edb3708c8c5 4737 case '3':
whismanoid 0:3edb3708c8c5 4738 {
whismanoid 0:3edb3708c8c5 4739 // cmdLine.serial().printf("\r\n 73 -- REF_4V096");
whismanoid 0:3edb3708c8c5 4740 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4741 "MAX5715_REF(REF_4V096)");
whismanoid 0:3edb3708c8c5 4742 g_MAX5715_device.REF(MAX5715::REF_4V096);
whismanoid 10:228a52f8107d 4743 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4744 }
whismanoid 0:3edb3708c8c5 4745 break;
whismanoid 0:3edb3708c8c5 4746 case '4':
whismanoid 0:3edb3708c8c5 4747 {
whismanoid 0:3edb3708c8c5 4748 // cmdLine.serial().printf("\r\n 74 -- REF_AlwaysOn_EXT");
whismanoid 0:3edb3708c8c5 4749 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4750 "MAX5715_REF(REF_AlwaysOn_EXT)");
whismanoid 0:3edb3708c8c5 4751 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_EXT);
whismanoid 10:228a52f8107d 4752 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4753 }
whismanoid 0:3edb3708c8c5 4754 break;
whismanoid 0:3edb3708c8c5 4755 case '5':
whismanoid 0:3edb3708c8c5 4756 {
whismanoid 0:3edb3708c8c5 4757 // cmdLine.serial().printf("\r\n 75 -- REF_AlwaysOn_2V500");
whismanoid 0:3edb3708c8c5 4758 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4759 "MAX5715_REF(REF_AlwaysOn_2V500)");
whismanoid 0:3edb3708c8c5 4760 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500);
whismanoid 10:228a52f8107d 4761 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4762 }
whismanoid 0:3edb3708c8c5 4763 break;
whismanoid 0:3edb3708c8c5 4764 case '6':
whismanoid 0:3edb3708c8c5 4765 {
whismanoid 0:3edb3708c8c5 4766 // cmdLine.serial().printf("\r\n 76 -- REF_AlwaysOn_2V048");
whismanoid 0:3edb3708c8c5 4767 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4768 "MAX5715_REF(REF_AlwaysOn_2V048)");
whismanoid 0:3edb3708c8c5 4769 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048);
whismanoid 10:228a52f8107d 4770 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4771 }
whismanoid 0:3edb3708c8c5 4772 break;
whismanoid 0:3edb3708c8c5 4773 case '7':
whismanoid 0:3edb3708c8c5 4774 {
whismanoid 0:3edb3708c8c5 4775 // cmdLine.serial().printf("\r\n 77 -- REF_AlwaysOn_4V096");
whismanoid 0:3edb3708c8c5 4776 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 4777 "MAX5715_REF(REF_AlwaysOn_4V096)");
whismanoid 0:3edb3708c8c5 4778 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_4V096);
whismanoid 10:228a52f8107d 4779 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4780 }
whismanoid 0:3edb3708c8c5 4781 break;
whismanoid 0:3edb3708c8c5 4782 }
whismanoid 0:3edb3708c8c5 4783 }
whismanoid 0:3edb3708c8c5 4784 break;
whismanoid 0:3edb3708c8c5 4785 case '8':
whismanoid 0:3edb3708c8c5 4786 {
whismanoid 0:3edb3708c8c5 4787 // recommended for hex command codes 80..8F
whismanoid 0:3edb3708c8c5 4788 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4789 {
whismanoid 0:3edb3708c8c5 4790 case '0':
whismanoid 0:3edb3708c8c5 4791 {
whismanoid 0:3edb3708c8c5 4792 // TODO: cmdLine.serial().printf("\r\n 80 code=? -- CODEall");
whismanoid 0:3edb3708c8c5 4793 // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 4794 g_MAX5715_device.channels_bitmask_DCBA = 0xFF; // store g_MAX5715_device.CODE[allChannels]
whismanoid 0:3edb3708c8c5 4795 uint16_t code = g_MAX5715_device.CODE[0];
whismanoid 0:3edb3708c8c5 4796 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 4797 {
whismanoid 0:3edb3708c8c5 4798 }
whismanoid 0:3edb3708c8c5 4799 cmdLine.serial().printf("CODEall code=%d", code);
whismanoid 0:3edb3708c8c5 4800 g_MAX5715_device.CODEall(code);
whismanoid 10:228a52f8107d 4801 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4802 }
whismanoid 0:3edb3708c8c5 4803 break;
whismanoid 0:3edb3708c8c5 4804 case '1':
whismanoid 0:3edb3708c8c5 4805 {
whismanoid 0:3edb3708c8c5 4806 // TODO: cmdLine.serial().printf("\r\n 81 -- LOADall");
whismanoid 0:3edb3708c8c5 4807 cmdLine.serial().printf("LOADall");
whismanoid 0:3edb3708c8c5 4808 g_MAX5715_device.LOADall();
whismanoid 10:228a52f8107d 4809 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4810 }
whismanoid 0:3edb3708c8c5 4811 break;
whismanoid 0:3edb3708c8c5 4812 case '2':
whismanoid 0:3edb3708c8c5 4813 {
whismanoid 0:3edb3708c8c5 4814 // TODO: cmdLine.serial().printf("\r\n 82 code=? -- CODEallLOADall");
whismanoid 0:3edb3708c8c5 4815 uint16_t code = g_MAX5715_device.CODE[0];
whismanoid 0:3edb3708c8c5 4816 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 4817 {
whismanoid 0:3edb3708c8c5 4818 }
whismanoid 0:3edb3708c8c5 4819 cmdLine.serial().printf("CODEallLOADall code=%d", code);
whismanoid 0:3edb3708c8c5 4820 g_MAX5715_device.CODEallLOADall(code);
whismanoid 10:228a52f8107d 4821 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4822 }
whismanoid 0:3edb3708c8c5 4823 break;
whismanoid 0:3edb3708c8c5 4824 }
whismanoid 0:3edb3708c8c5 4825 }
whismanoid 0:3edb3708c8c5 4826 break;
whismanoid 0:3edb3708c8c5 4827 case '9':
whismanoid 0:3edb3708c8c5 4828 {
whismanoid 0:3edb3708c8c5 4829 // recommended for hex command codes 90..9F
whismanoid 0:3edb3708c8c5 4830 }
whismanoid 0:3edb3708c8c5 4831 break;
whismanoid 0:3edb3708c8c5 4832 case 'a': case 'A':
whismanoid 0:3edb3708c8c5 4833 {
whismanoid 0:3edb3708c8c5 4834 // recommended for hex command codes A0..AF
whismanoid 0:3edb3708c8c5 4835 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4836 {
whismanoid 0:3edb3708c8c5 4837 case 't': case 'T':
whismanoid 0:3edb3708c8c5 4838 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 4839 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 4840 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 4841 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 4842 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 10:228a52f8107d 4843 return false; // command not handled
whismanoid 0:3edb3708c8c5 4844 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 4845 }
whismanoid 0:3edb3708c8c5 4846 }
whismanoid 0:3edb3708c8c5 4847 break;
whismanoid 0:3edb3708c8c5 4848 case 'b': case 'B':
whismanoid 0:3edb3708c8c5 4849 {
whismanoid 0:3edb3708c8c5 4850 // recommended for hex command codes B0..BF
whismanoid 0:3edb3708c8c5 4851 }
whismanoid 0:3edb3708c8c5 4852 break;
whismanoid 0:3edb3708c8c5 4853 case 'c': case 'C':
whismanoid 0:3edb3708c8c5 4854 {
whismanoid 0:3edb3708c8c5 4855 // recommended for hex command codes C0..CF
whismanoid 0:3edb3708c8c5 4856 // // MAX5717 menu function to drive MAX5717_CLRb_Pin CLR#
whismanoid 0:3edb3708c8c5 4857 // cmdLine.serial().printf("\r\n C -- CLR# pulse CH high CL low");
whismanoid 0:3edb3708c8c5 4858 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4859 {
whismanoid 0:3edb3708c8c5 4860 default:
whismanoid 0:3edb3708c8c5 4861 // g_MAX5715_device.CLRboutputPulseLow();
whismanoid 0:3edb3708c8c5 4862 g_MAX5715_device.CLRboutputValue(1);
whismanoid 0:3edb3708c8c5 4863 g_MAX5715_device.CLRboutputValue(0);
whismanoid 0:3edb3708c8c5 4864 g_MAX5715_device.CLRboutputValue(1);
whismanoid 0:3edb3708c8c5 4865 break;
whismanoid 0:3edb3708c8c5 4866 case 'H': case 'h': case '1':
whismanoid 0:3edb3708c8c5 4867 g_MAX5715_device.CLRboutputValue(1); // GPIOoutputCLRb(int isLogicHigh);
whismanoid 0:3edb3708c8c5 4868 break;
whismanoid 0:3edb3708c8c5 4869 case 'L': case 'l': case '0':
whismanoid 0:3edb3708c8c5 4870 g_MAX5715_device.CLRboutputValue(0); // GPIOoutputCLRb(int isLogicHigh);
whismanoid 0:3edb3708c8c5 4871 break;
whismanoid 0:3edb3708c8c5 4872 }
whismanoid 10:228a52f8107d 4873 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4874 }
whismanoid 0:3edb3708c8c5 4875 break;
whismanoid 0:3edb3708c8c5 4876 case 'd': case 'D':
whismanoid 0:3edb3708c8c5 4877 {
whismanoid 0:3edb3708c8c5 4878 // recommended for hex command codes D0..DF
whismanoid 0:3edb3708c8c5 4879 }
whismanoid 0:3edb3708c8c5 4880 break;
whismanoid 0:3edb3708c8c5 4881 case 'e': case 'E':
whismanoid 0:3edb3708c8c5 4882 {
whismanoid 0:3edb3708c8c5 4883 // recommended for hex command codes E0..EF
whismanoid 0:3edb3708c8c5 4884 }
whismanoid 0:3edb3708c8c5 4885 break;
whismanoid 0:3edb3708c8c5 4886 case 'f': case 'F':
whismanoid 0:3edb3708c8c5 4887 {
whismanoid 0:3edb3708c8c5 4888 // recommended for hex command codes F0..FF
whismanoid 0:3edb3708c8c5 4889 }
whismanoid 0:3edb3708c8c5 4890 break;
whismanoid 0:3edb3708c8c5 4891 case 'l': case 'L':
whismanoid 0:3edb3708c8c5 4892 {
whismanoid 0:3edb3708c8c5 4893 // // MAX5717 menu function to drive MAX5717_LDACb_Pin LDAC#
whismanoid 0:3edb3708c8c5 4894 // cmdLine.serial().printf("\r\n L -- LDAC# pulse LH high LL low");
whismanoid 0:3edb3708c8c5 4895 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4896 {
whismanoid 0:3edb3708c8c5 4897 default:
whismanoid 0:3edb3708c8c5 4898 // g_MAX5715_device.LDACboutputPulseLow();
whismanoid 0:3edb3708c8c5 4899 g_MAX5715_device.LDACboutputValue(1);
whismanoid 0:3edb3708c8c5 4900 g_MAX5715_device.LDACboutputValue(0);
whismanoid 0:3edb3708c8c5 4901 g_MAX5715_device.LDACboutputValue(1);
whismanoid 0:3edb3708c8c5 4902 break;
whismanoid 0:3edb3708c8c5 4903 case 'H': case 'h': case '1':
whismanoid 0:3edb3708c8c5 4904 g_MAX5715_device.LDACboutputValue(1); // GPIOoutputLDACb(int isLogicHigh);
whismanoid 0:3edb3708c8c5 4905 break;
whismanoid 0:3edb3708c8c5 4906 case 'L': case 'l': case '0':
whismanoid 0:3edb3708c8c5 4907 g_MAX5715_device.LDACboutputValue(0); // GPIOoutputLDACb(int isLogicHigh);
whismanoid 0:3edb3708c8c5 4908 break;
whismanoid 0:3edb3708c8c5 4909 }
whismanoid 10:228a52f8107d 4910 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4911 }
whismanoid 0:3edb3708c8c5 4912 break;
whismanoid 0:3edb3708c8c5 4913 case 'x': case 'X':
whismanoid 0:3edb3708c8c5 4914 {
whismanoid 0:3edb3708c8c5 4915 }
whismanoid 0:3edb3708c8c5 4916 break;
whismanoid 0:3edb3708c8c5 4917 case 'y': case 'Y':
whismanoid 0:3edb3708c8c5 4918 {
whismanoid 0:3edb3708c8c5 4919 }
whismanoid 0:3edb3708c8c5 4920 break;
whismanoid 0:3edb3708c8c5 4921 case 'z': case 'Z':
whismanoid 0:3edb3708c8c5 4922 {
whismanoid 0:3edb3708c8c5 4923 }
whismanoid 0:3edb3708c8c5 4924 break;
whismanoid 0:3edb3708c8c5 4925 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 0:3edb3708c8c5 4926 {
whismanoid 0:3edb3708c8c5 4927 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 4928 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 4929 {
whismanoid 0:3edb3708c8c5 4930 default:
whismanoid 0:3edb3708c8c5 4931 {
whismanoid 0:3edb3708c8c5 4932 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 4933 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 4934 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n",
whismanoid 0:3edb3708c8c5 4935 cmdLine.str());
whismanoid 0:3edb3708c8c5 4936 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 4937 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 4938 }
whismanoid 0:3edb3708c8c5 4939 }
whismanoid 0:3edb3708c8c5 4940 }
whismanoid 0:3edb3708c8c5 4941 break;
whismanoid 0:3edb3708c8c5 4942 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 0:3edb3708c8c5 4943 {
whismanoid 0:3edb3708c8c5 4944 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 4945 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 4946 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 4947 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 4948 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 4949 }
whismanoid 0:3edb3708c8c5 4950 break;
whismanoid 0:3edb3708c8c5 4951 case '@':
whismanoid 0:3edb3708c8c5 4952 {
whismanoid 0:3edb3708c8c5 4953 // //
whismanoid 0:3edb3708c8c5 4954 // // Menu @ -- print device configuration
whismanoid 0:3edb3708c8c5 4955 // TODO: cmdLine.serial().printf("\r\n @ -- print MAX5715 configuration");
whismanoid 0:3edb3708c8c5 4956 // //
whismanoid 0:3edb3708c8c5 4957 // print shadow register configuration
whismanoid 0:3edb3708c8c5 4958 //
whismanoid 0:3edb3708c8c5 4959 // shadow of write-only register CODE dddd_dddd_dddd_0000
whismanoid 0:3edb3708c8c5 4960 //~ int16_t CMD_1000_CODE;
whismanoid 0:3edb3708c8c5 4961 int index = 0;
whismanoid 0:3edb3708c8c5 4962 for (index = 0; index < 4; index++)
whismanoid 0:3edb3708c8c5 4963 {
whismanoid 0:3edb3708c8c5 4964 cmdLine.serial().printf("CODE %c=0x%4.4x MAX5715_VoltageOfCode(%d)=%5.3fV\r\n",
whismanoid 0:3edb3708c8c5 4965 (char)('A' + index),
whismanoid 0:3edb3708c8c5 4966 (g_MAX5715_device.Shadow_0010_nnnn_CODE[index] & 0xFFFF),
whismanoid 0:3edb3708c8c5 4967 g_MAX5715_device.CODE[index],
whismanoid 0:3edb3708c8c5 4968 g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[index])
whismanoid 0:3edb3708c8c5 4969 );
whismanoid 0:3edb3708c8c5 4970 }
whismanoid 0:3edb3708c8c5 4971 //
whismanoid 0:3edb3708c8c5 4972 cmdLine.serial().printf("\r\n");
whismanoid 0:3edb3708c8c5 4973 //
whismanoid 0:3edb3708c8c5 4974 //
whismanoid 0:3edb3708c8c5 4975 // Menu @) print MAX5715 configuration AND g_MAX5715_device globals
whismanoid 0:3edb3708c8c5 4976 //
whismanoid 0:3edb3708c8c5 4977 #if 1 // SUPPORT_CHANNELS
whismanoid 0:3edb3708c8c5 4978 cmdLine.serial().printf("channelNumber_0_3=%d channels_bitmask_DCBA=%d\r\n",
whismanoid 0:3edb3708c8c5 4979 (g_MAX5715_device.channelNumber_0_3 & 0xFFFF),
whismanoid 0:3edb3708c8c5 4980 (g_MAX5715_device.channels_bitmask_DCBA & 0xFFFF));
whismanoid 0:3edb3708c8c5 4981 #endif // SUPPORT_CHANNELS
whismanoid 0:3edb3708c8c5 4982 //
whismanoid 0:3edb3708c8c5 4983 cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX5715_device.VRef);
whismanoid 0:3edb3708c8c5 4984 // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB
whismanoid 10:228a52f8107d 4985 return true; // command was handled by MAX5715
whismanoid 0:3edb3708c8c5 4986 }
whismanoid 0:3edb3708c8c5 4987 break;
whismanoid 10:228a52f8107d 4988 } // end switch (cmdLine[0])
whismanoid 10:228a52f8107d 4989 return false; // command not handled by MAX5715
whismanoid 10:228a52f8107d 4990 } // end bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 4991 #endif
whismanoid 0:3edb3708c8c5 4992
whismanoid 10:228a52f8107d 4993 //--------------------------------------------------
whismanoid 10:228a52f8107d 4994 #if 0 // APPLICATION_MAX11131 // MAX11131_menu_onEOLcommandParser moved to Test_Menu_MAX11131.cpp
whismanoid 10:228a52f8107d 4995 bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 4996 {
whismanoid 10:228a52f8107d 4997 switch (cmdLine[0])
whismanoid 10:228a52f8107d 4998 {
whismanoid 0:3edb3708c8c5 4999 case '0':
whismanoid 0:3edb3708c8c5 5000 {
whismanoid 0:3edb3708c8c5 5001 // recommended for hex command codes 00..0F
whismanoid 0:3edb3708c8c5 5002 // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void);
whismanoid 0:3edb3708c8c5 5003 // TODO: cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead");
whismanoid 0:3edb3708c8c5 5004 if (cmdLine.parse_uint16_dec("n", g_MAX11131_device.NumWords))
whismanoid 0:3edb3708c8c5 5005 {
whismanoid 0:3edb3708c8c5 5006 }
whismanoid 0:3edb3708c8c5 5007 cmdLine.serial().printf("ScanRead NumWords=%d", g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 5008 if (g_MAX11131_device.isExternalClock)
whismanoid 0:3edb3708c8c5 5009 {
whismanoid 0:3edb3708c8c5 5010 cmdLine.serial().printf(" External Clock");
whismanoid 0:3edb3708c8c5 5011 //
whismanoid 0:3edb3708c8c5 5012 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5013 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5014 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5015 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5016 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5017 //
whismanoid 0:3edb3708c8c5 5018 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 5019 }
whismanoid 0:3edb3708c8c5 5020 else
whismanoid 0:3edb3708c8c5 5021 {
whismanoid 0:3edb3708c8c5 5022 cmdLine.serial().printf(" Internal Clock");
whismanoid 0:3edb3708c8c5 5023 //
whismanoid 0:3edb3708c8c5 5024 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5025 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5026 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5027 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5028 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5029 //
whismanoid 0:3edb3708c8c5 5030 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 0:3edb3708c8c5 5031 }
whismanoid 10:228a52f8107d 5032 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5033 }
whismanoid 0:3edb3708c8c5 5034 break;
whismanoid 0:3edb3708c8c5 5035 case '1':
whismanoid 0:3edb3708c8c5 5036 {
whismanoid 0:3edb3708c8c5 5037 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5038 // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 5039 // TODO: cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual");
whismanoid 0:3edb3708c8c5 5040 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5041 {
whismanoid 0:3edb3708c8c5 5042 }
whismanoid 0:3edb3708c8c5 5043 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5044 {
whismanoid 0:3edb3708c8c5 5045 }
whismanoid 0:3edb3708c8c5 5046 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 0:3edb3708c8c5 5047 {
whismanoid 0:3edb3708c8c5 5048 }
whismanoid 0:3edb3708c8c5 5049 cmdLine.serial().printf("ScanManual ch=%d pm=%d id=%d\r\n",
whismanoid 0:3edb3708c8c5 5050 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5051 g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5052 g_MAX11131_device.chan_id_0_1);
whismanoid 0:3edb3708c8c5 5053 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5054 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 0:3edb3708c8c5 5055 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5056 g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
whismanoid 0:3edb3708c8c5 5057 //
whismanoid 0:3edb3708c8c5 5058 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5059 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5060 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5061 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5062 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5063 //
whismanoid 0:3edb3708c8c5 5064 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 10:228a52f8107d 5065 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5066 }
whismanoid 0:3edb3708c8c5 5067 break;
whismanoid 0:3edb3708c8c5 5068 case '2':
whismanoid 0:3edb3708c8c5 5069 {
whismanoid 0:3edb3708c8c5 5070 // recommended for hex command codes 20..2F
whismanoid 0:3edb3708c8c5 5071 // 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 5072 // TODO: cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat");
whismanoid 0:3edb3708c8c5 5073 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 0:3edb3708c8c5 5074 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5075 // VERIFY: update value of g_MAX11131_device.nscan_4_8_12_16 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5076 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5077 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5078 // VERIFY: parse strCommandArgs for additional arguments including key=value pairs
whismanoid 0:3edb3708c8c5 5079 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5080 {
whismanoid 0:3edb3708c8c5 5081 }
whismanoid 0:3edb3708c8c5 5082 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 0:3edb3708c8c5 5083 {
whismanoid 0:3edb3708c8c5 5084 }
whismanoid 0:3edb3708c8c5 5085 if (cmdLine.parse_byte_dec("n", g_MAX11131_device.nscan_4_8_12_16))
whismanoid 0:3edb3708c8c5 5086 {
whismanoid 0:3edb3708c8c5 5087 }
whismanoid 0:3edb3708c8c5 5088 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 0:3edb3708c8c5 5089 {
whismanoid 0:3edb3708c8c5 5090 }
whismanoid 0:3edb3708c8c5 5091 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5092 {
whismanoid 0:3edb3708c8c5 5093 }
whismanoid 0:3edb3708c8c5 5094 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 5095 "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 5096 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5097 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 0:3edb3708c8c5 5098 g_MAX11131_device.nscan_4_8_12_16,
whismanoid 0:3edb3708c8c5 5099 g_MAX11131_device.swcnv_0_1,
whismanoid 0:3edb3708c8c5 5100 g_MAX11131_device.PowerManagement_0_2);
whismanoid 0:3edb3708c8c5 5101 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5102 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 0:3edb3708c8c5 5103 // VERIFY: replace argument with driver global; g_MAX11131_device.nscan_4_8_12_16 replaces nscan_4_8_12_16
whismanoid 0:3edb3708c8c5 5104 // 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 5105 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5106 g_MAX11131_device.NumWords = g_MAX11131_device.ScanRepeat();
whismanoid 0:3edb3708c8c5 5107 //
whismanoid 0:3edb3708c8c5 5108 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5109 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5110 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5111 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5112 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5113 //
whismanoid 0:3edb3708c8c5 5114 AINcode_print_value_chanID_mean(cmdLine, g_MAX11131_device.NumWords);
whismanoid 10:228a52f8107d 5115 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5116 }
whismanoid 0:3edb3708c8c5 5117 break;
whismanoid 0:3edb3708c8c5 5118 case '3':
whismanoid 0:3edb3708c8c5 5119 {
whismanoid 0:3edb3708c8c5 5120 // recommended for hex command codes 30..3F
whismanoid 0:3edb3708c8c5 5121 // 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 5122 // TODO: cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock");
whismanoid 0:3edb3708c8c5 5123 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 0:3edb3708c8c5 5124 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5125 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5126 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5127 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5128 {
whismanoid 0:3edb3708c8c5 5129 }
whismanoid 0:3edb3708c8c5 5130 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 0:3edb3708c8c5 5131 {
whismanoid 0:3edb3708c8c5 5132 }
whismanoid 0:3edb3708c8c5 5133 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5134 {
whismanoid 0:3edb3708c8c5 5135 }
whismanoid 0:3edb3708c8c5 5136 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 0:3edb3708c8c5 5137 {
whismanoid 0:3edb3708c8c5 5138 }
whismanoid 0:3edb3708c8c5 5139 cmdLine.serial().printf("ScanStandardInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n",
whismanoid 0:3edb3708c8c5 5140 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5141 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 0:3edb3708c8c5 5142 g_MAX11131_device.swcnv_0_1,
whismanoid 0:3edb3708c8c5 5143 g_MAX11131_device.PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5144 );
whismanoid 0:3edb3708c8c5 5145 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5146 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 0:3edb3708c8c5 5147 // 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 5148 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5149 g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardInternalClock();
whismanoid 0:3edb3708c8c5 5150 //
whismanoid 0:3edb3708c8c5 5151 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5152 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5153 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5154 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5155 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5156 //
whismanoid 0:3edb3708c8c5 5157 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 10:228a52f8107d 5158 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5159 }
whismanoid 0:3edb3708c8c5 5160 break;
whismanoid 0:3edb3708c8c5 5161 case '4':
whismanoid 0:3edb3708c8c5 5162 {
whismanoid 0:3edb3708c8c5 5163 // recommended for hex command codes 40..4F
whismanoid 0:3edb3708c8c5 5164 // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 5165 // TODO: cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock");
whismanoid 0:3edb3708c8c5 5166 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 0:3edb3708c8c5 5167 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5168 // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5169 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5170 {
whismanoid 0:3edb3708c8c5 5171 }
whismanoid 0:3edb3708c8c5 5172 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5173 {
whismanoid 0:3edb3708c8c5 5174 }
whismanoid 0:3edb3708c8c5 5175 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 0:3edb3708c8c5 5176 {
whismanoid 0:3edb3708c8c5 5177 }
whismanoid 0:3edb3708c8c5 5178 cmdLine.serial().printf("ScanStandardExternalClock ch=%d pm=%d id=%d\r\n",
whismanoid 0:3edb3708c8c5 5179 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5180 g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5181 g_MAX11131_device.chan_id_0_1
whismanoid 0:3edb3708c8c5 5182 );
whismanoid 0:3edb3708c8c5 5183 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5184 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 0:3edb3708c8c5 5185 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5186 g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock();
whismanoid 0:3edb3708c8c5 5187 //
whismanoid 0:3edb3708c8c5 5188 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5189 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5190 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5191 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5192 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5193 //
whismanoid 0:3edb3708c8c5 5194 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 10:228a52f8107d 5195 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5196 }
whismanoid 0:3edb3708c8c5 5197 break;
whismanoid 0:3edb3708c8c5 5198 case '5':
whismanoid 0:3edb3708c8c5 5199 {
whismanoid 0:3edb3708c8c5 5200 // recommended for hex command codes 50..5F
whismanoid 0:3edb3708c8c5 5201 // 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 5202 // TODO: cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock");
whismanoid 0:3edb3708c8c5 5203 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 0:3edb3708c8c5 5204 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5205 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5206 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5207 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5208 {
whismanoid 0:3edb3708c8c5 5209 }
whismanoid 0:3edb3708c8c5 5210 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 0:3edb3708c8c5 5211 {
whismanoid 0:3edb3708c8c5 5212 }
whismanoid 0:3edb3708c8c5 5213 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5214 {
whismanoid 0:3edb3708c8c5 5215 }
whismanoid 0:3edb3708c8c5 5216 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 0:3edb3708c8c5 5217 {
whismanoid 0:3edb3708c8c5 5218 }
whismanoid 0:3edb3708c8c5 5219 cmdLine.serial().printf("ScanUpperInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n",
whismanoid 0:3edb3708c8c5 5220 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5221 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 0:3edb3708c8c5 5222 g_MAX11131_device.swcnv_0_1,
whismanoid 0:3edb3708c8c5 5223 g_MAX11131_device.PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5224 );
whismanoid 0:3edb3708c8c5 5225 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5226 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 0:3edb3708c8c5 5227 // 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 5228 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5229 g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperInternalClock();
whismanoid 0:3edb3708c8c5 5230 //
whismanoid 0:3edb3708c8c5 5231 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5232 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5233 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5234 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5235 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5236 //
whismanoid 0:3edb3708c8c5 5237 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 10:228a52f8107d 5238 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5239 }
whismanoid 0:3edb3708c8c5 5240 break;
whismanoid 0:3edb3708c8c5 5241 case '6':
whismanoid 0:3edb3708c8c5 5242 {
whismanoid 0:3edb3708c8c5 5243 // recommended for hex command codes 60..6F
whismanoid 0:3edb3708c8c5 5244 // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 5245 // TODO: cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock");
whismanoid 0:3edb3708c8c5 5246 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 0:3edb3708c8c5 5247 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5248 // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5249 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 0:3edb3708c8c5 5250 {
whismanoid 0:3edb3708c8c5 5251 }
whismanoid 0:3edb3708c8c5 5252 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5253 {
whismanoid 0:3edb3708c8c5 5254 }
whismanoid 0:3edb3708c8c5 5255 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 0:3edb3708c8c5 5256 {
whismanoid 0:3edb3708c8c5 5257 }
whismanoid 0:3edb3708c8c5 5258 cmdLine.serial().printf("ScanUpperExternalClock ch=%d pm=%d id=%d\r\n",
whismanoid 0:3edb3708c8c5 5259 g_MAX11131_device.channelNumber_0_15,
whismanoid 0:3edb3708c8c5 5260 g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5261 g_MAX11131_device.chan_id_0_1
whismanoid 0:3edb3708c8c5 5262 );
whismanoid 0:3edb3708c8c5 5263 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5264 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 0:3edb3708c8c5 5265 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 0:3edb3708c8c5 5266 g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperExternalClock();
whismanoid 0:3edb3708c8c5 5267 //
whismanoid 0:3edb3708c8c5 5268 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5269 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5270 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5271 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5272 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5273 //
whismanoid 0:3edb3708c8c5 5274 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 10:228a52f8107d 5275 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5276 }
whismanoid 0:3edb3708c8c5 5277 break;
whismanoid 0:3edb3708c8c5 5278 case '7':
whismanoid 0:3edb3708c8c5 5279 {
whismanoid 0:3edb3708c8c5 5280 // recommended for hex command codes 70..7F
whismanoid 0:3edb3708c8c5 5281 // 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 5282 // TODO: cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock");
whismanoid 0:3edb3708c8c5 5283 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5284 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5285 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 0:3edb3708c8c5 5286 if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask))
whismanoid 0:3edb3708c8c5 5287 {
whismanoid 0:3edb3708c8c5 5288 // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs
whismanoid 0:3edb3708c8c5 5289 }
whismanoid 0:3edb3708c8c5 5290 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 0:3edb3708c8c5 5291 {
whismanoid 0:3edb3708c8c5 5292 }
whismanoid 0:3edb3708c8c5 5293 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5294 {
whismanoid 0:3edb3708c8c5 5295 }
whismanoid 0:3edb3708c8c5 5296 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 0:3edb3708c8c5 5297 {
whismanoid 0:3edb3708c8c5 5298 }
whismanoid 0:3edb3708c8c5 5299 cmdLine.serial().printf(
whismanoid 0:3edb3708c8c5 5300 "ScanCustomInternalClock enabledChannelsMask:0x%4.4x average_0_4_8_16_32:%d pm=%d swcnv=%d\r\n",
whismanoid 0:3edb3708c8c5 5301 (g_MAX11131_device.enabledChannelsMask & 0xFFFF),
whismanoid 0:3edb3708c8c5 5302 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 0:3edb3708c8c5 5303 g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5304 g_MAX11131_device.swcnv_0_1
whismanoid 0:3edb3708c8c5 5305 );
whismanoid 0:3edb3708c8c5 5306 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5307 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 0:3edb3708c8c5 5308 // 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 5309 // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask
whismanoid 0:3edb3708c8c5 5310 g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomInternalClock();
whismanoid 0:3edb3708c8c5 5311 //
whismanoid 0:3edb3708c8c5 5312 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5313 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5314 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5315 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5316 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5317 //
whismanoid 0:3edb3708c8c5 5318 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 10:228a52f8107d 5319 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5320 }
whismanoid 0:3edb3708c8c5 5321 break;
whismanoid 0:3edb3708c8c5 5322 case '8':
whismanoid 0:3edb3708c8c5 5323 {
whismanoid 0:3edb3708c8c5 5324 // recommended for hex command codes 80..8F
whismanoid 0:3edb3708c8c5 5325 // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 0:3edb3708c8c5 5326 // TODO: cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock");
whismanoid 0:3edb3708c8c5 5327 if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask))
whismanoid 0:3edb3708c8c5 5328 {
whismanoid 0:3edb3708c8c5 5329 // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs
whismanoid 0:3edb3708c8c5 5330 }
whismanoid 0:3edb3708c8c5 5331 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 0:3edb3708c8c5 5332 {
whismanoid 0:3edb3708c8c5 5333 }
whismanoid 0:3edb3708c8c5 5334 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 0:3edb3708c8c5 5335 {
whismanoid 0:3edb3708c8c5 5336 }
whismanoid 0:3edb3708c8c5 5337 cmdLine.serial().printf("ScanCustomExternalClock enabledChannelsMask:0x%4.4x pm=%d id=%d\r\n",
whismanoid 0:3edb3708c8c5 5338 (g_MAX11131_device.enabledChannelsMask & 0xFFFF),
whismanoid 0:3edb3708c8c5 5339 g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5340 g_MAX11131_device.chan_id_0_1
whismanoid 0:3edb3708c8c5 5341 );
whismanoid 0:3edb3708c8c5 5342 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5343 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 0:3edb3708c8c5 5344 // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask
whismanoid 0:3edb3708c8c5 5345 g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomExternalClock();
whismanoid 0:3edb3708c8c5 5346 //
whismanoid 0:3edb3708c8c5 5347 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5348 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5349 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5350 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5351 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5352 //
whismanoid 0:3edb3708c8c5 5353 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 10:228a52f8107d 5354 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5355 }
whismanoid 0:3edb3708c8c5 5356 break;
whismanoid 0:3edb3708c8c5 5357 case '9':
whismanoid 0:3edb3708c8c5 5358 {
whismanoid 0:3edb3708c8c5 5359 // recommended for hex command codes 90..9F
whismanoid 0:3edb3708c8c5 5360 // 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 5361 // TODO: cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock");
whismanoid 0:3edb3708c8c5 5362 //
whismanoid 0:3edb3708c8c5 5363 // get MAX11131 Sampleset channel selection pattern parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 5364 // cmdLine.parse_byteCount_byteList_dec(byteCount, mosiData, MAX_SPI_BYTE_COUNT)
whismanoid 0:3edb3708c8c5 5365 // into g_MAX11131_device.enabledChannelsPatternLength_1_256
whismanoid 0:3edb3708c8c5 5366 // into g_MAX11131_device.enabledChannelsPattern[0..255]
whismanoid 0:3edb3708c8c5 5367 size_t numValues;
whismanoid 0:3edb3708c8c5 5368 char valueList[256];
whismanoid 0:3edb3708c8c5 5369 if (cmdLine.parse_byteCount_byteList_dec( numValues, valueList, 256))
whismanoid 0:3edb3708c8c5 5370 {
whismanoid 0:3edb3708c8c5 5371 // first value is the "9" command itself
whismanoid 0:3edb3708c8c5 5372 g_MAX11131_device.enabledChannelsPatternLength_1_256 = numValues - 1;
whismanoid 0:3edb3708c8c5 5373 // copy valueList[1, ...] into g_MAX11131_device.enabledChannelsPattern[0, ...]
whismanoid 0:3edb3708c8c5 5374 for (size_t index = 0; index < (numValues - 1); index++)
whismanoid 0:3edb3708c8c5 5375 {
whismanoid 0:3edb3708c8c5 5376 g_MAX11131_device.enabledChannelsPattern[index] = valueList[1 + index];
whismanoid 0:3edb3708c8c5 5377 }
whismanoid 0:3edb3708c8c5 5378 }
whismanoid 0:3edb3708c8c5 5379 //
whismanoid 0:3edb3708c8c5 5380 cmdLine.serial().printf("ScanSampleSetExternalClock enabledChannelsPattern:{ ");
whismanoid 0:3edb3708c8c5 5381 int index;
whismanoid 0:3edb3708c8c5 5382 for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++)
whismanoid 0:3edb3708c8c5 5383 {
whismanoid 0:3edb3708c8c5 5384 //~ Serial.print( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC);
whismanoid 0:3edb3708c8c5 5385 //~ Serial.print(" ");
whismanoid 0:3edb3708c8c5 5386 cmdLine.serial().printf("AIN%d ", ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F));
whismanoid 0:3edb3708c8c5 5387 }
whismanoid 0:3edb3708c8c5 5388 cmdLine.serial().printf("}");
whismanoid 0:3edb3708c8c5 5389 cmdLine.serial().printf(" pm=%d id=%d\r\n", g_MAX11131_device.PowerManagement_0_2,
whismanoid 0:3edb3708c8c5 5390 g_MAX11131_device.chan_id_0_1);
whismanoid 0:3edb3708c8c5 5391 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 0:3edb3708c8c5 5392 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 0:3edb3708c8c5 5393 g_MAX11131_device.NumWords = g_MAX11131_device.ScanSampleSetExternalClock();
whismanoid 0:3edb3708c8c5 5394 //
whismanoid 0:3edb3708c8c5 5395 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 0:3edb3708c8c5 5396 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 0:3edb3708c8c5 5397 g_MAX11131_device.ReadAINcode();
whismanoid 0:3edb3708c8c5 5398 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 0:3edb3708c8c5 5399 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 0:3edb3708c8c5 5400 //
whismanoid 0:3edb3708c8c5 5401 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 10:228a52f8107d 5402 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5403 }
whismanoid 0:3edb3708c8c5 5404 break;
whismanoid 0:3edb3708c8c5 5405 case 'a': case 'A':
whismanoid 0:3edb3708c8c5 5406 {
whismanoid 0:3edb3708c8c5 5407 // recommended for hex command codes A0..AF
whismanoid 0:3edb3708c8c5 5408 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5409 {
whismanoid 0:3edb3708c8c5 5410 case 't': case 'T':
whismanoid 0:3edb3708c8c5 5411 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5412 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5413 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5414 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5415 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 10:228a52f8107d 5416 return false; // command not handled
whismanoid 0:3edb3708c8c5 5417 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5418 }
whismanoid 0:3edb3708c8c5 5419 }
whismanoid 0:3edb3708c8c5 5420 break;
whismanoid 0:3edb3708c8c5 5421 case 'b': case 'B':
whismanoid 0:3edb3708c8c5 5422 {
whismanoid 0:3edb3708c8c5 5423 // recommended for hex command codes B0..BF
whismanoid 0:3edb3708c8c5 5424 }
whismanoid 0:3edb3708c8c5 5425 break;
whismanoid 0:3edb3708c8c5 5426 case 'c': case 'C':
whismanoid 0:3edb3708c8c5 5427 {
whismanoid 0:3edb3708c8c5 5428 // recommended for hex command codes C0..CF
whismanoid 0:3edb3708c8c5 5429 }
whismanoid 0:3edb3708c8c5 5430 break;
whismanoid 0:3edb3708c8c5 5431 case 'd': case 'D':
whismanoid 0:3edb3708c8c5 5432 {
whismanoid 0:3edb3708c8c5 5433 // recommended for hex command codes D0..DF
whismanoid 0:3edb3708c8c5 5434 }
whismanoid 0:3edb3708c8c5 5435 break;
whismanoid 0:3edb3708c8c5 5436 case 'e': case 'E':
whismanoid 0:3edb3708c8c5 5437 {
whismanoid 0:3edb3708c8c5 5438 // recommended for hex command codes E0..EF
whismanoid 0:3edb3708c8c5 5439 }
whismanoid 0:3edb3708c8c5 5440 break;
whismanoid 0:3edb3708c8c5 5441 case 'f': case 'F':
whismanoid 0:3edb3708c8c5 5442 {
whismanoid 0:3edb3708c8c5 5443 // recommended for hex command codes F0..FF
whismanoid 0:3edb3708c8c5 5444 }
whismanoid 0:3edb3708c8c5 5445 break;
whismanoid 0:3edb3708c8c5 5446 case 'x': case 'X':
whismanoid 0:3edb3708c8c5 5447 {
whismanoid 0:3edb3708c8c5 5448 }
whismanoid 0:3edb3708c8c5 5449 break;
whismanoid 0:3edb3708c8c5 5450 case 'y': case 'Y':
whismanoid 0:3edb3708c8c5 5451 {
whismanoid 0:3edb3708c8c5 5452 }
whismanoid 0:3edb3708c8c5 5453 break;
whismanoid 0:3edb3708c8c5 5454 case 'i': case 'I':
whismanoid 0:3edb3708c8c5 5455 {
whismanoid 0:3edb3708c8c5 5456 // TODO: cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range");
whismanoid 0:3edb3708c8c5 5457 char strChannelId[3];
whismanoid 0:3edb3708c8c5 5458 strChannelId[0] = cmdLine[2];
whismanoid 0:3edb3708c8c5 5459 strChannelId[1] = cmdLine[3];
whismanoid 0:3edb3708c8c5 5460 strChannelId[2] = '\0';
whismanoid 0:3edb3708c8c5 5461 int channelId_0_15 = strtoul(strChannelId, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 0:3edb3708c8c5 5462 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5463 {
whismanoid 0:3edb3708c8c5 5464 case 's': case 'S':
whismanoid 0:3edb3708c8c5 5465 g_MAX11131_device.Reconfigure_SingleEnded(channelId_0_15);
whismanoid 0:3edb3708c8c5 5466 break;
whismanoid 0:3edb3708c8c5 5467 case 'u': case 'U':
whismanoid 0:3edb3708c8c5 5468 g_MAX11131_device.Reconfigure_DifferentialUnipolar(channelId_0_15);
whismanoid 0:3edb3708c8c5 5469 break;
whismanoid 0:3edb3708c8c5 5470 case 'b': case 'B':
whismanoid 0:3edb3708c8c5 5471 g_MAX11131_device.Reconfigure_DifferentialBipolarFSVref(channelId_0_15);
whismanoid 0:3edb3708c8c5 5472 break;
whismanoid 0:3edb3708c8c5 5473 case 'r': case 'R':
whismanoid 0:3edb3708c8c5 5474 g_MAX11131_device.Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15);
whismanoid 0:3edb3708c8c5 5475 break;
whismanoid 0:3edb3708c8c5 5476 }
whismanoid 0:3edb3708c8c5 5477 // char cmd1 = strCommandArgs[0];
whismanoid 0:3edb3708c8c5 5478 // strCommandArgs.remove(0, 1); // unsigned int index, unsigned int count
whismanoid 0:3edb3708c8c5 5479 // // get argument int channelId_0_15
whismanoid 0:3edb3708c8c5 5480 // // parse_strCommandArgs(strCommandArgs);
whismanoid 0:3edb3708c8c5 5481 // int channelId_0_15 = strtoul(strCommandArgs.c_str(), NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 0:3edb3708c8c5 5482 // if (cmd1 == 'S') {
whismanoid 0:3edb3708c8c5 5483 // MAX11131_Reconfigure_SingleEnded(channelId_0_15);
whismanoid 0:3edb3708c8c5 5484 // }
whismanoid 0:3edb3708c8c5 5485 // else if (cmd1 == 'U') {
whismanoid 0:3edb3708c8c5 5486 // MAX11131_Reconfigure_DifferentialUnipolar(channelId_0_15);
whismanoid 0:3edb3708c8c5 5487 // }
whismanoid 0:3edb3708c8c5 5488 // else if (cmd1 == 'B') {
whismanoid 0:3edb3708c8c5 5489 // MAX11131_Reconfigure_DifferentialBipolarFSVref(channelId_0_15);
whismanoid 0:3edb3708c8c5 5490 // }
whismanoid 0:3edb3708c8c5 5491 // else if (cmd1 == 'R') {
whismanoid 0:3edb3708c8c5 5492 // MAX11131_Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15);
whismanoid 0:3edb3708c8c5 5493 // }
whismanoid 10:228a52f8107d 5494 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5495 }
whismanoid 0:3edb3708c8c5 5496 break;
whismanoid 0:3edb3708c8c5 5497 case '@':
whismanoid 0:3edb3708c8c5 5498 {
whismanoid 0:3edb3708c8c5 5499 // TODO: cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration");
whismanoid 0:3edb3708c8c5 5500 // print shadow register configuration
whismanoid 0:3edb3708c8c5 5501 //
whismanoid 0:3edb3708c8c5 5502 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_MODE_CONTROL & 0xFFFF));
whismanoid 0:3edb3708c8c5 5503 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_MODE_CONTROL);
whismanoid 0:3edb3708c8c5 5504 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_CONFIGURATION & 0xFFFF));
whismanoid 0:3edb3708c8c5 5505 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_CONFIGURATION);
whismanoid 0:3edb3708c8c5 5506 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.UNIPOLAR & 0xFFFF));
whismanoid 0:3edb3708c8c5 5507 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.UNIPOLAR);
whismanoid 0:3edb3708c8c5 5508 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.BIPOLAR & 0xFFFF));
whismanoid 0:3edb3708c8c5 5509 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.BIPOLAR);
whismanoid 0:3edb3708c8c5 5510 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.RANGE & 0xFFFF));
whismanoid 0:3edb3708c8c5 5511 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.RANGE);
whismanoid 0:3edb3708c8c5 5512 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN0 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5513 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN0);
whismanoid 0:3edb3708c8c5 5514 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN1 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5515 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN1);
whismanoid 0:3edb3708c8c5 5516 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.SAMPLESET & 0xFFFF));
whismanoid 0:3edb3708c8c5 5517 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.SAMPLESET);
whismanoid 0:3edb3708c8c5 5518 //
whismanoid 0:3edb3708c8c5 5519 // VERIFY: print shadow SAMPLESET pattern entry
whismanoid 0:3edb3708c8c5 5520 int entryIndex;
whismanoid 0:3edb3708c8c5 5521 for (entryIndex = 0; entryIndex < g_MAX11131_device.enabledChannelsPatternLength_1_256;
whismanoid 0:3edb3708c8c5 5522 entryIndex += 4)
whismanoid 0:3edb3708c8c5 5523 {
whismanoid 0:3edb3708c8c5 5524 uint16_t pack4channels = 0;
whismanoid 0:3edb3708c8c5 5525 pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 0]) & 0x0F) << 12);
whismanoid 0:3edb3708c8c5 5526 if ((entryIndex + 1) < g_MAX11131_device.enabledChannelsPatternLength_1_256) {
whismanoid 0:3edb3708c8c5 5527 pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 1]) & 0x0F) << 8);
whismanoid 0:3edb3708c8c5 5528 }
whismanoid 0:3edb3708c8c5 5529 if ((entryIndex + 2) < g_MAX11131_device.enabledChannelsPatternLength_1_256) {
whismanoid 0:3edb3708c8c5 5530 pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 2]) & 0x0F) << 4);
whismanoid 0:3edb3708c8c5 5531 }
whismanoid 0:3edb3708c8c5 5532 if ((entryIndex + 3) < g_MAX11131_device.enabledChannelsPatternLength_1_256) {
whismanoid 0:3edb3708c8c5 5533 pack4channels |= ((g_MAX11131_device.enabledChannelsPattern[entryIndex + 3]) & 0x0F);
whismanoid 0:3edb3708c8c5 5534 }
whismanoid 0:3edb3708c8c5 5535 //~ SPIwrite16bits(pack4channels);
whismanoid 0:3edb3708c8c5 5536 cmdLine.serial().printf(" 0x%4.4x", (pack4channels & 0xFFFF));
whismanoid 0:3edb3708c8c5 5537 // decode SAMPLESET channel select pattern
whismanoid 0:3edb3708c8c5 5538 cmdLine.serial().printf(" SampleSet Entry: AIN%d AIN%d AIN%d AIN%d\r\n",
whismanoid 0:3edb3708c8c5 5539 ((pack4channels >> 12) & 0x000F),
whismanoid 0:3edb3708c8c5 5540 ((pack4channels >> 8) & 0x000F),
whismanoid 0:3edb3708c8c5 5541 ((pack4channels >> 4) & 0x000F),
whismanoid 0:3edb3708c8c5 5542 ((pack4channels ) & 0x000F)
whismanoid 0:3edb3708c8c5 5543 );
whismanoid 0:3edb3708c8c5 5544 }
whismanoid 0:3edb3708c8c5 5545 //cmdLine.serial().printf(" SAMPLESET enabledChannelsPattern:{ ");
whismanoid 0:3edb3708c8c5 5546 //int index;
whismanoid 0:3edb3708c8c5 5547 //for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++)
whismanoid 0:3edb3708c8c5 5548 //{
whismanoid 0:3edb3708c8c5 5549 // //~ cmdLine.serial().printf( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC);
whismanoid 0:3edb3708c8c5 5550 // //~ cmdLine.serial().printf(" ");
whismanoid 0:3edb3708c8c5 5551 // cmdLine.serial().printf("AIN");
whismanoid 0:3edb3708c8c5 5552 // cmdLine.serial().printf( ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F), DEC);
whismanoid 0:3edb3708c8c5 5553 // cmdLine.serial().printf(" ");
whismanoid 0:3edb3708c8c5 5554 //}
whismanoid 0:3edb3708c8c5 5555 //cmdLine.serial().printf("}");
whismanoid 0:3edb3708c8c5 5556 //
whismanoid 0:3edb3708c8c5 5557 // Menu @) print MAX11131 configuration AND g_MAX11131_device globals
whismanoid 0:3edb3708c8c5 5558 //
whismanoid 0:3edb3708c8c5 5559 cmdLine.serial().printf("SPI_MOSI_Semantic=%d\r\n", (g_MAX11131_device.SPI_MOSI_Semantic & 0xFFFF));
whismanoid 0:3edb3708c8c5 5560 cmdLine.serial().printf("NumWords=%d\r\n", (g_MAX11131_device.NumWords & 0xFFFF));
whismanoid 0:3edb3708c8c5 5561 cmdLine.serial().printf("isExternalClock=%d\r\n", (g_MAX11131_device.isExternalClock & 0xFFFF));
whismanoid 0:3edb3708c8c5 5562 cmdLine.serial().printf("ScanMode=%d\r\n", (g_MAX11131_device.ScanMode & 0xFFFF));
whismanoid 0:3edb3708c8c5 5563 cmdLine.serial().printf("channelNumber_0_15=%d\r\n",
whismanoid 0:3edb3708c8c5 5564 (g_MAX11131_device.channelNumber_0_15 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5565 cmdLine.serial().printf("PowerManagement_0_2=%d\r\n",
whismanoid 0:3edb3708c8c5 5566 (g_MAX11131_device.PowerManagement_0_2 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5567 cmdLine.serial().printf("chan_id_0_1=%d\r\n", (g_MAX11131_device.chan_id_0_1 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5568 cmdLine.serial().printf("average_0_4_8_16_32=%d\r\n",
whismanoid 0:3edb3708c8c5 5569 (g_MAX11131_device.average_0_4_8_16_32 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5570 cmdLine.serial().printf("nscan_4_8_12_16=%d\r\n", (g_MAX11131_device.nscan_4_8_12_16 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5571 cmdLine.serial().printf("swcnv_0_1=%d\r\n", (g_MAX11131_device.swcnv_0_1 & 0xFFFF));
whismanoid 0:3edb3708c8c5 5572 cmdLine.serial().printf("enabledChannelsMask=0x%4.4x\r\n",
whismanoid 0:3edb3708c8c5 5573 (g_MAX11131_device.enabledChannelsMask & 0xFFFF));
whismanoid 0:3edb3708c8c5 5574 //
whismanoid 0:3edb3708c8c5 5575 cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX11131_device.VRef);
whismanoid 0:3edb3708c8c5 5576 // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB
whismanoid 0:3edb3708c8c5 5577 //
whismanoid 10:228a52f8107d 5578 return true; // command was handled by MAX11131
whismanoid 0:3edb3708c8c5 5579 }
whismanoid 0:3edb3708c8c5 5580 //case '&':
whismanoid 0:3edb3708c8c5 5581 //{
whismanoid 0:3edb3708c8c5 5582 // // TODO: cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual");
whismanoid 0:3edb3708c8c5 5583 //}
whismanoid 0:3edb3708c8c5 5584 break;
whismanoid 0:3edb3708c8c5 5585 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 0:3edb3708c8c5 5586 {
whismanoid 0:3edb3708c8c5 5587 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 5588 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5589 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5590 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5591 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5592 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5593 }
whismanoid 0:3edb3708c8c5 5594 break;
whismanoid 0:3edb3708c8c5 5595 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 0:3edb3708c8c5 5596 {
whismanoid 0:3edb3708c8c5 5597 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5598 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5599 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5600 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5601 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5602 }
whismanoid 0:3edb3708c8c5 5603 break;
whismanoid 10:228a52f8107d 5604 } // end switch (cmdLine[0])
whismanoid 10:228a52f8107d 5605 return false; // command not handled
whismanoid 10:228a52f8107d 5606 } // end bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 5607 #endif
whismanoid 0:3edb3708c8c5 5608
whismanoid 10:228a52f8107d 5609 //--------------------------------------------------
whismanoid 10:228a52f8107d 5610 #if 0 // APPLICATION_MAX5171 // MAX5171_menu_onEOLcommandParser moved to Test_Menu_MAX5171.cpp
whismanoid 10:228a52f8107d 5611 bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 5612 {
whismanoid 10:228a52f8107d 5613 switch (cmdLine[0])
whismanoid 10:228a52f8107d 5614 {
whismanoid 0:3edb3708c8c5 5615 case '0':
whismanoid 0:3edb3708c8c5 5616 {
whismanoid 0:3edb3708c8c5 5617 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5618 //~ cmdLine.serial().printf("\r\n 0 code=? -- CODE");
whismanoid 0:3edb3708c8c5 5619 uint16_t code;
whismanoid 0:3edb3708c8c5 5620 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 5621 {
whismanoid 0:3edb3708c8c5 5622 }
whismanoid 0:3edb3708c8c5 5623 cmdLine.serial().printf("CODE code=%d", code);
whismanoid 0:3edb3708c8c5 5624 g_MAX5171_device.CODE(code);
whismanoid 10:228a52f8107d 5625 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5626 }
whismanoid 0:3edb3708c8c5 5627 break;
whismanoid 0:3edb3708c8c5 5628 case '4':
whismanoid 0:3edb3708c8c5 5629 {
whismanoid 0:3edb3708c8c5 5630 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5631 //~ cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD");
whismanoid 0:3edb3708c8c5 5632 uint16_t code;
whismanoid 0:3edb3708c8c5 5633 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 5634 {
whismanoid 0:3edb3708c8c5 5635 }
whismanoid 0:3edb3708c8c5 5636 cmdLine.serial().printf("CODE_LOAD code=%d", code);
whismanoid 0:3edb3708c8c5 5637 g_MAX5171_device.CODE_LOAD(code);
whismanoid 10:228a52f8107d 5638 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5639 }
whismanoid 0:3edb3708c8c5 5640 break;
whismanoid 0:3edb3708c8c5 5641 case '8':
whismanoid 0:3edb3708c8c5 5642 {
whismanoid 0:3edb3708c8c5 5643 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5644 //~ cmdLine.serial().printf("\r\n 8 -- LOAD");
whismanoid 0:3edb3708c8c5 5645 cmdLine.serial().printf("LOAD");
whismanoid 0:3edb3708c8c5 5646 g_MAX5171_device.LOAD();
whismanoid 10:228a52f8107d 5647 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5648 }
whismanoid 0:3edb3708c8c5 5649 break;
whismanoid 0:3edb3708c8c5 5650 case 'c': case 'C':
whismanoid 0:3edb3708c8c5 5651 {
whismanoid 0:3edb3708c8c5 5652 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5653 //~ cmdLine.serial().printf("\r\n c -- NOP");
whismanoid 0:3edb3708c8c5 5654 cmdLine.serial().printf("NOP");
whismanoid 0:3edb3708c8c5 5655 g_MAX5171_device.NOP();
whismanoid 10:228a52f8107d 5656 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5657 }
whismanoid 0:3edb3708c8c5 5658 break;
whismanoid 0:3edb3708c8c5 5659 case 'd': case 'D':
whismanoid 0:3edb3708c8c5 5660 {
whismanoid 0:3edb3708c8c5 5661 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5662 //~ cmdLine.serial().printf("\r\n d -- SHUTDOWN");
whismanoid 0:3edb3708c8c5 5663 cmdLine.serial().printf("SHUTDOWN");
whismanoid 0:3edb3708c8c5 5664 g_MAX5171_device.SHUTDOWN();
whismanoid 10:228a52f8107d 5665 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5666 }
whismanoid 0:3edb3708c8c5 5667 break;
whismanoid 0:3edb3708c8c5 5668 case 'e': case 'E':
whismanoid 0:3edb3708c8c5 5669 {
whismanoid 0:3edb3708c8c5 5670 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5671 {
whismanoid 0:3edb3708c8c5 5672 case '0':
whismanoid 0:3edb3708c8c5 5673 {
whismanoid 0:3edb3708c8c5 5674 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5675 //~ cmdLine.serial().printf("\r\n e0 -- UPO_LOW");
whismanoid 0:3edb3708c8c5 5676 cmdLine.serial().printf("UPO_LOW");
whismanoid 0:3edb3708c8c5 5677 g_MAX5171_device.UPO_LOW();
whismanoid 10:228a52f8107d 5678 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5679 }
whismanoid 0:3edb3708c8c5 5680 break;
whismanoid 0:3edb3708c8c5 5681 case '8':
whismanoid 0:3edb3708c8c5 5682 {
whismanoid 0:3edb3708c8c5 5683 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5684 //~ cmdLine.serial().printf("\r\n e8 -- UPO_HIGH");
whismanoid 0:3edb3708c8c5 5685 cmdLine.serial().printf("UPO_HIGH");
whismanoid 0:3edb3708c8c5 5686 g_MAX5171_device.UPO_HIGH();
whismanoid 10:228a52f8107d 5687 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5688 }
whismanoid 0:3edb3708c8c5 5689 break;
whismanoid 0:3edb3708c8c5 5690 }
whismanoid 0:3edb3708c8c5 5691 }
whismanoid 0:3edb3708c8c5 5692 break;
whismanoid 0:3edb3708c8c5 5693 case 'f': case 'F':
whismanoid 0:3edb3708c8c5 5694 {
whismanoid 0:3edb3708c8c5 5695 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5696 {
whismanoid 0:3edb3708c8c5 5697 case '0':
whismanoid 0:3edb3708c8c5 5698 {
whismanoid 0:3edb3708c8c5 5699 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5700 //~ cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE");
whismanoid 0:3edb3708c8c5 5701 cmdLine.serial().printf("MODE1_DOUT_SCLK_RISING_EDGE");
whismanoid 0:3edb3708c8c5 5702 g_MAX5171_device.MODE1_DOUT_SCLK_RISING_EDGE();
whismanoid 10:228a52f8107d 5703 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5704 }
whismanoid 0:3edb3708c8c5 5705 break;
whismanoid 0:3edb3708c8c5 5706 case '8':
whismanoid 0:3edb3708c8c5 5707 {
whismanoid 0:3edb3708c8c5 5708 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5709 //~ cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE");
whismanoid 0:3edb3708c8c5 5710 cmdLine.serial().printf("MODE0_DOUT_SCLK_FALLING_EDGE");
whismanoid 0:3edb3708c8c5 5711 g_MAX5171_device.MODE0_DOUT_SCLK_FALLING_EDGE();
whismanoid 10:228a52f8107d 5712 return true; // command was handled by MAX5171
whismanoid 0:3edb3708c8c5 5713 }
whismanoid 0:3edb3708c8c5 5714 break;
whismanoid 0:3edb3708c8c5 5715 }
whismanoid 0:3edb3708c8c5 5716 }
whismanoid 0:3edb3708c8c5 5717 break;
whismanoid 0:3edb3708c8c5 5718 case 'a': case 'A':
whismanoid 0:3edb3708c8c5 5719 {
whismanoid 0:3edb3708c8c5 5720 // recommended for hex command codes A0..AF
whismanoid 0:3edb3708c8c5 5721 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5722 {
whismanoid 0:3edb3708c8c5 5723 case 't': case 'T':
whismanoid 0:3edb3708c8c5 5724 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5725 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5726 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5727 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5728 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 0:3edb3708c8c5 5729 return;
whismanoid 0:3edb3708c8c5 5730 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5731 }
whismanoid 0:3edb3708c8c5 5732 }
whismanoid 0:3edb3708c8c5 5733 break;
whismanoid 0:3edb3708c8c5 5734 case 'x': case 'X':
whismanoid 0:3edb3708c8c5 5735 {
whismanoid 0:3edb3708c8c5 5736 }
whismanoid 0:3edb3708c8c5 5737 break;
whismanoid 0:3edb3708c8c5 5738 case 'y': case 'Y':
whismanoid 0:3edb3708c8c5 5739 {
whismanoid 0:3edb3708c8c5 5740 }
whismanoid 0:3edb3708c8c5 5741 break;
whismanoid 0:3edb3708c8c5 5742 case 'z': case 'Z':
whismanoid 0:3edb3708c8c5 5743 {
whismanoid 0:3edb3708c8c5 5744 }
whismanoid 0:3edb3708c8c5 5745 break;
whismanoid 0:3edb3708c8c5 5746 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 0:3edb3708c8c5 5747 {
whismanoid 0:3edb3708c8c5 5748 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 5749 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5750 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5751 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5752 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5753 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5754 }
whismanoid 0:3edb3708c8c5 5755 break;
whismanoid 0:3edb3708c8c5 5756 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 0:3edb3708c8c5 5757 {
whismanoid 0:3edb3708c8c5 5758 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5759 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5760 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5761 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5762 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5763 }
whismanoid 0:3edb3708c8c5 5764 break;
whismanoid 10:228a52f8107d 5765 } // end switch (cmdLine[0])
whismanoid 10:228a52f8107d 5766 return false; // command not handled
whismanoid 10:228a52f8107d 5767 } // end bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 5768 #endif
whismanoid 0:3edb3708c8c5 5769
whismanoid 10:228a52f8107d 5770 //--------------------------------------------------
whismanoid 10:228a52f8107d 5771 #if 0 // APPLICATION_MAX11410 // MAX11410_menu_onEOLcommandParser moved to Test_Menu_MAX11410.cpp
whismanoid 10:228a52f8107d 5772 bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 5773 {
whismanoid 10:228a52f8107d 5774 switch (cmdLine[0])
whismanoid 10:228a52f8107d 5775 {
whismanoid 0:3edb3708c8c5 5776 // TODO1: MAX11410 main_menu_onEOLcommandParser
whismanoid 0:3edb3708c8c5 5777 case '0':
whismanoid 0:3edb3708c8c5 5778 {
whismanoid 0:3edb3708c8c5 5779 // recommended for hex command codes 00..0F
whismanoid 0:3edb3708c8c5 5780 // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn");
whismanoid 0:3edb3708c8c5 5781 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 5782 uint16_t code;
whismanoid 0:3edb3708c8c5 5783 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 5784 {
whismanoid 0:3edb3708c8c5 5785 }
whismanoid 0:3edb3708c8c5 5786 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 5787 {
whismanoid 0:3edb3708c8c5 5788 }
whismanoid 0:3edb3708c8c5 5789 if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG))
whismanoid 0:3edb3708c8c5 5790 {
whismanoid 0:3edb3708c8c5 5791 isUpdatedSPIConfig = true;
whismanoid 0:3edb3708c8c5 5792 }
whismanoid 0:3edb3708c8c5 5793 cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 5794 MAX5715_CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 5795 cmdLine.serial().printf("\r\n placeholder");
whismanoid 10:228a52f8107d 5796 return true; // command was handled by MAX11410
whismanoid 0:3edb3708c8c5 5797 }
whismanoid 0:3edb3708c8c5 5798 break;
whismanoid 0:3edb3708c8c5 5799 case '1':
whismanoid 0:3edb3708c8c5 5800 {
whismanoid 0:3edb3708c8c5 5801 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5802 }
whismanoid 0:3edb3708c8c5 5803 break;
whismanoid 0:3edb3708c8c5 5804 case '2':
whismanoid 0:3edb3708c8c5 5805 {
whismanoid 0:3edb3708c8c5 5806 // recommended for hex command codes 20..2F
whismanoid 0:3edb3708c8c5 5807 }
whismanoid 0:3edb3708c8c5 5808 break;
whismanoid 0:3edb3708c8c5 5809 case '3':
whismanoid 0:3edb3708c8c5 5810 {
whismanoid 0:3edb3708c8c5 5811 // recommended for hex command codes 30..3F
whismanoid 0:3edb3708c8c5 5812 }
whismanoid 0:3edb3708c8c5 5813 break;
whismanoid 0:3edb3708c8c5 5814 case '4':
whismanoid 0:3edb3708c8c5 5815 {
whismanoid 0:3edb3708c8c5 5816 // recommended for hex command codes 40..4F
whismanoid 0:3edb3708c8c5 5817 }
whismanoid 0:3edb3708c8c5 5818 break;
whismanoid 0:3edb3708c8c5 5819 case '5':
whismanoid 0:3edb3708c8c5 5820 {
whismanoid 0:3edb3708c8c5 5821 // recommended for hex command codes 50..5F
whismanoid 0:3edb3708c8c5 5822 }
whismanoid 0:3edb3708c8c5 5823 break;
whismanoid 0:3edb3708c8c5 5824 case '6':
whismanoid 0:3edb3708c8c5 5825 {
whismanoid 0:3edb3708c8c5 5826 // recommended for hex command codes 60..6F
whismanoid 0:3edb3708c8c5 5827 }
whismanoid 0:3edb3708c8c5 5828 break;
whismanoid 0:3edb3708c8c5 5829 case '7':
whismanoid 0:3edb3708c8c5 5830 {
whismanoid 0:3edb3708c8c5 5831 // recommended for hex command codes 70..7F
whismanoid 0:3edb3708c8c5 5832 }
whismanoid 0:3edb3708c8c5 5833 break;
whismanoid 0:3edb3708c8c5 5834 case '8':
whismanoid 0:3edb3708c8c5 5835 {
whismanoid 0:3edb3708c8c5 5836 // recommended for hex command codes 80..8F
whismanoid 0:3edb3708c8c5 5837 }
whismanoid 0:3edb3708c8c5 5838 break;
whismanoid 0:3edb3708c8c5 5839 case '9':
whismanoid 0:3edb3708c8c5 5840 {
whismanoid 0:3edb3708c8c5 5841 // recommended for hex command codes 90..9F
whismanoid 0:3edb3708c8c5 5842 }
whismanoid 0:3edb3708c8c5 5843 break;
whismanoid 0:3edb3708c8c5 5844 case 'a': case 'A':
whismanoid 0:3edb3708c8c5 5845 {
whismanoid 0:3edb3708c8c5 5846 // recommended for hex command codes A0..AF
whismanoid 0:3edb3708c8c5 5847 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 5848 {
whismanoid 0:3edb3708c8c5 5849 case 't': case 'T':
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 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 0:3edb3708c8c5 5855 return;
whismanoid 0:3edb3708c8c5 5856 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5857 }
whismanoid 0:3edb3708c8c5 5858 }
whismanoid 0:3edb3708c8c5 5859 break;
whismanoid 0:3edb3708c8c5 5860 case 'b': case 'B':
whismanoid 0:3edb3708c8c5 5861 {
whismanoid 0:3edb3708c8c5 5862 // recommended for hex command codes B0..BF
whismanoid 0:3edb3708c8c5 5863 }
whismanoid 0:3edb3708c8c5 5864 break;
whismanoid 0:3edb3708c8c5 5865 case 'c': case 'C':
whismanoid 0:3edb3708c8c5 5866 {
whismanoid 0:3edb3708c8c5 5867 // recommended for hex command codes C0..CF
whismanoid 0:3edb3708c8c5 5868 }
whismanoid 0:3edb3708c8c5 5869 break;
whismanoid 0:3edb3708c8c5 5870 case 'd': case 'D':
whismanoid 0:3edb3708c8c5 5871 {
whismanoid 0:3edb3708c8c5 5872 // recommended for hex command codes D0..DF
whismanoid 0:3edb3708c8c5 5873 }
whismanoid 0:3edb3708c8c5 5874 break;
whismanoid 0:3edb3708c8c5 5875 case 'e': case 'E':
whismanoid 0:3edb3708c8c5 5876 {
whismanoid 0:3edb3708c8c5 5877 // recommended for hex command codes E0..EF
whismanoid 0:3edb3708c8c5 5878 }
whismanoid 0:3edb3708c8c5 5879 break;
whismanoid 0:3edb3708c8c5 5880 case 'f': case 'F':
whismanoid 0:3edb3708c8c5 5881 {
whismanoid 0:3edb3708c8c5 5882 // recommended for hex command codes F0..FF
whismanoid 0:3edb3708c8c5 5883 }
whismanoid 0:3edb3708c8c5 5884 break;
whismanoid 0:3edb3708c8c5 5885 case 'x': case 'X':
whismanoid 0:3edb3708c8c5 5886 {
whismanoid 0:3edb3708c8c5 5887 }
whismanoid 0:3edb3708c8c5 5888 break;
whismanoid 0:3edb3708c8c5 5889 case 'y': case 'Y':
whismanoid 0:3edb3708c8c5 5890 {
whismanoid 0:3edb3708c8c5 5891 }
whismanoid 0:3edb3708c8c5 5892 break;
whismanoid 0:3edb3708c8c5 5893 case 'z': case 'Z':
whismanoid 0:3edb3708c8c5 5894 {
whismanoid 0:3edb3708c8c5 5895 }
whismanoid 0:3edb3708c8c5 5896 break;
whismanoid 0:3edb3708c8c5 5897 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 0:3edb3708c8c5 5898 {
whismanoid 0:3edb3708c8c5 5899 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 5900 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5901 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5902 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5903 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5904 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5905 }
whismanoid 0:3edb3708c8c5 5906 break;
whismanoid 0:3edb3708c8c5 5907 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 0:3edb3708c8c5 5908 {
whismanoid 0:3edb3708c8c5 5909 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5910 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5911 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 5912 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 5913 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 5914 }
whismanoid 0:3edb3708c8c5 5915 break;
whismanoid 10:228a52f8107d 5916 } // end switch (cmdLine[0])
whismanoid 10:228a52f8107d 5917 return false; // command not handled
whismanoid 10:228a52f8107d 5918 } // end bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 5919 #endif
whismanoid 0:3edb3708c8c5 5920
whismanoid 0:3edb3708c8c5 5921
whismanoid 10:228a52f8107d 5922 //--------------------------------------------------
whismanoid 10:228a52f8107d 5923 #if APPLICATION_MAX12345 // MAX12345_menu_onEOLcommandParser
whismanoid 10:228a52f8107d 5924 bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 5925 {
whismanoid 10:228a52f8107d 5926 switch (cmdLine[0])
whismanoid 10:228a52f8107d 5927 {
whismanoid 10:228a52f8107d 5928 // TODO1: MAX12345 main_menu_onEOLcommandParser
whismanoid 0:3edb3708c8c5 5929 case '0':
whismanoid 0:3edb3708c8c5 5930 {
whismanoid 0:3edb3708c8c5 5931 // recommended for hex command codes 00..0F
whismanoid 0:3edb3708c8c5 5932 // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn");
whismanoid 0:3edb3708c8c5 5933 uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 0:3edb3708c8c5 5934 uint16_t code;
whismanoid 0:3edb3708c8c5 5935 if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 0:3edb3708c8c5 5936 {
whismanoid 0:3edb3708c8c5 5937 }
whismanoid 0:3edb3708c8c5 5938 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 0:3edb3708c8c5 5939 {
whismanoid 0:3edb3708c8c5 5940 }
whismanoid 0:3edb3708c8c5 5941 if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG))
whismanoid 0:3edb3708c8c5 5942 {
whismanoid 0:3edb3708c8c5 5943 isUpdatedSPIConfig = true;
whismanoid 0:3edb3708c8c5 5944 }
whismanoid 0:3edb3708c8c5 5945 cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 0:3edb3708c8c5 5946 MAX5715_CODEnLOADn(ch, code);
whismanoid 0:3edb3708c8c5 5947 cmdLine.serial().printf("\r\n placeholder");
whismanoid 10:228a52f8107d 5948 return true; // command was handled by MAX12345
whismanoid 0:3edb3708c8c5 5949 }
whismanoid 0:3edb3708c8c5 5950 break;
whismanoid 0:3edb3708c8c5 5951 case '1':
whismanoid 0:3edb3708c8c5 5952 {
whismanoid 0:3edb3708c8c5 5953 // recommended for hex command codes 10..1F
whismanoid 0:3edb3708c8c5 5954 }
whismanoid 0:3edb3708c8c5 5955 break;
whismanoid 0:3edb3708c8c5 5956 case '2':
whismanoid 0:3edb3708c8c5 5957 {
whismanoid 0:3edb3708c8c5 5958 // recommended for hex command codes 20..2F
whismanoid 0:3edb3708c8c5 5959 }
whismanoid 0:3edb3708c8c5 5960 break;
whismanoid 0:3edb3708c8c5 5961 case '3':
whismanoid 0:3edb3708c8c5 5962 {
whismanoid 0:3edb3708c8c5 5963 // recommended for hex command codes 30..3F
whismanoid 0:3edb3708c8c5 5964 }
whismanoid 0:3edb3708c8c5 5965 break;
whismanoid 0:3edb3708c8c5 5966 case '4':
whismanoid 0:3edb3708c8c5 5967 {
whismanoid 0:3edb3708c8c5 5968 // recommended for hex command codes 40..4F
whismanoid 0:3edb3708c8c5 5969 }
whismanoid 0:3edb3708c8c5 5970 break;
whismanoid 0:3edb3708c8c5 5971 case '5':
whismanoid 0:3edb3708c8c5 5972 {
whismanoid 0:3edb3708c8c5 5973 // recommended for hex command codes 50..5F
whismanoid 0:3edb3708c8c5 5974 }
whismanoid 0:3edb3708c8c5 5975 break;
whismanoid 0:3edb3708c8c5 5976 case '6':
whismanoid 0:3edb3708c8c5 5977 {
whismanoid 0:3edb3708c8c5 5978 // recommended for hex command codes 60..6F
whismanoid 0:3edb3708c8c5 5979 }
whismanoid 0:3edb3708c8c5 5980 break;
whismanoid 0:3edb3708c8c5 5981 case '7':
whismanoid 0:3edb3708c8c5 5982 {
whismanoid 0:3edb3708c8c5 5983 // recommended for hex command codes 70..7F
whismanoid 0:3edb3708c8c5 5984 }
whismanoid 0:3edb3708c8c5 5985 break;
whismanoid 0:3edb3708c8c5 5986 case '8':
whismanoid 0:3edb3708c8c5 5987 {
whismanoid 0:3edb3708c8c5 5988 // recommended for hex command codes 80..8F
whismanoid 0:3edb3708c8c5 5989 }
whismanoid 0:3edb3708c8c5 5990 break;
whismanoid 0:3edb3708c8c5 5991 case '9':
whismanoid 0:3edb3708c8c5 5992 {
whismanoid 0:3edb3708c8c5 5993 // recommended for hex command codes 90..9F
whismanoid 0:3edb3708c8c5 5994 }
whismanoid 0:3edb3708c8c5 5995 break;
whismanoid 0:3edb3708c8c5 5996 case 'a': case 'A':
whismanoid 0:3edb3708c8c5 5997 {
whismanoid 0:3edb3708c8c5 5998 // recommended for hex command codes A0..AF
whismanoid 0:3edb3708c8c5 5999 switch (cmdLine[1])
whismanoid 0:3edb3708c8c5 6000 {
whismanoid 0:3edb3708c8c5 6001 case 't': case 'T':
whismanoid 0:3edb3708c8c5 6002 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6003 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6004 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6005 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6006 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 0:3edb3708c8c5 6007 return;
whismanoid 0:3edb3708c8c5 6008 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6009 }
whismanoid 0:3edb3708c8c5 6010 }
whismanoid 0:3edb3708c8c5 6011 break;
whismanoid 0:3edb3708c8c5 6012 case 'b': case 'B':
whismanoid 0:3edb3708c8c5 6013 {
whismanoid 0:3edb3708c8c5 6014 // recommended for hex command codes B0..BF
whismanoid 0:3edb3708c8c5 6015 }
whismanoid 0:3edb3708c8c5 6016 break;
whismanoid 0:3edb3708c8c5 6017 case 'c': case 'C':
whismanoid 0:3edb3708c8c5 6018 {
whismanoid 0:3edb3708c8c5 6019 // recommended for hex command codes C0..CF
whismanoid 0:3edb3708c8c5 6020 }
whismanoid 0:3edb3708c8c5 6021 break;
whismanoid 0:3edb3708c8c5 6022 case 'd': case 'D':
whismanoid 0:3edb3708c8c5 6023 {
whismanoid 0:3edb3708c8c5 6024 // recommended for hex command codes D0..DF
whismanoid 0:3edb3708c8c5 6025 }
whismanoid 0:3edb3708c8c5 6026 break;
whismanoid 0:3edb3708c8c5 6027 case 'e': case 'E':
whismanoid 0:3edb3708c8c5 6028 {
whismanoid 0:3edb3708c8c5 6029 // recommended for hex command codes E0..EF
whismanoid 0:3edb3708c8c5 6030 }
whismanoid 0:3edb3708c8c5 6031 break;
whismanoid 0:3edb3708c8c5 6032 case 'f': case 'F':
whismanoid 0:3edb3708c8c5 6033 {
whismanoid 0:3edb3708c8c5 6034 // recommended for hex command codes F0..FF
whismanoid 0:3edb3708c8c5 6035 }
whismanoid 0:3edb3708c8c5 6036 break;
whismanoid 0:3edb3708c8c5 6037 case 'x': case 'X':
whismanoid 0:3edb3708c8c5 6038 {
whismanoid 0:3edb3708c8c5 6039 }
whismanoid 0:3edb3708c8c5 6040 break;
whismanoid 0:3edb3708c8c5 6041 case 'y': case 'Y':
whismanoid 0:3edb3708c8c5 6042 {
whismanoid 0:3edb3708c8c5 6043 }
whismanoid 0:3edb3708c8c5 6044 break;
whismanoid 0:3edb3708c8c5 6045 case 'z': case 'Z':
whismanoid 0:3edb3708c8c5 6046 {
whismanoid 0:3edb3708c8c5 6047 }
whismanoid 0:3edb3708c8c5 6048 break;
whismanoid 0:3edb3708c8c5 6049 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 0:3edb3708c8c5 6050 {
whismanoid 0:3edb3708c8c5 6051 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 0:3edb3708c8c5 6052 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6053 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6054 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6055 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6056 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6057 }
whismanoid 0:3edb3708c8c5 6058 break;
whismanoid 0:3edb3708c8c5 6059 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 0:3edb3708c8c5 6060 {
whismanoid 0:3edb3708c8c5 6061 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6062 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6063 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 0:3edb3708c8c5 6064 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6065 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6066 }
whismanoid 0:3edb3708c8c5 6067 break;
whismanoid 10:228a52f8107d 6068 } // end switch (cmdLine[0])
whismanoid 10:228a52f8107d 6069 return false; // command not handled
whismanoid 10:228a52f8107d 6070 } // end bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 6071 #endif
whismanoid 10:228a52f8107d 6072
whismanoid 10:228a52f8107d 6073
whismanoid 10:228a52f8107d 6074 //--------------------------------------------------
whismanoid 10:228a52f8107d 6075 // main menu command-line parser
whismanoid 10:228a52f8107d 6076 // invoked by CmdLine::append(char ch) or CmdLine::idleAppendIfReadable()
whismanoid 10:228a52f8107d 6077 void main_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 10:228a52f8107d 6078 {
whismanoid 10:228a52f8107d 6079 // DIAGNOSTIC: print line buffer
whismanoid 10:228a52f8107d 6080 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 10:228a52f8107d 6081 //
whismanoid 10:228a52f8107d 6082 switch (cmdLine[0])
whismanoid 10:228a52f8107d 6083 {
whismanoid 10:228a52f8107d 6084 case '?':
whismanoid 10:228a52f8107d 6085 main_menu_status(cmdLine);
whismanoid 10:228a52f8107d 6086 main_menu_help(cmdLine);
whismanoid 10:228a52f8107d 6087 // print command prompt
whismanoid 10:228a52f8107d 6088 //cmdLine.serial().printf("\r\n>");
whismanoid 10:228a52f8107d 6089 break;
whismanoid 10:228a52f8107d 6090 case '\r': case '\n': // ignore blank line
whismanoid 10:228a52f8107d 6091 case '\0': // ignore empty line
whismanoid 10:228a52f8107d 6092 case '#': // ignore comment line
whismanoid 10:228a52f8107d 6093 // # -- lines beginning with # are comments
whismanoid 10:228a52f8107d 6094 main_menu_status(cmdLine);
whismanoid 10:228a52f8107d 6095 //~ main_menu_help(cmdLine);
whismanoid 10:228a52f8107d 6096 // print command prompt
whismanoid 10:228a52f8107d 6097 //cmdLine.serial().printf("\r\n>");
whismanoid 10:228a52f8107d 6098 break;
whismanoid 10:228a52f8107d 6099 #if ECHO_EOF_ON_EOL
whismanoid 10:228a52f8107d 6100 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 10:228a52f8107d 6101 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 10:228a52f8107d 6102 diagnostic_led_EOF();
whismanoid 10:228a52f8107d 6103 break;
whismanoid 10:228a52f8107d 6104 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 10:228a52f8107d 6105 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 10:228a52f8107d 6106 diagnostic_led_EOF();
whismanoid 10:228a52f8107d 6107 break;
whismanoid 10:228a52f8107d 6108 #endif
whismanoid 10:228a52f8107d 6109 #if APPLICATION_ArduinoPinsMonitor
whismanoid 10:228a52f8107d 6110 case '.':
whismanoid 10:228a52f8107d 6111 {
whismanoid 10:228a52f8107d 6112 // . -- SelfTest
whismanoid 10:228a52f8107d 6113 cmdLine.serial().printf("SelfTest()");
whismanoid 10:228a52f8107d 6114 SelfTest(cmdLine);
whismanoid 10:228a52f8107d 6115 }
whismanoid 10:228a52f8107d 6116 break;
whismanoid 10:228a52f8107d 6117 case '%':
whismanoid 10:228a52f8107d 6118 {
whismanoid 10:228a52f8107d 6119 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 10:228a52f8107d 6120 }
whismanoid 10:228a52f8107d 6121 break; // case '%'
whismanoid 10:228a52f8107d 6122 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 10:228a52f8107d 6123 //
whismanoid 10:228a52f8107d 6124 // Application-specific commands here
whismanoid 10:228a52f8107d 6125 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 10:228a52f8107d 6126 //
whismanoid 10:228a52f8107d 6127 #if APPLICATION_ArduinoPinsMonitor
whismanoid 10:228a52f8107d 6128 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 0:3edb3708c8c5 6129
whismanoid 0:3edb3708c8c5 6130 //
whismanoid 0:3edb3708c8c5 6131 // TODO1: add new commands here
whismanoid 0:3edb3708c8c5 6132 //
whismanoid 0:3edb3708c8c5 6133 default:
whismanoid 10:228a52f8107d 6134 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 10:228a52f8107d 6135 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 10:228a52f8107d 6136 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 10:228a52f8107d 6137 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 10:228a52f8107d 6138 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 10:228a52f8107d 6139 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 10:228a52f8107d 6140 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 10:228a52f8107d 6141 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 10:228a52f8107d 6142 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 10:228a52f8107d 6143 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 10:228a52f8107d 6144 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 10:228a52f8107d 6145 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 10:228a52f8107d 6146 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 10:228a52f8107d 6147 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 10:228a52f8107d 6148 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 10:228a52f8107d 6149 #else
whismanoid 10:228a52f8107d 6150 if (0) // not_handled_by_device_submenu
whismanoid 10:228a52f8107d 6151 #endif
whismanoid 10:228a52f8107d 6152 {
whismanoid 10:228a52f8107d 6153 cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 0:3edb3708c8c5 6154 # if HAS_DAPLINK_SERIAL
whismanoid 10:228a52f8107d 6155 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 10:228a52f8107d 6156 cmdLine.str()[0], cmdLine.str());
whismanoid 0:3edb3708c8c5 6157 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:228a52f8107d 6158 }
whismanoid 0:3edb3708c8c5 6159 } // switch (cmdLine[0])
whismanoid 0:3edb3708c8c5 6160 //
whismanoid 0:3edb3708c8c5 6161 // print command prompt
whismanoid 0:3edb3708c8c5 6162 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 0:3edb3708c8c5 6163 cmdLine.serial().printf("\r\nMAX5715 > ");
whismanoid 0:3edb3708c8c5 6164 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 0:3edb3708c8c5 6165 cmdLine.serial().printf("\r\nMAX11131 > ");
whismanoid 0:3edb3708c8c5 6166 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 0:3edb3708c8c5 6167 cmdLine.serial().printf("\r\nMAX5171 > ");
whismanoid 0:3edb3708c8c5 6168 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 0:3edb3708c8c5 6169 cmdLine.serial().printf("\r\nMAX11410 > ");
whismanoid 0:3edb3708c8c5 6170 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 0:3edb3708c8c5 6171 cmdLine.serial().printf("\r\nMAX12345 > ");
whismanoid 0:3edb3708c8c5 6172 #else
whismanoid 0:3edb3708c8c5 6173 cmdLine.serial().printf("\r\n> ");
whismanoid 0:3edb3708c8c5 6174 #endif
whismanoid 10:228a52f8107d 6175 } // end void main_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 0:3edb3708c8c5 6176
whismanoid 0:3edb3708c8c5 6177 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6178 void InitializeConfiguration()
whismanoid 0:3edb3708c8c5 6179 {
whismanoid 0:3edb3708c8c5 6180
whismanoid 0:3edb3708c8c5 6181 #if APPLICATION_MAX5715 // InitializeConfiguration
whismanoid 0:3edb3708c8c5 6182 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6183 cmdLine_DAPLINKserial.serial().printf("\r\nMAX5715_Init()");
whismanoid 0:3edb3708c8c5 6184 # endif
whismanoid 7:bf501f8cb637 6185 cmdLine_serial.serial().printf("\r\nMAX5715_Init()");
whismanoid 0:3edb3708c8c5 6186 int initResult = g_MAX5715_device.Init(); // defined in #include MAX5715.h
whismanoid 0:3edb3708c8c5 6187 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6188 cmdLine_DAPLINKserial.serial().printf("\r\nMAX5715_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6189 # endif
whismanoid 7:bf501f8cb637 6190 cmdLine_serial.serial().printf("\r\nMAX5715_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6191 #endif // APPLICATION_MAX5715
whismanoid 0:3edb3708c8c5 6192
whismanoid 0:3edb3708c8c5 6193 #if APPLICATION_MAX11131 // InitializeConfiguration
whismanoid 0:3edb3708c8c5 6194 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6195 cmdLine_DAPLINKserial.serial().printf("\r\nMAX11131_Init()");
whismanoid 0:3edb3708c8c5 6196 # endif
whismanoid 7:bf501f8cb637 6197 cmdLine_serial.serial().printf("\r\nMAX11131_Init()");
whismanoid 0:3edb3708c8c5 6198 g_MAX11131_device.Init(); // defined in #include MAX11131.h
whismanoid 0:3edb3708c8c5 6199 #endif // APPLICATION_MAX11131
whismanoid 0:3edb3708c8c5 6200
whismanoid 0:3edb3708c8c5 6201 #if APPLICATION_MAX5171 // InitializeConfiguration
whismanoid 0:3edb3708c8c5 6202 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6203 cmdLine_DAPLINKserial.serial().printf("\r\nMAX5171_Init()");
whismanoid 0:3edb3708c8c5 6204 # endif
whismanoid 7:bf501f8cb637 6205 cmdLine_serial.serial().printf("\r\nMAX5171_Init()");
whismanoid 0:3edb3708c8c5 6206 int initResult = g_MAX5171_device.Init(); // defined in #include MAX5171.h
whismanoid 0:3edb3708c8c5 6207 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6208 cmdLine_DAPLINKserial.serial().printf("\r\nMAX5171_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6209 # endif
whismanoid 7:bf501f8cb637 6210 cmdLine_serial.serial().printf("\r\nMAX5171_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6211 #endif // APPLICATION_MAX5171
whismanoid 0:3edb3708c8c5 6212
whismanoid 0:3edb3708c8c5 6213 #if APPLICATION_MAX11410 // InitializeConfiguration
whismanoid 0:3edb3708c8c5 6214 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6215 cmdLine_DAPLINKserial.serial().printf("\r\nMAX11410_Init()");
whismanoid 0:3edb3708c8c5 6216 # endif
whismanoid 7:bf501f8cb637 6217 cmdLine_serial.serial().printf("\r\nMAX11410_Init()");
whismanoid 0:3edb3708c8c5 6218 int initResult = g_MAX11410_device.Init(); // defined in #include MAX11410.h
whismanoid 0:3edb3708c8c5 6219 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6220 cmdLine_DAPLINKserial.serial().printf("\r\nMAX11410_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6221 # endif
whismanoid 7:bf501f8cb637 6222 cmdLine_serial.serial().printf("\r\nMAX11410_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6223 #endif // APPLICATION_MAX11410
whismanoid 0:3edb3708c8c5 6224
whismanoid 0:3edb3708c8c5 6225 #if APPLICATION_MAX12345 // InitializeConfiguration
whismanoid 0:3edb3708c8c5 6226 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6227 cmdLine_DAPLINKserial.serial().printf("\r\nMAX12345_Init()");
whismanoid 0:3edb3708c8c5 6228 # endif
whismanoid 7:bf501f8cb637 6229 cmdLine_serial.serial().printf("\r\nMAX12345_Init()");
whismanoid 0:3edb3708c8c5 6230 int initResult = MAX12345_Init(); // defined in #include MAX12345.h
whismanoid 0:3edb3708c8c5 6231 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6232 cmdLine_DAPLINKserial.serial().printf("\r\nMAX12345_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6233 # endif
whismanoid 7:bf501f8cb637 6234 cmdLine_serial.serial().printf("\r\nMAX12345_Init() returned %d\r\n", initResult);
whismanoid 0:3edb3708c8c5 6235 #endif // APPLICATION_MAX12345
whismanoid 0:3edb3708c8c5 6236
whismanoid 0:3edb3708c8c5 6237 }
whismanoid 0:3edb3708c8c5 6238
whismanoid 0:3edb3708c8c5 6239 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6240 // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 6241 void diagnostic_led_EOF()
whismanoid 0:3edb3708c8c5 6242 {
whismanoid 0:3edb3708c8c5 6243 #if USE_LEDS
whismanoid 0:3edb3708c8c5 6244 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 6245 // 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 6246 ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250);
whismanoid 0:3edb3708c8c5 6247 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 6248 ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250);
whismanoid 0:3edb3708c8c5 6249 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 6250 ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250);
whismanoid 0:3edb3708c8c5 6251 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 6252 ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250);
whismanoid 0:3edb3708c8c5 6253 #endif // USE_LEDS
whismanoid 0:3edb3708c8c5 6254 }
whismanoid 0:3edb3708c8c5 6255
whismanoid 0:3edb3708c8c5 6256 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6257 // Support commands that get handled immediately w/o waiting for EOL
whismanoid 0:3edb3708c8c5 6258 // handled as immediate command, do not append to buffer
whismanoid 0:3edb3708c8c5 6259 void on_immediate_0x21() // Unicode (U+0021) ! EXCLAMATION MARK
whismanoid 0:3edb3708c8c5 6260 {
whismanoid 0:3edb3708c8c5 6261 #if USE_LEDS
whismanoid 0:3edb3708c8c5 6262 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 6263 #endif // USE_LEDS
whismanoid 0:3edb3708c8c5 6264 InitializeConfiguration();
whismanoid 0:3edb3708c8c5 6265 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6266 }
whismanoid 0:3edb3708c8c5 6267
whismanoid 0:3edb3708c8c5 6268 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6269 // Support commands that get handled immediately w/o waiting for EOL
whismanoid 0:3edb3708c8c5 6270 // handled as immediate command, do not append to buffer
whismanoid 0:3edb3708c8c5 6271 void on_immediate_0x7b() // Unicode (U+007B) { LEFT CURLY BRACKET
whismanoid 0:3edb3708c8c5 6272 {
whismanoid 0:3edb3708c8c5 6273 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6274 onButton2FallingEdge();
whismanoid 0:3edb3708c8c5 6275 #endif
whismanoid 0:3edb3708c8c5 6276 }
whismanoid 0:3edb3708c8c5 6277
whismanoid 0:3edb3708c8c5 6278 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6279 // Support commands that get handled immediately w/o waiting for EOL
whismanoid 0:3edb3708c8c5 6280 // handled as immediate command, do not append to buffer
whismanoid 0:3edb3708c8c5 6281 void on_immediate_0x7d() // Unicode (U+007D) } RIGHT CURLY BRACKET
whismanoid 0:3edb3708c8c5 6282 {
whismanoid 0:3edb3708c8c5 6283 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6284 onButton1FallingEdge();
whismanoid 0:3edb3708c8c5 6285 #endif
whismanoid 0:3edb3708c8c5 6286 }
whismanoid 0:3edb3708c8c5 6287
whismanoid 0:3edb3708c8c5 6288 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6289 // based on example code: https://os.mbed.com/docs/v5.7/reference/pwmout.html
whismanoid 0:3edb3708c8c5 6290 int main()
whismanoid 0:3edb3708c8c5 6291 {
whismanoid 0:3edb3708c8c5 6292 // Configure serial ports
whismanoid 0:3edb3708c8c5 6293 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 6294 // Note: DAPLINKserial interferes with the timer tick interrupt. Try faster baud rate?
whismanoid 0:3edb3708c8c5 6295 DAPLINKserial.baud(115200); // default 9600 baud
whismanoid 7:bf501f8cb637 6296 //serial.baud(9600); // class USBSerial has no baud function
whismanoid 0:3edb3708c8c5 6297 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6298 DAPLINKserial.printf("\r\n\r\nDAPLINK_SERIAL: main() startup\r\n");
whismanoid 0:3edb3708c8c5 6299 # endif
whismanoid 0:3edb3708c8c5 6300 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6301 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 6302 // MAX32625MBED crash if DAPLINKserial.baud(anything other than 9600 baud)
whismanoid 0:3edb3708c8c5 6303 // xxx DAPLINKserial.baud(115200); // default 9600 baud
whismanoid 7:bf501f8cb637 6304 //serial.baud(9600); // class USBSerial has no baud function
whismanoid 0:3edb3708c8c5 6305 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6306 DAPLINKserial.printf("\r\n\r\nDAPLINK_SERIAL: main() startup\r\n");
whismanoid 0:3edb3708c8c5 6307 # endif
whismanoid 0:3edb3708c8c5 6308 //--------------------------------------------------
whismanoid 0:3edb3708c8c5 6309 #elif defined(TARGET_LPC1768)
whismanoid 7:bf501f8cb637 6310 serial.baud(115200); // default 9600 baud
whismanoid 0:3edb3708c8c5 6311 #else
whismanoid 0:3edb3708c8c5 6312 // unknown target
whismanoid 0:3edb3708c8c5 6313 #endif
whismanoid 7:bf501f8cb637 6314 cmdLine_serial.clear();
whismanoid 7:bf501f8cb637 6315 //~ cmdLine_serial.serial().printf("\r\n cmdLine_serial.serial().printf test\r\n");
whismanoid 7:bf501f8cb637 6316 cmdLine_serial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 0:3edb3708c8c5 6317 /// @todo CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 7:bf501f8cb637 6318 cmdLine_serial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 7:bf501f8cb637 6319 cmdLine_serial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 7:bf501f8cb637 6320 cmdLine_serial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 0:3edb3708c8c5 6321 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6322 cmdLine_DAPLINKserial.clear();
whismanoid 0:3edb3708c8c5 6323 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 0:3edb3708c8c5 6324 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 0:3edb3708c8c5 6325 /// @todo CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 0:3edb3708c8c5 6326 cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 0:3edb3708c8c5 6327 cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 0:3edb3708c8c5 6328 cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 0:3edb3708c8c5 6329 # endif
whismanoid 0:3edb3708c8c5 6330
whismanoid 0:3edb3708c8c5 6331
whismanoid 0:3edb3708c8c5 6332 print_banner();
whismanoid 0:3edb3708c8c5 6333
whismanoid 0:3edb3708c8c5 6334 //#ifdef SCOPE_TRIG_PIN
whismanoid 0:3edb3708c8c5 6335 // scopePinP12 = 0;
whismanoid 0:3edb3708c8c5 6336 // scopePinP12 = 1;
whismanoid 0:3edb3708c8c5 6337 //#endif // SCOPE_TRIG_PIN
whismanoid 0:3edb3708c8c5 6338
whismanoid 0:3edb3708c8c5 6339 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6340 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 6341 # else
whismanoid 0:3edb3708c8c5 6342 button1.fall(&onButton1FallingEdge);
whismanoid 0:3edb3708c8c5 6343 # endif
whismanoid 0:3edb3708c8c5 6344 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6345 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6346 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 6347 # else
whismanoid 0:3edb3708c8c5 6348 button2.fall(&onButton2FallingEdge);
whismanoid 0:3edb3708c8c5 6349 # endif
whismanoid 0:3edb3708c8c5 6350 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6351
whismanoid 0:3edb3708c8c5 6352 #if HAS_SPI
whismanoid 0:3edb3708c8c5 6353 // spi init
whismanoid 0:3edb3708c8c5 6354 // mode | POL PHA
whismanoid 0:3edb3708c8c5 6355 // -----+--------
whismanoid 0:3edb3708c8c5 6356 // 0 | 0 0
whismanoid 0:3edb3708c8c5 6357 // 1 | 0 1
whismanoid 0:3edb3708c8c5 6358 // 2 | 1 0
whismanoid 0:3edb3708c8c5 6359 // 3 | 1 1
whismanoid 0:3edb3708c8c5 6360 //~ spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 0:3edb3708c8c5 6361 //~ spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 0:3edb3708c8c5 6362 //~ spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 0:3edb3708c8c5 6363 //~ spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 0:3edb3708c8c5 6364 //
whismanoid 0:3edb3708c8c5 6365 //~ spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 0:3edb3708c8c5 6366 //~ spi.frequency(9600000); // int SCLK_Hz=9600000 = 9.6MHz = 96MHz/10
whismanoid 0:3edb3708c8c5 6367 //~ spi.frequency(10666666); // int SCLK_Hz=10666666 = 10.6MHz = 96MHz/9
whismanoid 0:3edb3708c8c5 6368 //~ spi.frequency(12000000); // int SCLK_Hz=12000000 = 12MHz = 96MHz/8
whismanoid 0:3edb3708c8c5 6369 //~ spi.frequency(13714286); // int SCLK_Hz=13714286 = 13.7MHz = 96MHz/7
whismanoid 0:3edb3708c8c5 6370 //~ spi.frequency(16000000); // int SCLK_Hz=16000000 = 16MHz = 96MHz/6
whismanoid 0:3edb3708c8c5 6371 //~ spi.frequency(19200000); // int SCLK_Hz=19200000 = 19.2MHz = 96MHz/5
whismanoid 0:3edb3708c8c5 6372 //~ spi.frequency(24000000); // int SCLK_Hz=24000000 = 24MHz = 96MHz/4
whismanoid 0:3edb3708c8c5 6373 //~ spi.frequency(32000000); // int SCLK_Hz=32000000 = 32MHz = 96MHz/3
whismanoid 0:3edb3708c8c5 6374 //~ spi.frequency(48000000); // int SCLK_Hz=48000000 = 48MHz = 96MHz/2
whismanoid 0:3edb3708c8c5 6375 // unspecified SPI device
whismanoid 0:3edb3708c8c5 6376 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 6377 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 0:3edb3708c8c5 6378 spi_cs = 1;
whismanoid 0:3edb3708c8c5 6379 #endif
whismanoid 0:3edb3708c8c5 6380
whismanoid 0:3edb3708c8c5 6381 #if HAS_I2C
whismanoid 0:3edb3708c8c5 6382 // i2c init
whismanoid 0:3edb3708c8c5 6383 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 0:3edb3708c8c5 6384 // i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 0:3edb3708c8c5 6385 #else
whismanoid 0:3edb3708c8c5 6386 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:3edb3708c8c5 6387 #if HAS_digitalInOut14
whismanoid 0:3edb3708c8c5 6388 // DigitalInOut digitalInOut14(P1_6, PIN_INPUT, PullUp, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:3edb3708c8c5 6389 digitalInOut14.input();
whismanoid 0:3edb3708c8c5 6390 #endif
whismanoid 0:3edb3708c8c5 6391 #if HAS_digitalInOut15
whismanoid 0:3edb3708c8c5 6392 // DigitalInOut digitalInOut15(P1_7, PIN_INPUT, PullUp, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:3edb3708c8c5 6393 digitalInOut15.input();
whismanoid 0:3edb3708c8c5 6394 #endif
whismanoid 0:3edb3708c8c5 6395 #if HAS_digitalInOut16
whismanoid 0:3edb3708c8c5 6396 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:3edb3708c8c5 6397 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:3edb3708c8c5 6398 //DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:3edb3708c8c5 6399 digitalInOut16.input();
whismanoid 0:3edb3708c8c5 6400 #endif
whismanoid 0:3edb3708c8c5 6401 #if HAS_digitalInOut17
whismanoid 0:3edb3708c8c5 6402 //DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:3edb3708c8c5 6403 digitalInOut17.input();
whismanoid 0:3edb3708c8c5 6404 #endif
whismanoid 0:3edb3708c8c5 6405 #endif
whismanoid 0:3edb3708c8c5 6406
whismanoid 0:3edb3708c8c5 6407 #if USE_LEDS
whismanoid 0:3edb3708c8c5 6408 #if defined(TARGET_MAX32630)
whismanoid 0:3edb3708c8c5 6409 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 0:3edb3708c8c5 6410 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6411 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 6412 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6413 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 6414 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6415 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 0:3edb3708c8c5 6416 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6417 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 0:3edb3708c8c5 6418 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6419 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 0:3edb3708c8c5 6420 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6421 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 6422 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6423 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 0:3edb3708c8c5 6424 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6425 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:3edb3708c8c5 6426 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 0:3edb3708c8c5 6427 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6428 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 0:3edb3708c8c5 6429 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6430 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 0:3edb3708c8c5 6431 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6432 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 0:3edb3708c8c5 6433 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6434 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 0:3edb3708c8c5 6435 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6436 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 0:3edb3708c8c5 6437 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6438 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 0:3edb3708c8c5 6439 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6440 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 0:3edb3708c8c5 6441 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 0:3edb3708c8c5 6442 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:3edb3708c8c5 6443 led1 = LED_ON;
whismanoid 0:3edb3708c8c5 6444 led2 = LED_OFF;
whismanoid 0:3edb3708c8c5 6445 led3 = LED_OFF;
whismanoid 0:3edb3708c8c5 6446 led4 = LED_OFF;
whismanoid 0:3edb3708c8c5 6447 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 0:3edb3708c8c5 6448 //led1 = LED_ON;
whismanoid 0:3edb3708c8c5 6449 led2 = LED_ON;
whismanoid 0:3edb3708c8c5 6450 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 0:3edb3708c8c5 6451 led1 = LED_OFF;
whismanoid 0:3edb3708c8c5 6452 //led2 = LED_ON;
whismanoid 0:3edb3708c8c5 6453 led3 = LED_ON;
whismanoid 0:3edb3708c8c5 6454 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 0:3edb3708c8c5 6455 led2 = LED_OFF;
whismanoid 0:3edb3708c8c5 6456 //led3 = LED_ON;
whismanoid 0:3edb3708c8c5 6457 led4 = LED_ON;
whismanoid 0:3edb3708c8c5 6458 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 0:3edb3708c8c5 6459 led3 = LED_OFF;
whismanoid 0:3edb3708c8c5 6460 led4 = LED_ON;
whismanoid 0:3edb3708c8c5 6461 //
whismanoid 0:3edb3708c8c5 6462 #endif // target definition
whismanoid 0:3edb3708c8c5 6463 #endif
whismanoid 0:3edb3708c8c5 6464
whismanoid 0:3edb3708c8c5 6465 // cmd_TE();
whismanoid 0:3edb3708c8c5 6466
whismanoid 0:3edb3708c8c5 6467 #if USE_LEDS
whismanoid 0:3edb3708c8c5 6468 rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 0:3edb3708c8c5 6469 #endif // USE_LEDS
whismanoid 0:3edb3708c8c5 6470 InitializeConfiguration();
whismanoid 0:3edb3708c8c5 6471
whismanoid 0:3edb3708c8c5 6472 while (1) {
whismanoid 0:3edb3708c8c5 6473 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 0:3edb3708c8c5 6474 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 0:3edb3708c8c5 6475 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 0:3edb3708c8c5 6476 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6477 static int button1_value_prev = 1;
whismanoid 0:3edb3708c8c5 6478 static int button1_value_now = 1;
whismanoid 0:3edb3708c8c5 6479 button1_value_prev = button1_value_now;
whismanoid 0:3edb3708c8c5 6480 button1_value_now = button1.read();
whismanoid 0:3edb3708c8c5 6481 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 0:3edb3708c8c5 6482 {
whismanoid 0:3edb3708c8c5 6483 // on button1 falling edge (button1 press)
whismanoid 0:3edb3708c8c5 6484 onButton1FallingEdge();
whismanoid 0:3edb3708c8c5 6485 }
whismanoid 0:3edb3708c8c5 6486 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6487 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6488 static int button2_value_prev = 1;
whismanoid 0:3edb3708c8c5 6489 static int button2_value_now = 1;
whismanoid 0:3edb3708c8c5 6490 button2_value_prev = button2_value_now;
whismanoid 0:3edb3708c8c5 6491 button2_value_now = button2.read();
whismanoid 0:3edb3708c8c5 6492 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 0:3edb3708c8c5 6493 {
whismanoid 0:3edb3708c8c5 6494 // on button2 falling edge (button2 press)
whismanoid 0:3edb3708c8c5 6495 onButton2FallingEdge();
whismanoid 0:3edb3708c8c5 6496 }
whismanoid 0:3edb3708c8c5 6497 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 0:3edb3708c8c5 6498 #endif
whismanoid 0:3edb3708c8c5 6499 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6500 if (DAPLINKserial.readable()) {
whismanoid 0:3edb3708c8c5 6501 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 0:3edb3708c8c5 6502 }
whismanoid 0:3edb3708c8c5 6503 # endif // HAS_DAPLINK_SERIAL
whismanoid 7:bf501f8cb637 6504 if (serial.readable()) {
whismanoid 7:bf501f8cb637 6505 int c = serial.getc();
whismanoid 7:bf501f8cb637 6506 cmdLine_serial.append(c);
whismanoid 0:3edb3708c8c5 6507 #if IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6508 # if HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6509 cmdLine_DAPLINKserial.serial().printf("%c", c);
whismanoid 0:3edb3708c8c5 6510 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:3edb3708c8c5 6511 #endif // IGNORE_AT_COMMANDS
whismanoid 0:3edb3708c8c5 6512 //
whismanoid 0:3edb3708c8c5 6513 }
whismanoid 0:3edb3708c8c5 6514 } // while(1)
whismanoid 0:3edb3708c8c5 6515 }