Test program running on MAX32625MBED. Control through USB Serial commands using a terminal emulator such as teraterm or putty.
Dependencies: MaximTinyTester CmdLine MAX541 USBDevice
main.cpp@12:5d3f9663ea0c, 2019-07-10 (annotated)
- Committer:
- whismanoid
- Date:
- Wed Jul 10 21:44:29 2019 +0000
- Revision:
- 12:5d3f9663ea0c
- Parent:
- 11:9fa2402071de
- Child:
- 13:e36d51f46794
Support Nucleo_F446RE (LED indicators are NC)
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:3edb3708c8c5 | 40 | // - NUCLEO_F446RE |
whismanoid | 0:3edb3708c8c5 | 41 | // - NUCLEO_F401RE |
whismanoid | 0:3edb3708c8c5 | 42 | |
whismanoid | 0:3edb3708c8c5 | 43 | #include "mbed.h" |
whismanoid | 0:3edb3708c8c5 | 44 | #if defined(TARGET) |
whismanoid | 0:3edb3708c8c5 | 45 | // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h |
whismanoid | 0:3edb3708c8c5 | 46 | // Create a string definition for the TARGET |
whismanoid | 0:3edb3708c8c5 | 47 | #define STRING_ARG(arg) #arg |
whismanoid | 0:3edb3708c8c5 | 48 | #define STRING_NAME(name) STRING_ARG(name) |
whismanoid | 0:3edb3708c8c5 | 49 | #define TARGET_NAME STRING_NAME(TARGET) |
whismanoid | 11:9fa2402071de | 50 | #elif defined(TARGET_MAX32600) |
whismanoid | 11:9fa2402071de | 51 | #define TARGET_NAME "MAX32600" |
whismanoid | 0:3edb3708c8c5 | 52 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 53 | #define TARGET_NAME "LPC1768" |
whismanoid | 0:3edb3708c8c5 | 54 | #elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 55 | #define TARGET_NAME "NUCLEO_F446RE" |
whismanoid | 0:3edb3708c8c5 | 56 | #elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 57 | #define TARGET_NAME "NUCLEO_F401RE" |
whismanoid | 0:3edb3708c8c5 | 58 | #else |
whismanoid | 0:3edb3708c8c5 | 59 | #error TARGET NOT DEFINED |
whismanoid | 0:3edb3708c8c5 | 60 | #endif |
whismanoid | 0:3edb3708c8c5 | 61 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 62 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 63 | // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM |
whismanoid | 0:3edb3708c8c5 | 64 | // +-------------[microUSB]-------------+ |
whismanoid | 0:3edb3708c8c5 | 65 | // | J1 MAX32630FTHR J2 | |
whismanoid | 0:3edb3708c8c5 | 66 | // ______ | [ ] RST GND [ ] | |
whismanoid | 0:3edb3708c8c5 | 67 | // ______ | [ ] 3V3 BAT+[ ] | |
whismanoid | 0:3edb3708c8c5 | 68 | // ______ | [ ] 1V8 reset SW1 | |
whismanoid | 0:3edb3708c8c5 | 69 | // ______ | [ ] GND J4 J3 | |
whismanoid | 0:3edb3708c8c5 | 70 | // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+ |
whismanoid | 0:3edb3708c8c5 | 71 | // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn |
whismanoid | 0:3edb3708c8c5 | 72 | // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power |
whismanoid | 0:3edb3708c8c5 | 73 | // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | dig9 |
whismanoid | 0:3edb3708c8c5 | 74 | // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | dig8 |
whismanoid | 0:3edb3708c8c5 | 75 | // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | dig7 |
whismanoid | 0:3edb3708c8c5 | 76 | // (SPI.SCLK) | [s] P5_0 SCLK SDIO2 P5_4 [d] | dig6 |
whismanoid | 0:3edb3708c8c5 | 77 | // (SPI.MOSI) | [s] P5_1 MOSI SSEL P5_3 [d] | dig5 |
whismanoid | 0:3edb3708c8c5 | 78 | // (SPI.MISO) | [s] P5_2 MISO RTS P3_3 [d] | dig4 |
whismanoid | 0:3edb3708c8c5 | 79 | // (SPI.CS ) | [s] P3_0 RX CTS P3_2 [d] | dig3 |
whismanoid | 0:3edb3708c8c5 | 80 | // dig0 | [d] P3_1 TX SCL P3_5 [d] | dig2 |
whismanoid | 0:3edb3708c8c5 | 81 | // ______ | [ ] GND SDA P3_4 [d] | dig1 |
whismanoid | 0:3edb3708c8c5 | 82 | // | | |
whismanoid | 0:3edb3708c8c5 | 83 | // | XIP Flash MAX14690N | |
whismanoid | 0:3edb3708c8c5 | 84 | // | XIP_SCLK P1_0 SDA2 P5_7 | |
whismanoid | 0:3edb3708c8c5 | 85 | // | XIP_MOSI P1_1 SCL2 P6_0 | |
whismanoid | 0:3edb3708c8c5 | 86 | // | XIP_MISO P1_2 PMIC_INIT P3_7 | |
whismanoid | 0:3edb3708c8c5 | 87 | // | XIP_SSEL P1_3 MPC P2_7 | |
whismanoid | 0:3edb3708c8c5 | 88 | // | XIP_DIO2 P1_4 MON AIN_0 | |
whismanoid | 0:3edb3708c8c5 | 89 | // | XIP_DIO3 P1_5 | |
whismanoid | 0:3edb3708c8c5 | 90 | // | | |
whismanoid | 0:3edb3708c8c5 | 91 | // | PAN1326B MicroSD LED | |
whismanoid | 0:3edb3708c8c5 | 92 | // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 | |
whismanoid | 0:3edb3708c8c5 | 93 | // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 | |
whismanoid | 0:3edb3708c8c5 | 94 | // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 | |
whismanoid | 0:3edb3708c8c5 | 95 | // | BT_RTS P0_3 SD_SSEL P0_7 | |
whismanoid | 0:3edb3708c8c5 | 96 | // | BT_RST P1_6 DETECT P2_2 | |
whismanoid | 0:3edb3708c8c5 | 97 | // | BT_CLK P1_7 SW2 P2_3 | |
whismanoid | 0:3edb3708c8c5 | 98 | // +------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 99 | // 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 | 100 | // 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 | 101 | // AIN_0 = AIN0 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 102 | // AIN_1 = AIN1 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 103 | // AIN_2 = AIN2 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 104 | // AIN_3 = AIN3 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 105 | // AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 106 | // AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 107 | // AIN_6 = VDDB / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 108 | // AIN_7 = VDD18 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 109 | // AIN_8 = VDD12 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 110 | // AIN_9 = VRTC / 2.0 fullscale is 2.4V |
whismanoid | 0:3edb3708c8c5 | 111 | // AIN_10 = x undefined? |
whismanoid | 0:3edb3708c8c5 | 112 | // AIN_11 = VDDIO / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 113 | // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 114 | // |
whismanoid | 0:3edb3708c8c5 | 115 | #include "max32630fthr.h" |
whismanoid | 0:3edb3708c8c5 | 116 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
whismanoid | 0:3edb3708c8c5 | 117 | #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 118 | // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15 |
whismanoid | 0:3edb3708c8c5 | 119 | const float ADC_FULL_SCALE_VOLTAGE = 1.200; |
whismanoid | 0:3edb3708c8c5 | 120 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 121 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 122 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 123 | // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 124 | // +-------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 125 | // | MAX32625MBED Arduino UNO header | |
whismanoid | 0:3edb3708c8c5 | 126 | // | | |
whismanoid | 0:3edb3708c8c5 | 127 | // | A5/SCL[ ] | P1_7 dig15 |
whismanoid | 0:3edb3708c8c5 | 128 | // | A4/SDA[ ] | P1_6 dig14 |
whismanoid | 0:3edb3708c8c5 | 129 | // | AREF=N/C[ ] | |
whismanoid | 0:3edb3708c8c5 | 130 | // | GND[ ] | |
whismanoid | 0:3edb3708c8c5 | 131 | // | [ ]N/C SCK/13[ ] | P1_0 dig13 |
whismanoid | 0:3edb3708c8c5 | 132 | // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12 |
whismanoid | 0:3edb3708c8c5 | 133 | // | [ ]RST MOSI/11[ ]~| P1_1 dig11 |
whismanoid | 0:3edb3708c8c5 | 134 | // | [ ]3V3 CS/10[ ]~| P1_3 dig10 |
whismanoid | 0:3edb3708c8c5 | 135 | // | [ ]5V0 9[ ]~| P1_5 dig9 |
whismanoid | 0:3edb3708c8c5 | 136 | // | [ ]GND 8[ ] | P1_4 dig8 |
whismanoid | 0:3edb3708c8c5 | 137 | // | [ ]GND | |
whismanoid | 0:3edb3708c8c5 | 138 | // | [ ]Vin 7[ ] | P0_7 dig7 |
whismanoid | 0:3edb3708c8c5 | 139 | // | 6[ ]~| P0_6 dig6 |
whismanoid | 0:3edb3708c8c5 | 140 | // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5 |
whismanoid | 0:3edb3708c8c5 | 141 | // AIN_1 | [ ]A1 4[ ] | P0_4 dig4 |
whismanoid | 0:3edb3708c8c5 | 142 | // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3 |
whismanoid | 0:3edb3708c8c5 | 143 | // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2 |
whismanoid | 0:3edb3708c8c5 | 144 | // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1 |
whismanoid | 0:3edb3708c8c5 | 145 | // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0 |
whismanoid | 0:3edb3708c8c5 | 146 | // | [ ] [ ] [ ] | |
whismanoid | 0:3edb3708c8c5 | 147 | // | UNO_R3 GND MOSI 5V ____________/ |
whismanoid | 0:3edb3708c8c5 | 148 | // \_______________________/ |
whismanoid | 0:3edb3708c8c5 | 149 | // |
whismanoid | 0:3edb3708c8c5 | 150 | // +------------------------+ |
whismanoid | 0:3edb3708c8c5 | 151 | // | | |
whismanoid | 0:3edb3708c8c5 | 152 | // | MicroSD LED | |
whismanoid | 0:3edb3708c8c5 | 153 | // | SD_SCLK P2_4 r P3_0 | |
whismanoid | 0:3edb3708c8c5 | 154 | // | SD_MOSI P2_5 g P3_1 | |
whismanoid | 0:3edb3708c8c5 | 155 | // | SD_MISO P2_6 b P3_2 | |
whismanoid | 0:3edb3708c8c5 | 156 | // | SD_SSEL P2_7 y P3_3 | |
whismanoid | 0:3edb3708c8c5 | 157 | // | | |
whismanoid | 0:3edb3708c8c5 | 158 | // | DAPLINK BUTTONS | |
whismanoid | 0:3edb3708c8c5 | 159 | // | TX P2_1 SW3 P2_3 | |
whismanoid | 0:3edb3708c8c5 | 160 | // | RX P2_0 SW2 P2_2 | |
whismanoid | 0:3edb3708c8c5 | 161 | // +------------------------+ |
whismanoid | 0:3edb3708c8c5 | 162 | // |
whismanoid | 0:3edb3708c8c5 | 163 | // AIN_0 = AIN0 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 164 | // AIN_1 = AIN1 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 165 | // AIN_2 = AIN2 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 166 | // AIN_3 = AIN3 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 167 | // AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 168 | // AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 169 | // AIN_6 = VDDB / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 170 | // AIN_7 = VDD18 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 171 | // AIN_8 = VDD12 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 172 | // AIN_9 = VRTC / 2.0 fullscale is 2.4V |
whismanoid | 0:3edb3708c8c5 | 173 | // AIN_10 = x undefined? |
whismanoid | 0:3edb3708c8c5 | 174 | // AIN_11 = VDDIO / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 175 | // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 176 | // |
whismanoid | 0:3edb3708c8c5 | 177 | //#include "max32625mbed.h" // ? |
whismanoid | 0:3edb3708c8c5 | 178 | //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ? |
whismanoid | 0:3edb3708c8c5 | 179 | #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 180 | // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15 |
whismanoid | 0:3edb3708c8c5 | 181 | const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico? |
whismanoid | 0:3edb3708c8c5 | 182 | // Arduino connector |
whismanoid | 0:3edb3708c8c5 | 183 | #ifndef A0 |
whismanoid | 0:3edb3708c8c5 | 184 | #define A0 AIN_0 |
whismanoid | 0:3edb3708c8c5 | 185 | #endif |
whismanoid | 0:3edb3708c8c5 | 186 | #ifndef A1 |
whismanoid | 0:3edb3708c8c5 | 187 | #define A1 AIN_1 |
whismanoid | 0:3edb3708c8c5 | 188 | #endif |
whismanoid | 0:3edb3708c8c5 | 189 | #ifndef A2 |
whismanoid | 0:3edb3708c8c5 | 190 | #define A2 AIN_2 |
whismanoid | 0:3edb3708c8c5 | 191 | #endif |
whismanoid | 0:3edb3708c8c5 | 192 | #ifndef A3 |
whismanoid | 0:3edb3708c8c5 | 193 | #define A3 AIN_3 |
whismanoid | 0:3edb3708c8c5 | 194 | #endif |
whismanoid | 0:3edb3708c8c5 | 195 | #ifndef D0 |
whismanoid | 0:3edb3708c8c5 | 196 | #define D0 P0_0 |
whismanoid | 0:3edb3708c8c5 | 197 | #endif |
whismanoid | 0:3edb3708c8c5 | 198 | #ifndef D1 |
whismanoid | 0:3edb3708c8c5 | 199 | #define D1 P0_1 |
whismanoid | 0:3edb3708c8c5 | 200 | #endif |
whismanoid | 0:3edb3708c8c5 | 201 | #ifndef D2 |
whismanoid | 0:3edb3708c8c5 | 202 | #define D2 P0_2 |
whismanoid | 0:3edb3708c8c5 | 203 | #endif |
whismanoid | 0:3edb3708c8c5 | 204 | #ifndef D3 |
whismanoid | 0:3edb3708c8c5 | 205 | #define D3 P0_3 |
whismanoid | 0:3edb3708c8c5 | 206 | #endif |
whismanoid | 0:3edb3708c8c5 | 207 | #ifndef D4 |
whismanoid | 0:3edb3708c8c5 | 208 | #define D4 P0_4 |
whismanoid | 0:3edb3708c8c5 | 209 | #endif |
whismanoid | 0:3edb3708c8c5 | 210 | #ifndef D5 |
whismanoid | 0:3edb3708c8c5 | 211 | #define D5 P0_5 |
whismanoid | 0:3edb3708c8c5 | 212 | #endif |
whismanoid | 0:3edb3708c8c5 | 213 | #ifndef D6 |
whismanoid | 0:3edb3708c8c5 | 214 | #define D6 P0_6 |
whismanoid | 0:3edb3708c8c5 | 215 | #endif |
whismanoid | 0:3edb3708c8c5 | 216 | #ifndef D7 |
whismanoid | 0:3edb3708c8c5 | 217 | #define D7 P0_7 |
whismanoid | 0:3edb3708c8c5 | 218 | #endif |
whismanoid | 0:3edb3708c8c5 | 219 | #ifndef D8 |
whismanoid | 0:3edb3708c8c5 | 220 | #define D8 P1_4 |
whismanoid | 0:3edb3708c8c5 | 221 | #endif |
whismanoid | 0:3edb3708c8c5 | 222 | #ifndef D9 |
whismanoid | 0:3edb3708c8c5 | 223 | #define D9 P1_5 |
whismanoid | 0:3edb3708c8c5 | 224 | #endif |
whismanoid | 0:3edb3708c8c5 | 225 | #ifndef D10 |
whismanoid | 0:3edb3708c8c5 | 226 | #define D10 P1_3 |
whismanoid | 0:3edb3708c8c5 | 227 | #endif |
whismanoid | 0:3edb3708c8c5 | 228 | #ifndef D11 |
whismanoid | 0:3edb3708c8c5 | 229 | #define D11 P1_1 |
whismanoid | 0:3edb3708c8c5 | 230 | #endif |
whismanoid | 0:3edb3708c8c5 | 231 | #ifndef D12 |
whismanoid | 0:3edb3708c8c5 | 232 | #define D12 P1_2 |
whismanoid | 0:3edb3708c8c5 | 233 | #endif |
whismanoid | 0:3edb3708c8c5 | 234 | #ifndef D13 |
whismanoid | 0:3edb3708c8c5 | 235 | #define D13 P1_0 |
whismanoid | 0:3edb3708c8c5 | 236 | #endif |
whismanoid | 0:3edb3708c8c5 | 237 | //-------------------------------------------------- |
whismanoid | 11:9fa2402071de | 238 | #elif defined(TARGET_MAX32600) |
whismanoid | 11:9fa2402071de | 239 | // target MAX32600 |
whismanoid | 11:9fa2402071de | 240 | // |
whismanoid | 11:9fa2402071de | 241 | #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 |
whismanoid | 11:9fa2402071de | 242 | const float ADC_FULL_SCALE_VOLTAGE = 1.500; |
whismanoid | 11:9fa2402071de | 243 | // |
whismanoid | 11:9fa2402071de | 244 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 245 | #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 246 | // TODO1: target NUCLEO_F446RE |
whismanoid | 0:3edb3708c8c5 | 247 | // |
whismanoid | 0:3edb3708c8c5 | 248 | // USER_BUTTON PC13 |
whismanoid | 0:3edb3708c8c5 | 249 | // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1. |
whismanoid | 0:3edb3708c8c5 | 250 | #define USE_LEDS 0 |
whismanoid | 0:3edb3708c8c5 | 251 | // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); |
whismanoid | 7:bf501f8cb637 | 252 | // Serial serial(SERIAL_TX, SERIAL_RX); |
whismanoid | 0:3edb3708c8c5 | 253 | #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 |
whismanoid | 0:3edb3708c8c5 | 254 | const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico? |
whismanoid | 0:3edb3708c8c5 | 255 | // |
whismanoid | 0:3edb3708c8c5 | 256 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 257 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 258 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 259 | // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM |
whismanoid | 0:3edb3708c8c5 | 260 | // +-------------[microUSB]-------------+ |
whismanoid | 0:3edb3708c8c5 | 261 | // ______ | [ ] GND +3.3V VOUT [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 262 | // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 263 | // ______ | [ ] VB USB.IF- [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 264 | // ______ | [ ] nR USB.IF+ [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 265 | // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 266 | // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 267 | // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 268 | // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 269 | // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 270 | // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 271 | // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 272 | // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 273 | // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 274 | // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 275 | // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1 |
whismanoid | 0:3edb3708c8c5 | 276 | // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2 |
whismanoid | 0:3edb3708c8c5 | 277 | // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3 |
whismanoid | 0:3edb3708c8c5 | 278 | // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4 |
whismanoid | 0:3edb3708c8c5 | 279 | // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5 |
whismanoid | 0:3edb3708c8c5 | 280 | // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 281 | // +------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 282 | // AIN6 = P0.3 = TGT_SBL_RXD? |
whismanoid | 0:3edb3708c8c5 | 283 | // AIN7 = P0.2 = TGT_SBL_TXD? |
whismanoid | 0:3edb3708c8c5 | 284 | // |
whismanoid | 0:3edb3708c8c5 | 285 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 286 | // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14 |
whismanoid | 0:3edb3708c8c5 | 287 | #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 |
whismanoid | 0:3edb3708c8c5 | 288 | const float ADC_FULL_SCALE_VOLTAGE = 3.300; |
whismanoid | 0:3edb3708c8c5 | 289 | #else // not defined(TARGET_LPC1768 etc.) |
whismanoid | 0:3edb3708c8c5 | 290 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 291 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 292 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 293 | #endif // target definition |
whismanoid | 0:3edb3708c8c5 | 294 | |
whismanoid | 0:3edb3708c8c5 | 295 | |
whismanoid | 0:3edb3708c8c5 | 296 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 297 | // alphanumeric command codes A-Z,a-z,0-9 reserved for application use |
whismanoid | 0:3edb3708c8c5 | 298 | #ifndef APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 299 | #define APPLICATION_ArduinoPinsMonitor 1 |
whismanoid | 0:3edb3708c8c5 | 300 | #endif // APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 301 | |
whismanoid | 0:3edb3708c8c5 | 302 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 303 | // Support MAX5715BOB Breakout Board |
whismanoid | 0:3edb3708c8c5 | 304 | #ifndef APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 305 | #define APPLICATION_MAX5715 1 |
whismanoid | 0:3edb3708c8c5 | 306 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 307 | #if APPLICATION_MAX5715 // header file |
whismanoid | 0:3edb3708c8c5 | 308 | #include "MAX5715.h" |
whismanoid | 0:3edb3708c8c5 | 309 | // suppress the I2C diagnostics, not relevant to this chip |
whismanoid | 0:3edb3708c8c5 | 310 | #define HAS_I2C 0 |
whismanoid | 0:3edb3708c8c5 | 311 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 312 | |
whismanoid | 0:3edb3708c8c5 | 313 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 314 | // Support MAX11131BOB Breakout Board |
whismanoid | 0:3edb3708c8c5 | 315 | #ifndef APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 316 | #define APPLICATION_MAX11131 0 |
whismanoid | 0:3edb3708c8c5 | 317 | #endif // APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 318 | #if APPLICATION_MAX11131 // header file |
whismanoid | 0:3edb3708c8c5 | 319 | #include "MAX11131.h" |
whismanoid | 0:3edb3708c8c5 | 320 | // suppress the I2C diagnostics, not relevant to this chip |
whismanoid | 0:3edb3708c8c5 | 321 | #define HAS_I2C 0 |
whismanoid | 0:3edb3708c8c5 | 322 | #endif // APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 323 | |
whismanoid | 0:3edb3708c8c5 | 324 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 325 | // Support MAX5171BOB Breakout Board |
whismanoid | 0:3edb3708c8c5 | 326 | #ifndef APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 327 | #define APPLICATION_MAX5171 0 |
whismanoid | 0:3edb3708c8c5 | 328 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 329 | #if APPLICATION_MAX5171 // header file |
whismanoid | 0:3edb3708c8c5 | 330 | #include "MAX5171.h" |
whismanoid | 0:3edb3708c8c5 | 331 | // suppress the I2C diagnostics, not relevant to this chip |
whismanoid | 0:3edb3708c8c5 | 332 | #define HAS_I2C 0 |
whismanoid | 0:3edb3708c8c5 | 333 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 334 | |
whismanoid | 0:3edb3708c8c5 | 335 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 336 | // Support MAX11410BOB Breakout Board (placeholder) |
whismanoid | 0:3edb3708c8c5 | 337 | #ifndef APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 338 | #define APPLICATION_MAX11410 0 |
whismanoid | 0:3edb3708c8c5 | 339 | #endif // APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 340 | #if APPLICATION_MAX11410 // header file |
whismanoid | 0:3edb3708c8c5 | 341 | #include "MAX11410.h" |
whismanoid | 0:3edb3708c8c5 | 342 | #endif // APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 343 | |
whismanoid | 0:3edb3708c8c5 | 344 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 345 | // Support MAX12345BOB Breakout Board (placeholder) |
whismanoid | 0:3edb3708c8c5 | 346 | #ifndef APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 347 | #define APPLICATION_MAX12345 0 |
whismanoid | 0:3edb3708c8c5 | 348 | #endif // APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 349 | #if APPLICATION_MAX12345 // header file |
whismanoid | 0:3edb3708c8c5 | 350 | #include "MAX12345.h" |
whismanoid | 0:3edb3708c8c5 | 351 | #endif // APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 352 | |
whismanoid | 0:3edb3708c8c5 | 353 | |
whismanoid | 0:3edb3708c8c5 | 354 | #include "MAX541.h" |
whismanoid | 0:3edb3708c8c5 | 355 | |
whismanoid | 0:3edb3708c8c5 | 356 | #include "MaximTinyTester.h" |
whismanoid | 0:3edb3708c8c5 | 357 | |
whismanoid | 0:3edb3708c8c5 | 358 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 359 | // Option to dedicate SPI port pins |
whismanoid | 0:3edb3708c8c5 | 360 | // |
whismanoid | 0:3edb3708c8c5 | 361 | // SPI2_MOSI = P5_1 |
whismanoid | 0:3edb3708c8c5 | 362 | // SPI2_MISO = P5_2 |
whismanoid | 0:3edb3708c8c5 | 363 | // SPI2_SCK = P5_0 |
whismanoid | 0:3edb3708c8c5 | 364 | // On this board I'm using P3_0 as spi_cs |
whismanoid | 0:3edb3708c8c5 | 365 | // SPI2_SS = P5_3 |
whismanoid | 0:3edb3708c8c5 | 366 | // SPI2_SDIO2 = P5_4 |
whismanoid | 0:3edb3708c8c5 | 367 | // SPI2_SDIO3 = P5_5 |
whismanoid | 0:3edb3708c8c5 | 368 | // SPI2_SRN = P5_6 |
whismanoid | 0:3edb3708c8c5 | 369 | // |
whismanoid | 0:3edb3708c8c5 | 370 | #ifndef HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 371 | #define HAS_SPI 1 |
whismanoid | 0:3edb3708c8c5 | 372 | #endif |
whismanoid | 0:3edb3708c8c5 | 373 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 374 | #define SPI_MODE0 0 |
whismanoid | 0:3edb3708c8c5 | 375 | #define SPI_MODE1 1 |
whismanoid | 0:3edb3708c8c5 | 376 | #define SPI_MODE2 2 |
whismanoid | 0:3edb3708c8c5 | 377 | #define SPI_MODE3 3 |
whismanoid | 0:3edb3708c8c5 | 378 | // |
whismanoid | 0:3edb3708c8c5 | 379 | // Define application-specific default SPI_SCLK_Hz and SPI_dataMode |
whismanoid | 0:3edb3708c8c5 | 380 | #if APPLICATION_MAX5715 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 381 | // |
whismanoid | 0:3edb3708c8c5 | 382 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 383 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:3edb3708c8c5 | 384 | #define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:3edb3708c8c5 | 385 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 386 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 387 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 388 | #define SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 389 | // |
whismanoid | 0:3edb3708c8c5 | 390 | #elif APPLICATION_MAX11131 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 391 | // |
whismanoid | 0:3edb3708c8c5 | 392 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 393 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:3edb3708c8c5 | 394 | #define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:3edb3708c8c5 | 395 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 396 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 397 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 398 | #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 399 | // |
whismanoid | 0:3edb3708c8c5 | 400 | #elif APPLICATION_MAX5171 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 401 | // |
whismanoid | 0:3edb3708c8c5 | 402 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 403 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:3edb3708c8c5 | 404 | #define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:3edb3708c8c5 | 405 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 406 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 407 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 408 | #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 409 | // |
whismanoid | 0:3edb3708c8c5 | 410 | #elif APPLICATION_MAX11410 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 411 | // |
whismanoid | 0:3edb3708c8c5 | 412 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 413 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:3edb3708c8c5 | 414 | //#define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:3edb3708c8c5 | 415 | #define SPI_SCLK_Hz 8000000 // 8MHz |
whismanoid | 0:3edb3708c8c5 | 416 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 417 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 418 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 419 | #define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Falling Edge stable; SCLK idle Low |
whismanoid | 0:3edb3708c8c5 | 420 | // |
whismanoid | 0:3edb3708c8c5 | 421 | #elif APPLICATION_MAX12345 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 422 | // |
whismanoid | 0:3edb3708c8c5 | 423 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 424 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:3edb3708c8c5 | 425 | #define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:3edb3708c8c5 | 426 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 427 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 428 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 429 | #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 430 | // |
whismanoid | 0:3edb3708c8c5 | 431 | #else // APPLICATION_ArduinoPinsMonitor diagnostic |
whismanoid | 0:3edb3708c8c5 | 432 | // |
whismanoid | 0:3edb3708c8c5 | 433 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 434 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 435 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 436 | #define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 437 | //#define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low |
whismanoid | 0:3edb3708c8c5 | 438 | //#define SPI_dataMode SPI_MODE1 // CPOL=0,CPHA=1: Falling Edge stable; SCLK idle Low |
whismanoid | 0:3edb3708c8c5 | 439 | //#define SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 440 | #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 441 | // |
whismanoid | 0:3edb3708c8c5 | 442 | #endif |
whismanoid | 0:3edb3708c8c5 | 443 | // |
whismanoid | 0:3edb3708c8c5 | 444 | uint32_t g_SPI_SCLK_Hz = SPI_SCLK_Hz; |
whismanoid | 0:3edb3708c8c5 | 445 | // TODO1: validate g_SPI_SCLK_Hz against system clock frequency SystemCoreClock F_CPU |
whismanoid | 0:3edb3708c8c5 | 446 | #if defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 447 | // Nucleo SPI frequency isn't working quite as expected... |
whismanoid | 0:3edb3708c8c5 | 448 | // Looks like STMF4 has an spi clock prescaler (2,4,8,16,32,64,128,256) |
whismanoid | 0:3edb3708c8c5 | 449 | // so 180MHz->[90.0, 45.0, 22.5, 11.25, 5.625, 2.8125, 1.40625, 0.703125] |
whismanoid | 0:3edb3708c8c5 | 450 | // %SC SCLK=1MHz sets spi frequency 703.125kHz |
whismanoid | 0:3edb3708c8c5 | 451 | // %SC SCLK=2MHz sets spi frequency 1.40625MHz |
whismanoid | 0:3edb3708c8c5 | 452 | // %SC SCLK=3MHz sets spi frequency 2.8125MHz |
whismanoid | 0:3edb3708c8c5 | 453 | // %SC SCLK=6MHz sets spi frequency 5.625MHz |
whismanoid | 0:3edb3708c8c5 | 454 | // %SC SCLK=12MHz sets spi frequency 11.25MHz |
whismanoid | 0:3edb3708c8c5 | 455 | // %SC SCLK=23MHz sets spi frequency 22.5MHz |
whismanoid | 0:3edb3708c8c5 | 456 | // %SC SCLK=45MHz sets spi frequency 45.0MHz |
whismanoid | 0:3edb3708c8c5 | 457 | // Don't know why I can't reach spi frequency 90.0MHz, but ok whatever. |
whismanoid | 0:3edb3708c8c5 | 458 | const uint32_t limit_min_SPI_SCLK_divisor = 2; |
whismanoid | 0:3edb3708c8c5 | 459 | const uint32_t limit_max_SPI_SCLK_divisor = 256; |
whismanoid | 0:3edb3708c8c5 | 460 | // not really a divisor, just a powers-of-two prescaler with no intermediate divisors. |
whismanoid | 0:3edb3708c8c5 | 461 | #else |
whismanoid | 0:3edb3708c8c5 | 462 | const uint32_t limit_min_SPI_SCLK_divisor = 2; |
whismanoid | 0:3edb3708c8c5 | 463 | const uint32_t limit_max_SPI_SCLK_divisor = 8191; |
whismanoid | 0:3edb3708c8c5 | 464 | #endif |
whismanoid | 0:3edb3708c8c5 | 465 | const uint32_t limit_max_SPI_SCLK_Hz = (SystemCoreClock / limit_min_SPI_SCLK_divisor); // F_CPU / 2; // 8MHz / 2 = 4MHz |
whismanoid | 0:3edb3708c8c5 | 466 | const uint32_t limit_min_SPI_SCLK_Hz = (SystemCoreClock / limit_max_SPI_SCLK_divisor); // F_CPU / 128; // 8MHz / 128 = 62.5kHz |
whismanoid | 0:3edb3708c8c5 | 467 | // |
whismanoid | 0:3edb3708c8c5 | 468 | uint8_t g_SPI_dataMode = SPI_dataMode; |
whismanoid | 0:3edb3708c8c5 | 469 | uint8_t g_SPI_cs_state = 1; |
whismanoid | 0:3edb3708c8c5 | 470 | // |
whismanoid | 0:3edb3708c8c5 | 471 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 472 | // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 473 | // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) |
whismanoid | 0:3edb3708c8c5 | 474 | //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 | 475 | //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 | 476 | //SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 |
whismanoid | 0:3edb3708c8c5 | 477 | SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 |
whismanoid | 0:3edb3708c8c5 | 478 | // |
whismanoid | 0:3edb3708c8c5 | 479 | DigitalOut spi_cs(P3_0); |
whismanoid | 0:3edb3708c8c5 | 480 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 481 | // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 482 | // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) |
whismanoid | 0:3edb3708c8c5 | 483 | //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 | 484 | //DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32635MBED: P0_7 Arduino 8-pin header D4 |
whismanoid | 0:3edb3708c8c5 | 485 | 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 | 486 | DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32635MBED: P1_3 Arduino 10-pin header D10 |
whismanoid | 0:3edb3708c8c5 | 487 | 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 | 488 | DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header |
whismanoid | 0:3edb3708c8c5 | 489 | #define HAS_SPI2_MAX541 1 |
whismanoid | 0:3edb3708c8c5 | 490 | // |
whismanoid | 11:9fa2402071de | 491 | #elif defined(TARGET_MAX32600) |
whismanoid | 11:9fa2402071de | 492 | SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 |
whismanoid | 11:9fa2402071de | 493 | DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10 |
whismanoid | 11:9fa2402071de | 494 | // |
whismanoid | 0:3edb3708c8c5 | 495 | #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 496 | // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 497 | // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) |
whismanoid | 0:3edb3708c8c5 | 498 | // |
whismanoid | 0:3edb3708c8c5 | 499 | // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses. |
whismanoid | 0:3edb3708c8c5 | 500 | 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 | 501 | DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10 |
whismanoid | 0:3edb3708c8c5 | 502 | // |
whismanoid | 0:3edb3708c8c5 | 503 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 504 | // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 505 | // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) |
whismanoid | 0:3edb3708c8c5 | 506 | //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 | 507 | //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 | 508 | //SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 |
whismanoid | 0:3edb3708c8c5 | 509 | SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 |
whismanoid | 0:3edb3708c8c5 | 510 | // |
whismanoid | 0:3edb3708c8c5 | 511 | DigitalOut spi_cs(P3_0); |
whismanoid | 0:3edb3708c8c5 | 512 | #else |
whismanoid | 0:3edb3708c8c5 | 513 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 514 | #endif |
whismanoid | 0:3edb3708c8c5 | 515 | #endif |
whismanoid | 0:3edb3708c8c5 | 516 | |
whismanoid | 0:3edb3708c8c5 | 517 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 518 | // Device driver object |
whismanoid | 0:3edb3708c8c5 | 519 | #if APPLICATION_MAX5715 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 520 | DigitalOut LDACb_pin(D9); // Arduino 10-pin header D9 |
whismanoid | 0:3edb3708c8c5 | 521 | DigitalOut CLRb_pin(D8); // Arduino 10-pin header D8 |
whismanoid | 0:3edb3708c8c5 | 522 | //~ DigitalIn RDYb_pin(D12); // Arduino 10-pin header D12 (MISO) |
whismanoid | 0:3edb3708c8c5 | 523 | MAX5715 g_MAX5715_device(spi, spi_cs, |
whismanoid | 0:3edb3708c8c5 | 524 | LDACb_pin, |
whismanoid | 0:3edb3708c8c5 | 525 | CLRb_pin, |
whismanoid | 0:3edb3708c8c5 | 526 | ///* RDYb_pin */ digitalInOut12, |
whismanoid | 0:3edb3708c8c5 | 527 | MAX5715::MAX5715_IC); |
whismanoid | 0:3edb3708c8c5 | 528 | // |
whismanoid | 0:3edb3708c8c5 | 529 | #elif APPLICATION_MAX11131 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 530 | DigitalOut CNVSTb_pin(D9); // Arduino 10-pin header D9 |
whismanoid | 0:3edb3708c8c5 | 531 | //DigitalOut CLRb_pin(D8); // Arduino 10-pin header D8 |
whismanoid | 0:3edb3708c8c5 | 532 | DigitalIn EOCb_pin(D12); // Arduino 10-pin header D12 (MISO) |
whismanoid | 0:3edb3708c8c5 | 533 | MAX11131 g_MAX11131_device(spi, spi_cs, |
whismanoid | 0:3edb3708c8c5 | 534 | CNVSTb_pin, |
whismanoid | 0:3edb3708c8c5 | 535 | EOCb_pin, |
whismanoid | 0:3edb3708c8c5 | 536 | ///* RDYb_pin */ digitalInOut12, |
whismanoid | 0:3edb3708c8c5 | 537 | MAX11131::MAX11131_IC); |
whismanoid | 0:3edb3708c8c5 | 538 | // |
whismanoid | 0:3edb3708c8c5 | 539 | // |
whismanoid | 0:3edb3708c8c5 | 540 | #elif APPLICATION_MAX5171 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 541 | // AnalogOut FB_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 542 | DigitalOut RS_pin(D9); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 543 | DigitalOut PDLb_pin(D8); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 544 | DigitalOut CLRb_pin(D7); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 545 | DigitalOut SHDN_pin(D6); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 546 | // AnalogIn OUT_pin(A0); // Analog Output from MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 547 | DigitalIn UPO_pin(D2); // Digital General-Purpose Output from MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 548 | MAX5171 g_MAX5171_device(spi, spi_cs, RS_pin, PDLb_pin, CLRb_pin, SHDN_pin, UPO_pin, MAX5171::MAX5171_IC); |
whismanoid | 0:3edb3708c8c5 | 549 | // |
whismanoid | 0:3edb3708c8c5 | 550 | #elif APPLICATION_MAX11410 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 551 | // |
whismanoid | 0:3edb3708c8c5 | 552 | MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC); |
whismanoid | 0:3edb3708c8c5 | 553 | // |
whismanoid | 0:3edb3708c8c5 | 554 | #elif APPLICATION_MAX12345 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 555 | // |
whismanoid | 0:3edb3708c8c5 | 556 | MAX12345 g_MAX12345_device(spi, spi_cs, ...); |
whismanoid | 0:3edb3708c8c5 | 557 | // |
whismanoid | 0:3edb3708c8c5 | 558 | #else // APPLICATION_ArduinoPinsMonitor diagnostic |
whismanoid | 0:3edb3708c8c5 | 559 | // |
whismanoid | 0:3edb3708c8c5 | 560 | #endif |
whismanoid | 0:3edb3708c8c5 | 561 | |
whismanoid | 0:3edb3708c8c5 | 562 | |
whismanoid | 0:3edb3708c8c5 | 563 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 564 | // Option to dedicate I2C port pins |
whismanoid | 0:3edb3708c8c5 | 565 | // |
whismanoid | 0:3edb3708c8c5 | 566 | #ifndef HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 567 | #define HAS_I2C 1 |
whismanoid | 0:3edb3708c8c5 | 568 | #endif |
whismanoid | 0:3edb3708c8c5 | 569 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 570 | //#include "I2C.h" |
whismanoid | 0:3edb3708c8c5 | 571 | //#include "I2CSlave.h" |
whismanoid | 0:3edb3708c8c5 | 572 | //#define I2C_SCL_Hz 400000 // 400kHz |
whismanoid | 0:3edb3708c8c5 | 573 | //#define I2C_SCL_Hz 200000 // 200kHz |
whismanoid | 0:3edb3708c8c5 | 574 | #define I2C_SCL_Hz 100000 // 100kHz |
whismanoid | 0:3edb3708c8c5 | 575 | // |
whismanoid | 0:3edb3708c8c5 | 576 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 577 | // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU |
whismanoid | 0:3edb3708c8c5 | 578 | const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz |
whismanoid | 0:3edb3708c8c5 | 579 | const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz |
whismanoid | 0:3edb3708c8c5 | 580 | // |
whismanoid | 0:3edb3708c8c5 | 581 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 582 | //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl MAX32630FTHR: NOT_CONNECTED |
whismanoid | 0:3edb3708c8c5 | 583 | //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl MAX32630FTHR: P3_4, P3_5 |
whismanoid | 0:3edb3708c8c5 | 584 | //I2C i2cMaster2(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0 |
whismanoid | 0:3edb3708c8c5 | 585 | //I2C i2cMaster(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0 |
whismanoid | 0:3edb3708c8c5 | 586 | // |
whismanoid | 0:3edb3708c8c5 | 587 | //I2CSlave i2cSlave0(I2C0_SDA, I2C0_SCL); // sda scl MAX32630FTHR: NOT_CONNECTED |
whismanoid | 0:3edb3708c8c5 | 588 | //I2CSlave i2cSlave1(I2C1_SDA, I2C1_SCL); // sda scl MAX32630FTHR: P3_4, P3_5 |
whismanoid | 0:3edb3708c8c5 | 589 | //I2CSlave i2cSlave2(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0 |
whismanoid | 0:3edb3708c8c5 | 590 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 591 | // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU |
whismanoid | 0:3edb3708c8c5 | 592 | const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz |
whismanoid | 0:3edb3708c8c5 | 593 | const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz |
whismanoid | 0:3edb3708c8c5 | 594 | // |
whismanoid | 0:3edb3708c8c5 | 595 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 596 | //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 597 | //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header |
whismanoid | 0:3edb3708c8c5 | 598 | // 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 | 599 | // |
whismanoid | 0:3edb3708c8c5 | 600 | #elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 601 | // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU |
whismanoid | 0:3edb3708c8c5 | 602 | const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz |
whismanoid | 0:3edb3708c8c5 | 603 | const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz |
whismanoid | 0:3edb3708c8c5 | 604 | // |
whismanoid | 0:3edb3708c8c5 | 605 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 606 | //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 607 | //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header |
whismanoid | 0:3edb3708c8c5 | 608 | // 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 | 609 | # ifndef I2C0_SDA |
whismanoid | 0:3edb3708c8c5 | 610 | # define I2C0_SDA I2C_SDA |
whismanoid | 0:3edb3708c8c5 | 611 | # define I2C0_SCL I2C_SCL |
whismanoid | 0:3edb3708c8c5 | 612 | # endif |
whismanoid | 0:3edb3708c8c5 | 613 | // |
whismanoid | 0:3edb3708c8c5 | 614 | #elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 615 | // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU |
whismanoid | 0:3edb3708c8c5 | 616 | const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz |
whismanoid | 0:3edb3708c8c5 | 617 | const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz |
whismanoid | 0:3edb3708c8c5 | 618 | // |
whismanoid | 0:3edb3708c8c5 | 619 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 620 | //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 621 | //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header |
whismanoid | 0:3edb3708c8c5 | 622 | // 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 | 623 | # ifndef I2C0_SDA |
whismanoid | 0:3edb3708c8c5 | 624 | # define I2C0_SDA I2C_SDA |
whismanoid | 0:3edb3708c8c5 | 625 | # define I2C0_SCL I2C_SCL |
whismanoid | 0:3edb3708c8c5 | 626 | # endif |
whismanoid | 0:3edb3708c8c5 | 627 | // |
whismanoid | 0:3edb3708c8c5 | 628 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 629 | #else |
whismanoid | 0:3edb3708c8c5 | 630 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 631 | #endif |
whismanoid | 0:3edb3708c8c5 | 632 | // |
whismanoid | 0:3edb3708c8c5 | 633 | #endif |
whismanoid | 0:3edb3708c8c5 | 634 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 635 | uint32_t g_I2C_SCL_Hz = I2C_SCL_Hz; |
whismanoid | 0:3edb3708c8c5 | 636 | uint8_t g_I2C_status = 0; // g_I2C_status = Wire_Sr.endTransmission(); |
whismanoid | 0:3edb3708c8c5 | 637 | uint8_t g_I2C_deviceAddress7 = (0xA0 >> 1); // I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified. |
whismanoid | 0:3edb3708c8c5 | 638 | uint8_t g_I2C_read_count = 0; |
whismanoid | 0:3edb3708c8c5 | 639 | uint8_t g_I2C_write_count = 0; |
whismanoid | 0:3edb3708c8c5 | 640 | uint8_t g_I2C_write_data[256]; |
whismanoid | 0:3edb3708c8c5 | 641 | uint8_t g_I2C_command_regAddress; |
whismanoid | 0:3edb3708c8c5 | 642 | // |
whismanoid | 0:3edb3708c8c5 | 643 | // TODO: i2c init |
whismanoid | 0:3edb3708c8c5 | 644 | // i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 645 | #endif |
whismanoid | 0:3edb3708c8c5 | 646 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 647 | // TODO: i2c transfer |
whismanoid | 0:3edb3708c8c5 | 648 | //const int addr7bit = 0x48; // 7 bit I2C address |
whismanoid | 0:3edb3708c8c5 | 649 | //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 |
whismanoid | 0:3edb3708c8c5 | 650 | // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 651 | // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 652 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 653 | // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 654 | // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 655 | // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 656 | // /* 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 | 657 | // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... |
whismanoid | 0:3edb3708c8c5 | 658 | #endif |
whismanoid | 0:3edb3708c8c5 | 659 | |
whismanoid | 0:3edb3708c8c5 | 660 | |
whismanoid | 0:3edb3708c8c5 | 661 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 662 | // Declare the Serial driver |
whismanoid | 0:3edb3708c8c5 | 663 | // default baud rate settings are 9600 8N1 |
whismanoid | 0:3edb3708c8c5 | 664 | // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe |
whismanoid | 0:3edb3708c8c5 | 665 | // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/ |
whismanoid | 0:3edb3708c8c5 | 666 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 667 | #include "USBSerial.h" |
whismanoid | 0:3edb3708c8c5 | 668 | // Hardware serial port over DAPLink |
whismanoid | 0:3edb3708c8c5 | 669 | // The default baud rate for the DapLink UART is 9600 |
whismanoid | 0:3edb3708c8c5 | 670 | Serial DAPLINKserial(P2_1, P2_0); // tx, rx |
whismanoid | 0:3edb3708c8c5 | 671 | #define HAS_DAPLINK_SERIAL 1 |
whismanoid | 0:3edb3708c8c5 | 672 | // Virtual serial port over USB |
whismanoid | 0:3edb3708c8c5 | 673 | // The baud rate does not affect the virtual USBSerial UART. |
whismanoid | 7:bf501f8cb637 | 674 | USBSerial serial; |
whismanoid | 0:3edb3708c8c5 | 675 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 676 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 677 | #include "USBSerial.h" |
whismanoid | 0:3edb3708c8c5 | 678 | // Hardware serial port over DAPLink |
whismanoid | 0:3edb3708c8c5 | 679 | // The default baud rate for the DapLink UART is 9600 |
whismanoid | 0:3edb3708c8c5 | 680 | Serial DAPLINKserial(P2_1, P2_0); // tx, rx |
whismanoid | 0:3edb3708c8c5 | 681 | #define HAS_DAPLINK_SERIAL 1 |
whismanoid | 0:3edb3708c8c5 | 682 | // Virtual serial port over USB |
whismanoid | 0:3edb3708c8c5 | 683 | // The baud rate does not affect the virtual USBSerial UART. |
whismanoid | 7:bf501f8cb637 | 684 | USBSerial serial; |
whismanoid | 0:3edb3708c8c5 | 685 | //-------------------------------------------------- |
whismanoid | 11:9fa2402071de | 686 | #elif defined(TARGET_MAX32600) |
whismanoid | 11:9fa2402071de | 687 | #include "USBSerial.h" |
whismanoid | 11:9fa2402071de | 688 | // Hardware serial port over DAPLink |
whismanoid | 11:9fa2402071de | 689 | // The default baud rate for the DapLink UART is 9600 |
whismanoid | 11:9fa2402071de | 690 | Serial DAPLINKserial(P1_1, P1_0); // tx, rx |
whismanoid | 11:9fa2402071de | 691 | #define HAS_DAPLINK_SERIAL 1 |
whismanoid | 11:9fa2402071de | 692 | // Virtual serial port over USB |
whismanoid | 11:9fa2402071de | 693 | // The baud rate does not affect the virtual USBSerial UART. |
whismanoid | 11:9fa2402071de | 694 | USBSerial serial; |
whismanoid | 11:9fa2402071de | 695 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 696 | #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) |
whismanoid | 7:bf501f8cb637 | 697 | Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx |
whismanoid | 0:3edb3708c8c5 | 698 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 699 | // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 700 | #elif defined(TARGET_LPC1768) |
whismanoid | 7:bf501f8cb637 | 701 | Serial serial(USBTX, USBRX); // tx, rx |
whismanoid | 0:3edb3708c8c5 | 702 | #else |
whismanoid | 0:3edb3708c8c5 | 703 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 704 | #endif |
whismanoid | 0:3edb3708c8c5 | 705 | |
whismanoid | 0:3edb3708c8c5 | 706 | void on_immediate_0x21(); // Unicode (U+0021) ! EXCLAMATION MARK |
whismanoid | 0:3edb3708c8c5 | 707 | void on_immediate_0x7b(); // Unicode (U+007B) { LEFT CURLY BRACKET |
whismanoid | 0:3edb3708c8c5 | 708 | void on_immediate_0x7d(); // Unicode (U+007D) } RIGHT CURLY BRACKET |
whismanoid | 0:3edb3708c8c5 | 709 | |
whismanoid | 0:3edb3708c8c5 | 710 | #include "CmdLine.h" |
whismanoid | 0:3edb3708c8c5 | 711 | |
whismanoid | 0:3edb3708c8c5 | 712 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 713 | CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK"); |
whismanoid | 0:3edb3708c8c5 | 714 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 7:bf501f8cb637 | 715 | CmdLine cmdLine_serial(serial, "serial"); |
whismanoid | 0:3edb3708c8c5 | 716 | |
whismanoid | 0:3edb3708c8c5 | 717 | |
whismanoid | 0:3edb3708c8c5 | 718 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 719 | // tolerate AT commands, which may be sent during probe, such as: |
whismanoid | 0:3edb3708c8c5 | 720 | // AT |
whismanoid | 0:3edb3708c8c5 | 721 | // AT+CGMI -- request manufacturer identification AT+CMGI=? |
whismanoid | 0:3edb3708c8c5 | 722 | // AT+CGMM -- request manufacturer model |
whismanoid | 0:3edb3708c8c5 | 723 | // AT%IPSYS? |
whismanoid | 0:3edb3708c8c5 | 724 | // ATE0 -- echo disable |
whismanoid | 0:3edb3708c8c5 | 725 | // ATV1 -- verbose result codes OK | ERROR | NO CARRIER |
whismanoid | 0:3edb3708c8c5 | 726 | // AT+CMEE=1 |
whismanoid | 0:3edb3708c8c5 | 727 | // ATX4 |
whismanoid | 0:3edb3708c8c5 | 728 | // AT&C1 |
whismanoid | 0:3edb3708c8c5 | 729 | // ATE0 |
whismanoid | 0:3edb3708c8c5 | 730 | // AT+CMEE=1 |
whismanoid | 0:3edb3708c8c5 | 731 | // AT+GCAP |
whismanoid | 0:3edb3708c8c5 | 732 | // ATI |
whismanoid | 0:3edb3708c8c5 | 733 | // AT+CPIN? |
whismanoid | 0:3edb3708c8c5 | 734 | // AT+CGMM |
whismanoid | 0:3edb3708c8c5 | 735 | #ifndef IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 736 | #define IGNORE_AT_COMMANDS 1 |
whismanoid | 0:3edb3708c8c5 | 737 | #endif |
whismanoid | 0:3edb3708c8c5 | 738 | |
whismanoid | 0:3edb3708c8c5 | 739 | |
whismanoid | 0:3edb3708c8c5 | 740 | // uncrustify-0.66.1 *INDENT-OFF* |
whismanoid | 0:3edb3708c8c5 | 741 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 742 | // Declare the DigitalInOut GPIO pins |
whismanoid | 0:3edb3708c8c5 | 743 | // Optional digitalInOut support. If there is only one it should be digitalInOut1. |
whismanoid | 0:3edb3708c8c5 | 744 | // D) Digital High/Low/Input Pin |
whismanoid | 0:3edb3708c8c5 | 745 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 746 | // +-------------[microUSB]-------------+ |
whismanoid | 0:3edb3708c8c5 | 747 | // | J1 MAX32630FTHR J2 | |
whismanoid | 0:3edb3708c8c5 | 748 | // | [ ] RST GND [ ] | |
whismanoid | 0:3edb3708c8c5 | 749 | // | [ ] 3V3 BAT+[ ] | |
whismanoid | 0:3edb3708c8c5 | 750 | // | [ ] 1V8 reset SW1 | |
whismanoid | 0:3edb3708c8c5 | 751 | // | [ ] GND J4 J3 | |
whismanoid | 0:3edb3708c8c5 | 752 | // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] | |
whismanoid | 0:3edb3708c8c5 | 753 | // | [ ] AIN_1 1.2Vfs PWR [ ] | |
whismanoid | 0:3edb3708c8c5 | 754 | // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] | |
whismanoid | 0:3edb3708c8c5 | 755 | // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9 |
whismanoid | 0:3edb3708c8c5 | 756 | // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8 |
whismanoid | 0:3edb3708c8c5 | 757 | // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7 |
whismanoid | 0:3edb3708c8c5 | 758 | // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6 |
whismanoid | 0:3edb3708c8c5 | 759 | // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5 |
whismanoid | 0:3edb3708c8c5 | 760 | // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4 |
whismanoid | 0:3edb3708c8c5 | 761 | // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3 |
whismanoid | 0:3edb3708c8c5 | 762 | // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2 |
whismanoid | 0:3edb3708c8c5 | 763 | // | [ ] GND SDA P3_4 [x] | dig1 |
whismanoid | 0:3edb3708c8c5 | 764 | // +------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 765 | #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15 |
whismanoid | 0:3edb3708c8c5 | 766 | #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12 |
whismanoid | 0:3edb3708c8c5 | 767 | #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11 |
whismanoid | 0:3edb3708c8c5 | 768 | #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10 |
whismanoid | 0:3edb3708c8c5 | 769 | #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9 |
whismanoid | 0:3edb3708c8c5 | 770 | #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8 |
whismanoid | 0:3edb3708c8c5 | 771 | #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7 |
whismanoid | 0:3edb3708c8c5 | 772 | #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6 |
whismanoid | 0:3edb3708c8c5 | 773 | #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5 |
whismanoid | 0:3edb3708c8c5 | 774 | #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4 |
whismanoid | 0:3edb3708c8c5 | 775 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 776 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 777 | #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9 |
whismanoid | 0:3edb3708c8c5 | 778 | #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10 |
whismanoid | 0:3edb3708c8c5 | 779 | #else // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 780 | #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9 |
whismanoid | 0:3edb3708c8c5 | 781 | #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10 |
whismanoid | 0:3edb3708c8c5 | 782 | #endif // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 783 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 784 | // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 785 | #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11 |
whismanoid | 0:3edb3708c8c5 | 786 | #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12 |
whismanoid | 0:3edb3708c8c5 | 787 | #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13 |
whismanoid | 0:3edb3708c8c5 | 788 | #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14 |
whismanoid | 0:3edb3708c8c5 | 789 | #else // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 790 | #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11 |
whismanoid | 0:3edb3708c8c5 | 791 | #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12 |
whismanoid | 0:3edb3708c8c5 | 792 | #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13 |
whismanoid | 0:3edb3708c8c5 | 793 | #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14 |
whismanoid | 0:3edb3708c8c5 | 794 | #endif // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 795 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 796 | DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15 |
whismanoid | 0:3edb3708c8c5 | 797 | #endif |
whismanoid | 0:3edb3708c8c5 | 798 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 799 | DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12 |
whismanoid | 0:3edb3708c8c5 | 800 | #endif |
whismanoid | 0:3edb3708c8c5 | 801 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 802 | DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11 |
whismanoid | 0:3edb3708c8c5 | 803 | #endif |
whismanoid | 0:3edb3708c8c5 | 804 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 805 | DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10 |
whismanoid | 0:3edb3708c8c5 | 806 | #endif |
whismanoid | 0:3edb3708c8c5 | 807 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 808 | DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9 |
whismanoid | 0:3edb3708c8c5 | 809 | #endif |
whismanoid | 0:3edb3708c8c5 | 810 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 811 | DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8 |
whismanoid | 0:3edb3708c8c5 | 812 | #endif |
whismanoid | 0:3edb3708c8c5 | 813 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 814 | DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7 |
whismanoid | 0:3edb3708c8c5 | 815 | #endif |
whismanoid | 0:3edb3708c8c5 | 816 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 817 | DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6 |
whismanoid | 0:3edb3708c8c5 | 818 | #endif |
whismanoid | 0:3edb3708c8c5 | 819 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 820 | DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5 |
whismanoid | 0:3edb3708c8c5 | 821 | #endif |
whismanoid | 0:3edb3708c8c5 | 822 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 823 | DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4 |
whismanoid | 0:3edb3708c8c5 | 824 | #endif |
whismanoid | 0:3edb3708c8c5 | 825 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 826 | DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9 |
whismanoid | 0:3edb3708c8c5 | 827 | #endif |
whismanoid | 0:3edb3708c8c5 | 828 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 829 | DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10 |
whismanoid | 0:3edb3708c8c5 | 830 | #endif |
whismanoid | 0:3edb3708c8c5 | 831 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 832 | DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11 |
whismanoid | 0:3edb3708c8c5 | 833 | #endif |
whismanoid | 0:3edb3708c8c5 | 834 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 835 | DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12 |
whismanoid | 0:3edb3708c8c5 | 836 | #endif |
whismanoid | 0:3edb3708c8c5 | 837 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 838 | DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13 |
whismanoid | 0:3edb3708c8c5 | 839 | #endif |
whismanoid | 0:3edb3708c8c5 | 840 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 841 | DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14 |
whismanoid | 0:3edb3708c8c5 | 842 | #endif |
whismanoid | 0:3edb3708c8c5 | 843 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 844 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 845 | // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 846 | // +-------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 847 | // | MAX32625MBED Arduino UNO header | |
whismanoid | 0:3edb3708c8c5 | 848 | // | | |
whismanoid | 0:3edb3708c8c5 | 849 | // | A5/SCL[ ] | P1_7 dig15 |
whismanoid | 0:3edb3708c8c5 | 850 | // | A4/SDA[ ] | P1_6 dig14 |
whismanoid | 0:3edb3708c8c5 | 851 | // | AREF=N/C[ ] | |
whismanoid | 0:3edb3708c8c5 | 852 | // | GND[ ] | |
whismanoid | 0:3edb3708c8c5 | 853 | // | [ ]N/C SCK/13[ ] | P1_0 dig13 |
whismanoid | 0:3edb3708c8c5 | 854 | // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12 |
whismanoid | 0:3edb3708c8c5 | 855 | // | [ ]RST MOSI/11[ ]~| P1_1 dig11 |
whismanoid | 0:3edb3708c8c5 | 856 | // | [ ]3V3 CS/10[ ]~| P1_3 dig10 |
whismanoid | 0:3edb3708c8c5 | 857 | // | [ ]5V0 9[ ]~| P1_5 dig9 |
whismanoid | 0:3edb3708c8c5 | 858 | // | [ ]GND 8[ ] | P1_4 dig8 |
whismanoid | 0:3edb3708c8c5 | 859 | // | [ ]GND | |
whismanoid | 0:3edb3708c8c5 | 860 | // | [ ]Vin 7[ ] | P0_7 dig7 |
whismanoid | 0:3edb3708c8c5 | 861 | // | 6[ ]~| P0_6 dig6 |
whismanoid | 0:3edb3708c8c5 | 862 | // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5 |
whismanoid | 0:3edb3708c8c5 | 863 | // AIN_1 | [ ]A1 4[ ] | P0_4 dig4 |
whismanoid | 0:3edb3708c8c5 | 864 | // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3 |
whismanoid | 0:3edb3708c8c5 | 865 | // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2 |
whismanoid | 0:3edb3708c8c5 | 866 | // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1 |
whismanoid | 0:3edb3708c8c5 | 867 | // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0 |
whismanoid | 0:3edb3708c8c5 | 868 | // | [ ] [ ] [ ] | |
whismanoid | 0:3edb3708c8c5 | 869 | // | UNO_R3 GND MOSI 5V ____________/ |
whismanoid | 0:3edb3708c8c5 | 870 | // \_______________________/ |
whismanoid | 0:3edb3708c8c5 | 871 | // |
whismanoid | 0:3edb3708c8c5 | 872 | #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0 |
whismanoid | 0:3edb3708c8c5 | 873 | #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1 |
whismanoid | 0:3edb3708c8c5 | 874 | #if APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 875 | #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn |
whismanoid | 0:3edb3708c8c5 | 876 | #else |
whismanoid | 0:3edb3708c8c5 | 877 | #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2 |
whismanoid | 0:3edb3708c8c5 | 878 | #endif |
whismanoid | 0:3edb3708c8c5 | 879 | #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3 |
whismanoid | 0:3edb3708c8c5 | 880 | #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4 |
whismanoid | 0:3edb3708c8c5 | 881 | #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5 |
whismanoid | 0:3edb3708c8c5 | 882 | #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6 |
whismanoid | 0:3edb3708c8c5 | 883 | #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7 |
whismanoid | 0:3edb3708c8c5 | 884 | #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8 |
whismanoid | 0:3edb3708c8c5 | 885 | #if APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 886 | #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut |
whismanoid | 0:3edb3708c8c5 | 887 | #else |
whismanoid | 0:3edb3708c8c5 | 888 | #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9 |
whismanoid | 0:3edb3708c8c5 | 889 | #endif |
whismanoid | 0:3edb3708c8c5 | 890 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 891 | // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 892 | #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10 |
whismanoid | 0:3edb3708c8c5 | 893 | #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11 |
whismanoid | 0:3edb3708c8c5 | 894 | #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12 |
whismanoid | 0:3edb3708c8c5 | 895 | #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13 |
whismanoid | 0:3edb3708c8c5 | 896 | #else // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 897 | #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10 |
whismanoid | 0:3edb3708c8c5 | 898 | #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11 |
whismanoid | 0:3edb3708c8c5 | 899 | #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12 |
whismanoid | 0:3edb3708c8c5 | 900 | #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13 |
whismanoid | 0:3edb3708c8c5 | 901 | #endif // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 902 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 903 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 904 | #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 905 | #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 906 | #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 907 | #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 908 | #else // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 909 | #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 910 | #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 911 | #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 912 | #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 913 | #endif // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 914 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 915 | DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0 |
whismanoid | 0:3edb3708c8c5 | 916 | #endif |
whismanoid | 0:3edb3708c8c5 | 917 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 918 | DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1 |
whismanoid | 0:3edb3708c8c5 | 919 | #endif |
whismanoid | 0:3edb3708c8c5 | 920 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 921 | DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2 |
whismanoid | 0:3edb3708c8c5 | 922 | #endif |
whismanoid | 0:3edb3708c8c5 | 923 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 924 | DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3 |
whismanoid | 0:3edb3708c8c5 | 925 | #endif |
whismanoid | 0:3edb3708c8c5 | 926 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 927 | DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4 |
whismanoid | 0:3edb3708c8c5 | 928 | #endif |
whismanoid | 0:3edb3708c8c5 | 929 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 930 | DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5 |
whismanoid | 0:3edb3708c8c5 | 931 | #endif |
whismanoid | 0:3edb3708c8c5 | 932 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 933 | DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6 |
whismanoid | 0:3edb3708c8c5 | 934 | #endif |
whismanoid | 0:3edb3708c8c5 | 935 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 936 | DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7 |
whismanoid | 0:3edb3708c8c5 | 937 | #endif |
whismanoid | 0:3edb3708c8c5 | 938 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 939 | DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8 |
whismanoid | 0:3edb3708c8c5 | 940 | #endif |
whismanoid | 0:3edb3708c8c5 | 941 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 942 | DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9 |
whismanoid | 0:3edb3708c8c5 | 943 | #endif |
whismanoid | 0:3edb3708c8c5 | 944 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 945 | DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10 |
whismanoid | 0:3edb3708c8c5 | 946 | #endif |
whismanoid | 0:3edb3708c8c5 | 947 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 948 | DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11 |
whismanoid | 0:3edb3708c8c5 | 949 | #endif |
whismanoid | 0:3edb3708c8c5 | 950 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 951 | DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12 |
whismanoid | 0:3edb3708c8c5 | 952 | #endif |
whismanoid | 0:3edb3708c8c5 | 953 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 954 | DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13 |
whismanoid | 0:3edb3708c8c5 | 955 | #endif |
whismanoid | 0:3edb3708c8c5 | 956 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 957 | // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 |
whismanoid | 0:3edb3708c8c5 | 958 | // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain |
whismanoid | 0:3edb3708c8c5 | 959 | DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 960 | #endif |
whismanoid | 0:3edb3708c8c5 | 961 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 962 | // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 |
whismanoid | 0:3edb3708c8c5 | 963 | DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 964 | #endif |
whismanoid | 0:3edb3708c8c5 | 965 | #if HAS_digitalInOut16 |
whismanoid | 0:3edb3708c8c5 | 966 | // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 |
whismanoid | 0:3edb3708c8c5 | 967 | // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain |
whismanoid | 0:3edb3708c8c5 | 968 | // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V |
whismanoid | 0:3edb3708c8c5 | 969 | DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 970 | #endif |
whismanoid | 0:3edb3708c8c5 | 971 | #if HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 972 | // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 |
whismanoid | 0:3edb3708c8c5 | 973 | DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 974 | #endif |
whismanoid | 0:3edb3708c8c5 | 975 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 976 | #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 977 | #define HAS_digitalInOut0 0 // P0_0 TARGET_MAX32625MBED D0 |
whismanoid | 0:3edb3708c8c5 | 978 | #define HAS_digitalInOut1 0 // P0_1 TARGET_MAX32625MBED D1 |
whismanoid | 0:3edb3708c8c5 | 979 | #if APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 980 | #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn |
whismanoid | 0:3edb3708c8c5 | 981 | #else |
whismanoid | 0:3edb3708c8c5 | 982 | #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2 |
whismanoid | 0:3edb3708c8c5 | 983 | #endif |
whismanoid | 0:3edb3708c8c5 | 984 | #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3 |
whismanoid | 0:3edb3708c8c5 | 985 | #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4 |
whismanoid | 0:3edb3708c8c5 | 986 | #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5 |
whismanoid | 0:3edb3708c8c5 | 987 | #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6 |
whismanoid | 0:3edb3708c8c5 | 988 | #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7 |
whismanoid | 0:3edb3708c8c5 | 989 | #if APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 990 | #define HAS_digitalInOut8 0 // P1_4 TARGET_MAX32625MBED D8 -- MAX5715 CLRb DigitalOut |
whismanoid | 0:3edb3708c8c5 | 991 | #else |
whismanoid | 0:3edb3708c8c5 | 992 | #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8 |
whismanoid | 0:3edb3708c8c5 | 993 | #endif |
whismanoid | 0:3edb3708c8c5 | 994 | #if APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 995 | #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX5715 LDACb DigitalOut |
whismanoid | 0:3edb3708c8c5 | 996 | #elif APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 997 | #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut |
whismanoid | 0:3edb3708c8c5 | 998 | #else |
whismanoid | 0:3edb3708c8c5 | 999 | #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9 |
whismanoid | 0:3edb3708c8c5 | 1000 | #endif |
whismanoid | 0:3edb3708c8c5 | 1001 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 1002 | // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 1003 | // Arduino digital pin D10 SPI function is CS/10 |
whismanoid | 0:3edb3708c8c5 | 1004 | // Arduino digital pin D11 SPI function is MOSI/11 |
whismanoid | 0:3edb3708c8c5 | 1005 | // Arduino digital pin D12 SPI function is MISO/12 |
whismanoid | 0:3edb3708c8c5 | 1006 | // Arduino digital pin D13 SPI function is SCK/13 |
whismanoid | 0:3edb3708c8c5 | 1007 | #define HAS_digitalInOut10 0 |
whismanoid | 0:3edb3708c8c5 | 1008 | #define HAS_digitalInOut11 0 |
whismanoid | 0:3edb3708c8c5 | 1009 | #define HAS_digitalInOut12 0 |
whismanoid | 0:3edb3708c8c5 | 1010 | #define HAS_digitalInOut13 0 |
whismanoid | 0:3edb3708c8c5 | 1011 | #else // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 1012 | #define HAS_digitalInOut10 1 |
whismanoid | 0:3edb3708c8c5 | 1013 | #define HAS_digitalInOut11 1 |
whismanoid | 0:3edb3708c8c5 | 1014 | #define HAS_digitalInOut12 1 |
whismanoid | 0:3edb3708c8c5 | 1015 | #define HAS_digitalInOut13 1 |
whismanoid | 0:3edb3708c8c5 | 1016 | #endif // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 1017 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 1018 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 1019 | // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 1020 | // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 1021 | // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 1022 | // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 1023 | #define HAS_digitalInOut14 0 |
whismanoid | 0:3edb3708c8c5 | 1024 | #define HAS_digitalInOut15 0 |
whismanoid | 0:3edb3708c8c5 | 1025 | #define HAS_digitalInOut16 0 |
whismanoid | 0:3edb3708c8c5 | 1026 | #define HAS_digitalInOut17 0 |
whismanoid | 0:3edb3708c8c5 | 1027 | #else // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 1028 | #define HAS_digitalInOut14 1 |
whismanoid | 0:3edb3708c8c5 | 1029 | #define HAS_digitalInOut15 1 |
whismanoid | 0:3edb3708c8c5 | 1030 | #define HAS_digitalInOut16 0 |
whismanoid | 0:3edb3708c8c5 | 1031 | #define HAS_digitalInOut17 0 |
whismanoid | 0:3edb3708c8c5 | 1032 | #endif // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 1033 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 1034 | DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1035 | #endif |
whismanoid | 0:3edb3708c8c5 | 1036 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 1037 | DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1038 | #endif |
whismanoid | 0:3edb3708c8c5 | 1039 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 1040 | DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1041 | #endif |
whismanoid | 0:3edb3708c8c5 | 1042 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 1043 | DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1044 | #endif |
whismanoid | 0:3edb3708c8c5 | 1045 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 1046 | DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1047 | #endif |
whismanoid | 0:3edb3708c8c5 | 1048 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 1049 | DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1050 | #endif |
whismanoid | 0:3edb3708c8c5 | 1051 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 1052 | DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1053 | #endif |
whismanoid | 0:3edb3708c8c5 | 1054 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 1055 | DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1056 | #endif |
whismanoid | 0:3edb3708c8c5 | 1057 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 1058 | DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1059 | #endif |
whismanoid | 0:3edb3708c8c5 | 1060 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 1061 | DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1062 | #endif |
whismanoid | 0:3edb3708c8c5 | 1063 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 1064 | // Arduino digital pin D10 SPI function is CS/10 |
whismanoid | 0:3edb3708c8c5 | 1065 | DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1066 | #endif |
whismanoid | 0:3edb3708c8c5 | 1067 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 1068 | // Arduino digital pin D11 SPI function is MOSI/11 |
whismanoid | 0:3edb3708c8c5 | 1069 | DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1070 | #endif |
whismanoid | 0:3edb3708c8c5 | 1071 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 1072 | // Arduino digital pin D12 SPI function is MISO/12 |
whismanoid | 0:3edb3708c8c5 | 1073 | DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1074 | #endif |
whismanoid | 0:3edb3708c8c5 | 1075 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 1076 | // Arduino digital pin D13 SPI function is SCK/13 |
whismanoid | 0:3edb3708c8c5 | 1077 | DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1078 | #endif |
whismanoid | 0:3edb3708c8c5 | 1079 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 1080 | // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 1081 | DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1082 | #endif |
whismanoid | 0:3edb3708c8c5 | 1083 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 1084 | // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 1085 | DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1086 | #endif |
whismanoid | 0:3edb3708c8c5 | 1087 | #if HAS_digitalInOut16 |
whismanoid | 0:3edb3708c8c5 | 1088 | // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 1089 | DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1090 | #endif |
whismanoid | 0:3edb3708c8c5 | 1091 | #if HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 1092 | // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 1093 | DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1094 | #endif |
whismanoid | 0:3edb3708c8c5 | 1095 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1096 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 1097 | #define HAS_digitalInOut0 1 |
whismanoid | 0:3edb3708c8c5 | 1098 | #define HAS_digitalInOut1 1 |
whismanoid | 0:3edb3708c8c5 | 1099 | #define HAS_digitalInOut2 1 |
whismanoid | 0:3edb3708c8c5 | 1100 | #define HAS_digitalInOut3 1 |
whismanoid | 0:3edb3708c8c5 | 1101 | #define HAS_digitalInOut4 1 |
whismanoid | 0:3edb3708c8c5 | 1102 | #define HAS_digitalInOut5 1 |
whismanoid | 0:3edb3708c8c5 | 1103 | #define HAS_digitalInOut6 1 |
whismanoid | 0:3edb3708c8c5 | 1104 | #define HAS_digitalInOut7 1 |
whismanoid | 0:3edb3708c8c5 | 1105 | #define HAS_digitalInOut8 1 |
whismanoid | 0:3edb3708c8c5 | 1106 | #define HAS_digitalInOut9 1 |
whismanoid | 0:3edb3708c8c5 | 1107 | // #define HAS_digitalInOut10 1 |
whismanoid | 0:3edb3708c8c5 | 1108 | // #define HAS_digitalInOut11 1 |
whismanoid | 0:3edb3708c8c5 | 1109 | // #define HAS_digitalInOut12 1 |
whismanoid | 0:3edb3708c8c5 | 1110 | // #define HAS_digitalInOut13 1 |
whismanoid | 0:3edb3708c8c5 | 1111 | // #define HAS_digitalInOut14 1 |
whismanoid | 0:3edb3708c8c5 | 1112 | // #define HAS_digitalInOut15 1 |
whismanoid | 0:3edb3708c8c5 | 1113 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 1114 | DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3 |
whismanoid | 0:3edb3708c8c5 | 1115 | #endif |
whismanoid | 0:3edb3708c8c5 | 1116 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 1117 | DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2 |
whismanoid | 0:3edb3708c8c5 | 1118 | #endif |
whismanoid | 0:3edb3708c8c5 | 1119 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 1120 | DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1 |
whismanoid | 0:3edb3708c8c5 | 1121 | #endif |
whismanoid | 0:3edb3708c8c5 | 1122 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 1123 | DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0 |
whismanoid | 0:3edb3708c8c5 | 1124 | #endif |
whismanoid | 0:3edb3708c8c5 | 1125 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 1126 | DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1 |
whismanoid | 0:3edb3708c8c5 | 1127 | #endif |
whismanoid | 0:3edb3708c8c5 | 1128 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 1129 | DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1 |
whismanoid | 0:3edb3708c8c5 | 1130 | #endif |
whismanoid | 0:3edb3708c8c5 | 1131 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 1132 | DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1 |
whismanoid | 0:3edb3708c8c5 | 1133 | #endif |
whismanoid | 0:3edb3708c8c5 | 1134 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 1135 | DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO |
whismanoid | 0:3edb3708c8c5 | 1136 | #endif |
whismanoid | 0:3edb3708c8c5 | 1137 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 1138 | DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK |
whismanoid | 0:3edb3708c8c5 | 1139 | #endif |
whismanoid | 0:3edb3708c8c5 | 1140 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 1141 | DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL |
whismanoid | 0:3edb3708c8c5 | 1142 | #endif |
whismanoid | 0:3edb3708c8c5 | 1143 | // |
whismanoid | 0:3edb3708c8c5 | 1144 | // these pins support analog input analogIn0 .. analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1145 | //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0 |
whismanoid | 0:3edb3708c8c5 | 1146 | //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1 |
whismanoid | 0:3edb3708c8c5 | 1147 | //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3 |
whismanoid | 0:3edb3708c8c5 | 1148 | //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3 |
whismanoid | 0:3edb3708c8c5 | 1149 | //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4 |
whismanoid | 0:3edb3708c8c5 | 1150 | //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5 |
whismanoid | 0:3edb3708c8c5 | 1151 | // |
whismanoid | 0:3edb3708c8c5 | 1152 | // these pins support PWM pwmDriver1 .. pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 1153 | //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0 |
whismanoid | 0:3edb3708c8c5 | 1154 | //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1 |
whismanoid | 0:3edb3708c8c5 | 1155 | //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2 |
whismanoid | 0:3edb3708c8c5 | 1156 | //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3 |
whismanoid | 0:3edb3708c8c5 | 1157 | //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1 |
whismanoid | 0:3edb3708c8c5 | 1158 | //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK |
whismanoid | 0:3edb3708c8c5 | 1159 | // |
whismanoid | 0:3edb3708c8c5 | 1160 | // these could be additional digitalInOut pins |
whismanoid | 0:3edb3708c8c5 | 1161 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 1162 | DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1 |
whismanoid | 0:3edb3708c8c5 | 1163 | #endif |
whismanoid | 0:3edb3708c8c5 | 1164 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 1165 | DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0 |
whismanoid | 0:3edb3708c8c5 | 1166 | #endif |
whismanoid | 0:3edb3708c8c5 | 1167 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 1168 | DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1 |
whismanoid | 0:3edb3708c8c5 | 1169 | #endif |
whismanoid | 0:3edb3708c8c5 | 1170 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 1171 | DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0 |
whismanoid | 0:3edb3708c8c5 | 1172 | #endif |
whismanoid | 0:3edb3708c8c5 | 1173 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 1174 | DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1175 | #endif |
whismanoid | 0:3edb3708c8c5 | 1176 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 1177 | DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1178 | #endif |
whismanoid | 0:3edb3708c8c5 | 1179 | #else |
whismanoid | 0:3edb3708c8c5 | 1180 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 1181 | #endif |
whismanoid | 0:3edb3708c8c5 | 1182 | // uncrustify-0.66.1 *INDENT-ON* |
whismanoid | 0:3edb3708c8c5 | 1183 | #if HAS_digitalInOut0 || HAS_digitalInOut1 \ |
whismanoid | 0:3edb3708c8c5 | 1184 | || HAS_digitalInOut2 || HAS_digitalInOut3 \ |
whismanoid | 0:3edb3708c8c5 | 1185 | || HAS_digitalInOut4 || HAS_digitalInOut5 \ |
whismanoid | 0:3edb3708c8c5 | 1186 | || HAS_digitalInOut6 || HAS_digitalInOut7 \ |
whismanoid | 0:3edb3708c8c5 | 1187 | || HAS_digitalInOut8 || HAS_digitalInOut9 \ |
whismanoid | 0:3edb3708c8c5 | 1188 | || HAS_digitalInOut10 || HAS_digitalInOut11 \ |
whismanoid | 0:3edb3708c8c5 | 1189 | || HAS_digitalInOut12 || HAS_digitalInOut13 \ |
whismanoid | 0:3edb3708c8c5 | 1190 | || HAS_digitalInOut14 || HAS_digitalInOut15 \ |
whismanoid | 0:3edb3708c8c5 | 1191 | || HAS_digitalInOut16 || HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 1192 | #define HAS_digitalInOuts 1 |
whismanoid | 0:3edb3708c8c5 | 1193 | #endif |
whismanoid | 0:3edb3708c8c5 | 1194 | |
whismanoid | 0:3edb3708c8c5 | 1195 | // uncrustify-0.66.1 *INDENT-OFF* |
whismanoid | 0:3edb3708c8c5 | 1196 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1197 | // Declare the AnalogIn driver |
whismanoid | 0:3edb3708c8c5 | 1198 | // Optional analogIn support. If there is only one it should be analogIn1. |
whismanoid | 0:3edb3708c8c5 | 1199 | // A) analog input |
whismanoid | 0:3edb3708c8c5 | 1200 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 1201 | #define HAS_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 1202 | #define HAS_analogIn1 1 |
whismanoid | 0:3edb3708c8c5 | 1203 | #define HAS_analogIn2 1 |
whismanoid | 0:3edb3708c8c5 | 1204 | #define HAS_analogIn3 1 |
whismanoid | 0:3edb3708c8c5 | 1205 | #define HAS_analogIn4 1 |
whismanoid | 0:3edb3708c8c5 | 1206 | #define HAS_analogIn5 1 |
whismanoid | 0:3edb3708c8c5 | 1207 | #define HAS_analogIn6 1 |
whismanoid | 0:3edb3708c8c5 | 1208 | #define HAS_analogIn7 1 |
whismanoid | 0:3edb3708c8c5 | 1209 | #define HAS_analogIn8 1 |
whismanoid | 0:3edb3708c8c5 | 1210 | #define HAS_analogIn9 1 |
whismanoid | 0:3edb3708c8c5 | 1211 | // #define HAS_analogIn10 0 |
whismanoid | 0:3edb3708c8c5 | 1212 | // #define HAS_analogIn11 0 |
whismanoid | 0:3edb3708c8c5 | 1213 | // #define HAS_analogIn12 0 |
whismanoid | 0:3edb3708c8c5 | 1214 | // #define HAS_analogIn13 0 |
whismanoid | 0:3edb3708c8c5 | 1215 | // #define HAS_analogIn14 0 |
whismanoid | 0:3edb3708c8c5 | 1216 | // #define HAS_analogIn15 0 |
whismanoid | 0:3edb3708c8c5 | 1217 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 1218 | AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1219 | #endif |
whismanoid | 0:3edb3708c8c5 | 1220 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 1221 | AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1222 | #endif |
whismanoid | 0:3edb3708c8c5 | 1223 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 1224 | AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1225 | #endif |
whismanoid | 0:3edb3708c8c5 | 1226 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 1227 | AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1228 | #endif |
whismanoid | 0:3edb3708c8c5 | 1229 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 1230 | AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 1231 | #endif |
whismanoid | 0:3edb3708c8c5 | 1232 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1233 | AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 1234 | #endif |
whismanoid | 0:3edb3708c8c5 | 1235 | #if HAS_analogIn6 |
whismanoid | 0:3edb3708c8c5 | 1236 | AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 1237 | #endif |
whismanoid | 0:3edb3708c8c5 | 1238 | #if HAS_analogIn7 |
whismanoid | 0:3edb3708c8c5 | 1239 | AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1240 | #endif |
whismanoid | 0:3edb3708c8c5 | 1241 | #if HAS_analogIn8 |
whismanoid | 0:3edb3708c8c5 | 1242 | AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1243 | #endif |
whismanoid | 0:3edb3708c8c5 | 1244 | #if HAS_analogIn9 |
whismanoid | 0:3edb3708c8c5 | 1245 | AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V |
whismanoid | 0:3edb3708c8c5 | 1246 | #endif |
whismanoid | 0:3edb3708c8c5 | 1247 | #if HAS_analogIn10 |
whismanoid | 0:3edb3708c8c5 | 1248 | AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined? |
whismanoid | 0:3edb3708c8c5 | 1249 | #endif |
whismanoid | 0:3edb3708c8c5 | 1250 | #if HAS_analogIn11 |
whismanoid | 0:3edb3708c8c5 | 1251 | AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 1252 | #endif |
whismanoid | 0:3edb3708c8c5 | 1253 | #if HAS_analogIn12 |
whismanoid | 0:3edb3708c8c5 | 1254 | AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 1255 | #endif |
whismanoid | 0:3edb3708c8c5 | 1256 | #if HAS_analogIn13 |
whismanoid | 0:3edb3708c8c5 | 1257 | AnalogIn analogIn13(____); |
whismanoid | 0:3edb3708c8c5 | 1258 | #endif |
whismanoid | 0:3edb3708c8c5 | 1259 | #if HAS_analogIn14 |
whismanoid | 0:3edb3708c8c5 | 1260 | AnalogIn analogIn14(____); |
whismanoid | 0:3edb3708c8c5 | 1261 | #endif |
whismanoid | 0:3edb3708c8c5 | 1262 | #if HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 1263 | AnalogIn analogIn15(____); |
whismanoid | 0:3edb3708c8c5 | 1264 | #endif |
whismanoid | 0:3edb3708c8c5 | 1265 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1266 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 1267 | #define HAS_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 1268 | #define HAS_analogIn1 1 |
whismanoid | 0:3edb3708c8c5 | 1269 | #define HAS_analogIn2 1 |
whismanoid | 0:3edb3708c8c5 | 1270 | #define HAS_analogIn3 1 |
whismanoid | 0:3edb3708c8c5 | 1271 | #define HAS_analogIn4 1 |
whismanoid | 0:3edb3708c8c5 | 1272 | #define HAS_analogIn5 1 |
whismanoid | 0:3edb3708c8c5 | 1273 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 1274 | AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1275 | #endif |
whismanoid | 0:3edb3708c8c5 | 1276 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 1277 | AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1278 | #endif |
whismanoid | 0:3edb3708c8c5 | 1279 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 1280 | AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1281 | #endif |
whismanoid | 0:3edb3708c8c5 | 1282 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 1283 | AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1284 | #endif |
whismanoid | 0:3edb3708c8c5 | 1285 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 1286 | AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 1287 | #endif |
whismanoid | 0:3edb3708c8c5 | 1288 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1289 | AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 1290 | #endif |
whismanoid | 0:3edb3708c8c5 | 1291 | //-------------------------------------------------- |
whismanoid | 11:9fa2402071de | 1292 | #elif defined(TARGET_MAX32600) |
whismanoid | 11:9fa2402071de | 1293 | #define HAS_analogIn0 1 |
whismanoid | 11:9fa2402071de | 1294 | #define HAS_analogIn1 1 |
whismanoid | 11:9fa2402071de | 1295 | #define HAS_analogIn2 1 |
whismanoid | 11:9fa2402071de | 1296 | #define HAS_analogIn3 1 |
whismanoid | 11:9fa2402071de | 1297 | #define HAS_analogIn4 1 |
whismanoid | 11:9fa2402071de | 1298 | #define HAS_analogIn5 1 |
whismanoid | 11:9fa2402071de | 1299 | #if HAS_analogIn0 |
whismanoid | 11:9fa2402071de | 1300 | AnalogIn analogIn0(A0); |
whismanoid | 11:9fa2402071de | 1301 | #endif |
whismanoid | 11:9fa2402071de | 1302 | #if HAS_analogIn1 |
whismanoid | 11:9fa2402071de | 1303 | AnalogIn analogIn1(A1); |
whismanoid | 11:9fa2402071de | 1304 | #endif |
whismanoid | 11:9fa2402071de | 1305 | #if HAS_analogIn2 |
whismanoid | 11:9fa2402071de | 1306 | AnalogIn analogIn2(A2); |
whismanoid | 11:9fa2402071de | 1307 | #endif |
whismanoid | 11:9fa2402071de | 1308 | #if HAS_analogIn3 |
whismanoid | 11:9fa2402071de | 1309 | AnalogIn analogIn3(A3); |
whismanoid | 11:9fa2402071de | 1310 | #endif |
whismanoid | 11:9fa2402071de | 1311 | #if HAS_analogIn4 |
whismanoid | 11:9fa2402071de | 1312 | AnalogIn analogIn4(A4); |
whismanoid | 11:9fa2402071de | 1313 | #endif |
whismanoid | 11:9fa2402071de | 1314 | #if HAS_analogIn5 |
whismanoid | 11:9fa2402071de | 1315 | AnalogIn analogIn5(A5); |
whismanoid | 11:9fa2402071de | 1316 | #endif |
whismanoid | 11:9fa2402071de | 1317 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1318 | #elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 1319 | #define HAS_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 1320 | #define HAS_analogIn1 1 |
whismanoid | 0:3edb3708c8c5 | 1321 | #define HAS_analogIn2 1 |
whismanoid | 0:3edb3708c8c5 | 1322 | #define HAS_analogIn3 1 |
whismanoid | 0:3edb3708c8c5 | 1323 | #define HAS_analogIn4 1 |
whismanoid | 0:3edb3708c8c5 | 1324 | #define HAS_analogIn5 1 |
whismanoid | 0:3edb3708c8c5 | 1325 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 1326 | AnalogIn analogIn0(A0); |
whismanoid | 0:3edb3708c8c5 | 1327 | #endif |
whismanoid | 0:3edb3708c8c5 | 1328 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 1329 | AnalogIn analogIn1(A1); |
whismanoid | 0:3edb3708c8c5 | 1330 | #endif |
whismanoid | 0:3edb3708c8c5 | 1331 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 1332 | AnalogIn analogIn2(A2); |
whismanoid | 0:3edb3708c8c5 | 1333 | #endif |
whismanoid | 0:3edb3708c8c5 | 1334 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 1335 | AnalogIn analogIn3(A3); |
whismanoid | 0:3edb3708c8c5 | 1336 | #endif |
whismanoid | 0:3edb3708c8c5 | 1337 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 1338 | AnalogIn analogIn4(A4); |
whismanoid | 0:3edb3708c8c5 | 1339 | #endif |
whismanoid | 0:3edb3708c8c5 | 1340 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1341 | AnalogIn analogIn5(A5); |
whismanoid | 0:3edb3708c8c5 | 1342 | #endif |
whismanoid | 0:3edb3708c8c5 | 1343 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1344 | #elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 1345 | #define HAS_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 1346 | #define HAS_analogIn1 1 |
whismanoid | 0:3edb3708c8c5 | 1347 | #define HAS_analogIn2 1 |
whismanoid | 0:3edb3708c8c5 | 1348 | #define HAS_analogIn3 1 |
whismanoid | 0:3edb3708c8c5 | 1349 | #define HAS_analogIn4 1 |
whismanoid | 0:3edb3708c8c5 | 1350 | #define HAS_analogIn5 1 |
whismanoid | 0:3edb3708c8c5 | 1351 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 1352 | AnalogIn analogIn0(A0); |
whismanoid | 0:3edb3708c8c5 | 1353 | #endif |
whismanoid | 0:3edb3708c8c5 | 1354 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 1355 | AnalogIn analogIn1(A1); |
whismanoid | 0:3edb3708c8c5 | 1356 | #endif |
whismanoid | 0:3edb3708c8c5 | 1357 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 1358 | AnalogIn analogIn2(A2); |
whismanoid | 0:3edb3708c8c5 | 1359 | #endif |
whismanoid | 0:3edb3708c8c5 | 1360 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 1361 | AnalogIn analogIn3(A3); |
whismanoid | 0:3edb3708c8c5 | 1362 | #endif |
whismanoid | 0:3edb3708c8c5 | 1363 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 1364 | AnalogIn analogIn4(A4); |
whismanoid | 0:3edb3708c8c5 | 1365 | #endif |
whismanoid | 0:3edb3708c8c5 | 1366 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1367 | AnalogIn analogIn5(A5); |
whismanoid | 0:3edb3708c8c5 | 1368 | #endif |
whismanoid | 0:3edb3708c8c5 | 1369 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1370 | // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 1371 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 1372 | #define HAS_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 1373 | #define HAS_analogIn1 1 |
whismanoid | 0:3edb3708c8c5 | 1374 | #define HAS_analogIn2 1 |
whismanoid | 0:3edb3708c8c5 | 1375 | #define HAS_analogIn3 1 |
whismanoid | 0:3edb3708c8c5 | 1376 | #define HAS_analogIn4 1 |
whismanoid | 0:3edb3708c8c5 | 1377 | #define HAS_analogIn5 1 |
whismanoid | 0:3edb3708c8c5 | 1378 | // #define HAS_analogIn6 1 |
whismanoid | 0:3edb3708c8c5 | 1379 | // #define HAS_analogIn7 1 |
whismanoid | 0:3edb3708c8c5 | 1380 | // #define HAS_analogIn8 1 |
whismanoid | 0:3edb3708c8c5 | 1381 | // #define HAS_analogIn9 1 |
whismanoid | 0:3edb3708c8c5 | 1382 | // #define HAS_analogIn10 1 |
whismanoid | 0:3edb3708c8c5 | 1383 | // #define HAS_analogIn11 1 |
whismanoid | 0:3edb3708c8c5 | 1384 | // #define HAS_analogIn12 1 |
whismanoid | 0:3edb3708c8c5 | 1385 | // #define HAS_analogIn13 1 |
whismanoid | 0:3edb3708c8c5 | 1386 | // #define HAS_analogIn14 1 |
whismanoid | 0:3edb3708c8c5 | 1387 | // #define HAS_analogIn15 1 |
whismanoid | 0:3edb3708c8c5 | 1388 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 1389 | AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0 |
whismanoid | 0:3edb3708c8c5 | 1390 | #endif |
whismanoid | 0:3edb3708c8c5 | 1391 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 1392 | AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1 |
whismanoid | 0:3edb3708c8c5 | 1393 | #endif |
whismanoid | 0:3edb3708c8c5 | 1394 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 1395 | AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3 |
whismanoid | 0:3edb3708c8c5 | 1396 | #endif |
whismanoid | 0:3edb3708c8c5 | 1397 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 1398 | AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3 |
whismanoid | 0:3edb3708c8c5 | 1399 | #endif |
whismanoid | 0:3edb3708c8c5 | 1400 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 1401 | AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4 |
whismanoid | 0:3edb3708c8c5 | 1402 | #endif |
whismanoid | 0:3edb3708c8c5 | 1403 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1404 | AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5 |
whismanoid | 0:3edb3708c8c5 | 1405 | #endif |
whismanoid | 0:3edb3708c8c5 | 1406 | #if HAS_analogIn6 |
whismanoid | 0:3edb3708c8c5 | 1407 | AnalogIn analogIn6(____); |
whismanoid | 0:3edb3708c8c5 | 1408 | #endif |
whismanoid | 0:3edb3708c8c5 | 1409 | #if HAS_analogIn7 |
whismanoid | 0:3edb3708c8c5 | 1410 | AnalogIn analogIn7(____); |
whismanoid | 0:3edb3708c8c5 | 1411 | #endif |
whismanoid | 0:3edb3708c8c5 | 1412 | #if HAS_analogIn8 |
whismanoid | 0:3edb3708c8c5 | 1413 | AnalogIn analogIn8(____); |
whismanoid | 0:3edb3708c8c5 | 1414 | #endif |
whismanoid | 0:3edb3708c8c5 | 1415 | #if HAS_analogIn9 |
whismanoid | 0:3edb3708c8c5 | 1416 | AnalogIn analogIn9(____); |
whismanoid | 0:3edb3708c8c5 | 1417 | #endif |
whismanoid | 0:3edb3708c8c5 | 1418 | #if HAS_analogIn10 |
whismanoid | 0:3edb3708c8c5 | 1419 | AnalogIn analogIn10(____); |
whismanoid | 0:3edb3708c8c5 | 1420 | #endif |
whismanoid | 0:3edb3708c8c5 | 1421 | #if HAS_analogIn11 |
whismanoid | 0:3edb3708c8c5 | 1422 | AnalogIn analogIn11(____); |
whismanoid | 0:3edb3708c8c5 | 1423 | #endif |
whismanoid | 0:3edb3708c8c5 | 1424 | #if HAS_analogIn12 |
whismanoid | 0:3edb3708c8c5 | 1425 | AnalogIn analogIn12(____); |
whismanoid | 0:3edb3708c8c5 | 1426 | #endif |
whismanoid | 0:3edb3708c8c5 | 1427 | #if HAS_analogIn13 |
whismanoid | 0:3edb3708c8c5 | 1428 | AnalogIn analogIn13(____); |
whismanoid | 0:3edb3708c8c5 | 1429 | #endif |
whismanoid | 0:3edb3708c8c5 | 1430 | #if HAS_analogIn14 |
whismanoid | 0:3edb3708c8c5 | 1431 | AnalogIn analogIn14(____); |
whismanoid | 0:3edb3708c8c5 | 1432 | #endif |
whismanoid | 0:3edb3708c8c5 | 1433 | #if HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 1434 | AnalogIn analogIn15(____); |
whismanoid | 0:3edb3708c8c5 | 1435 | #endif |
whismanoid | 0:3edb3708c8c5 | 1436 | #else |
whismanoid | 0:3edb3708c8c5 | 1437 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 1438 | #endif |
whismanoid | 0:3edb3708c8c5 | 1439 | // uncrustify-0.66.1 *INDENT-ON* |
whismanoid | 0:3edb3708c8c5 | 1440 | #if HAS_analogIn0 || HAS_analogIn1 \ |
whismanoid | 0:3edb3708c8c5 | 1441 | || HAS_analogIn2 || HAS_analogIn3 \ |
whismanoid | 0:3edb3708c8c5 | 1442 | || HAS_analogIn4 || HAS_analogIn5 \ |
whismanoid | 0:3edb3708c8c5 | 1443 | || HAS_analogIn6 || HAS_analogIn7 \ |
whismanoid | 0:3edb3708c8c5 | 1444 | || HAS_analogIn8 || HAS_analogIn9 \ |
whismanoid | 0:3edb3708c8c5 | 1445 | || HAS_analogIn10 || HAS_analogIn11 \ |
whismanoid | 0:3edb3708c8c5 | 1446 | || HAS_analogIn12 || HAS_analogIn13 \ |
whismanoid | 0:3edb3708c8c5 | 1447 | || HAS_analogIn14 || HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 1448 | #define HAS_analogIns 1 |
whismanoid | 0:3edb3708c8c5 | 1449 | #endif |
whismanoid | 0:3edb3708c8c5 | 1450 | |
whismanoid | 0:3edb3708c8c5 | 1451 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1452 | // Option to use LEDs to show status |
whismanoid | 0:3edb3708c8c5 | 1453 | #ifndef USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 1454 | #define USE_LEDS 1 |
whismanoid | 0:3edb3708c8c5 | 1455 | #endif |
whismanoid | 0:3edb3708c8c5 | 1456 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 1457 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 1458 | # define LED_ON 0 |
whismanoid | 0:3edb3708c8c5 | 1459 | # define LED_OFF 1 |
whismanoid | 0:3edb3708c8c5 | 1460 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1461 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 1462 | # define LED_ON 0 |
whismanoid | 0:3edb3708c8c5 | 1463 | # define LED_OFF 1 |
whismanoid | 0:3edb3708c8c5 | 1464 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1465 | // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 1466 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 1467 | # define LED_ON 1 |
whismanoid | 0:3edb3708c8c5 | 1468 | # define LED_OFF 0 |
whismanoid | 0:3edb3708c8c5 | 1469 | #else // not defined(TARGET_LPC1768 etc.) |
whismanoid | 0:3edb3708c8c5 | 1470 | # define LED_ON 1 |
whismanoid | 0:3edb3708c8c5 | 1471 | # define LED_OFF 0 |
whismanoid | 0:3edb3708c8c5 | 1472 | #endif // target definition |
whismanoid | 0:3edb3708c8c5 | 1473 | DigitalOut led1(LED1, LED_OFF); // MAX32630FTHR: LED1 = LED_RED |
whismanoid | 0:3edb3708c8c5 | 1474 | DigitalOut led2(LED2, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN |
whismanoid | 0:3edb3708c8c5 | 1475 | DigitalOut led3(LED3, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE |
whismanoid | 0:3edb3708c8c5 | 1476 | DigitalOut led4(LED4, LED_OFF); |
whismanoid | 12:5d3f9663ea0c | 1477 | #else // USE_LEDS=0 |
whismanoid | 12:5d3f9663ea0c | 1478 | // issue #41 support Nucleo_F446RE |
whismanoid | 12:5d3f9663ea0c | 1479 | // there are no LED indicators on the board, LED1 interferes with SPI; |
whismanoid | 12:5d3f9663ea0c | 1480 | // but we still need placeholders led1 led2 led3 led4. |
whismanoid | 12:5d3f9663ea0c | 1481 | // Declare DigitalOut led1 led2 led3 led4 targeting safe pins. |
whismanoid | 12:5d3f9663ea0c | 1482 | // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false |
whismanoid | 12:5d3f9663ea0c | 1483 | # define LED_ON 0 |
whismanoid | 12:5d3f9663ea0c | 1484 | # define LED_OFF 1 |
whismanoid | 12:5d3f9663ea0c | 1485 | DigitalOut led1(NC, LED_OFF); |
whismanoid | 12:5d3f9663ea0c | 1486 | DigitalOut led2(NC, LED_OFF); |
whismanoid | 12:5d3f9663ea0c | 1487 | DigitalOut led3(NC, LED_OFF); |
whismanoid | 12:5d3f9663ea0c | 1488 | DigitalOut led4(NC, LED_OFF); |
whismanoid | 0:3edb3708c8c5 | 1489 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 1490 | |
whismanoid | 0:3edb3708c8c5 | 1491 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1492 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 1493 | class RGB_LED { |
whismanoid | 0:3edb3708c8c5 | 1494 | public: |
whismanoid | 0:3edb3708c8c5 | 1495 | RGB_LED(DigitalOut &led_red, DigitalOut &led_green, DigitalOut &led_blue) |
whismanoid | 0:3edb3708c8c5 | 1496 | : m_red(led_red), m_green(led_green), m_blue(led_blue) |
whismanoid | 0:3edb3708c8c5 | 1497 | { |
whismanoid | 0:3edb3708c8c5 | 1498 | }; |
whismanoid | 0:3edb3708c8c5 | 1499 | DigitalOut &m_red; |
whismanoid | 0:3edb3708c8c5 | 1500 | DigitalOut &m_green; |
whismanoid | 0:3edb3708c8c5 | 1501 | DigitalOut &m_blue; |
whismanoid | 0:3edb3708c8c5 | 1502 | ~RGB_LED() |
whismanoid | 0:3edb3708c8c5 | 1503 | { |
whismanoid | 0:3edb3708c8c5 | 1504 | }; |
whismanoid | 0:3edb3708c8c5 | 1505 | /* diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 1506 | */ |
whismanoid | 0:3edb3708c8c5 | 1507 | void red() { |
whismanoid | 0:3edb3708c8c5 | 1508 | m_red = LED_ON; m_green = LED_OFF; m_blue = LED_OFF; // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 1509 | }; |
whismanoid | 0:3edb3708c8c5 | 1510 | /* diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 1511 | */ |
whismanoid | 0:3edb3708c8c5 | 1512 | void green() { |
whismanoid | 0:3edb3708c8c5 | 1513 | m_red = LED_OFF; m_green = LED_ON; m_blue = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 1514 | }; |
whismanoid | 0:3edb3708c8c5 | 1515 | /* diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 1516 | */ |
whismanoid | 0:3edb3708c8c5 | 1517 | void blue() { |
whismanoid | 0:3edb3708c8c5 | 1518 | m_red = LED_OFF; m_green = LED_OFF; m_blue = LED_ON; // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 1519 | }; |
whismanoid | 0:3edb3708c8c5 | 1520 | /* diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 1521 | */ |
whismanoid | 0:3edb3708c8c5 | 1522 | void white() { |
whismanoid | 0:3edb3708c8c5 | 1523 | m_red = LED_ON; m_green = LED_ON; m_blue = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 1524 | }; |
whismanoid | 0:3edb3708c8c5 | 1525 | /* diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 1526 | */ |
whismanoid | 0:3edb3708c8c5 | 1527 | void cyan() { |
whismanoid | 0:3edb3708c8c5 | 1528 | m_red = LED_OFF; m_green = LED_ON; m_blue = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 1529 | }; |
whismanoid | 0:3edb3708c8c5 | 1530 | /* diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 1531 | */ |
whismanoid | 0:3edb3708c8c5 | 1532 | void magenta() { |
whismanoid | 0:3edb3708c8c5 | 1533 | m_red = LED_ON; m_green = LED_OFF; m_blue = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 1534 | }; |
whismanoid | 0:3edb3708c8c5 | 1535 | /* diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 1536 | */ |
whismanoid | 0:3edb3708c8c5 | 1537 | void yellow() { |
whismanoid | 0:3edb3708c8c5 | 1538 | m_red = LED_ON; m_green = LED_ON; m_blue = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 1539 | }; |
whismanoid | 0:3edb3708c8c5 | 1540 | /* diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 1541 | */ |
whismanoid | 0:3edb3708c8c5 | 1542 | void black() { |
whismanoid | 0:3edb3708c8c5 | 1543 | m_red = LED_OFF; m_green = LED_OFF; m_blue = LED_OFF; // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 1544 | }; |
whismanoid | 0:3edb3708c8c5 | 1545 | }; |
whismanoid | 0:3edb3708c8c5 | 1546 | RGB_LED rgb_led(led1, led2, led3); // red, green, blue LEDs |
whismanoid | 0:3edb3708c8c5 | 1547 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 1548 | |
whismanoid | 0:3edb3708c8c5 | 1549 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1550 | // use BUTTON1 trigger some action |
whismanoid | 0:3edb3708c8c5 | 1551 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 1552 | #define HAS_BUTTON1_DEMO_INTERRUPT 1 |
whismanoid | 0:3edb3708c8c5 | 1553 | #elif defined(TARGET_MAX32625) |
whismanoid | 0:3edb3708c8c5 | 1554 | #define HAS_BUTTON1_DEMO_INTERRUPT 1 |
whismanoid | 0:3edb3708c8c5 | 1555 | #define HAS_BUTTON2_DEMO_INTERRUPT 1 |
whismanoid | 0:3edb3708c8c5 | 1556 | #elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 1557 | #define HAS_BUTTON1_DEMO_INTERRUPT 0 |
whismanoid | 0:3edb3708c8c5 | 1558 | #define HAS_BUTTON2_DEMO_INTERRUPT 0 |
whismanoid | 0:3edb3708c8c5 | 1559 | #elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 1560 | #define HAS_BUTTON1_DEMO_INTERRUPT 0 |
whismanoid | 0:3edb3708c8c5 | 1561 | #define HAS_BUTTON2_DEMO_INTERRUPT 0 |
whismanoid | 0:3edb3708c8c5 | 1562 | #endif |
whismanoid | 0:3edb3708c8c5 | 1563 | // |
whismanoid | 0:3edb3708c8c5 | 1564 | #ifndef HAS_BUTTON1_DEMO |
whismanoid | 0:3edb3708c8c5 | 1565 | #define HAS_BUTTON1_DEMO 0 |
whismanoid | 0:3edb3708c8c5 | 1566 | #endif |
whismanoid | 0:3edb3708c8c5 | 1567 | #ifndef HAS_BUTTON2_DEMO |
whismanoid | 0:3edb3708c8c5 | 1568 | #define HAS_BUTTON2_DEMO 0 |
whismanoid | 0:3edb3708c8c5 | 1569 | #endif |
whismanoid | 0:3edb3708c8c5 | 1570 | // |
whismanoid | 0:3edb3708c8c5 | 1571 | // avoid runtime error on button1 press [mbed-os-5.11] |
whismanoid | 0:3edb3708c8c5 | 1572 | // instead of using InterruptIn, use DigitalIn and poll in main while(1) |
whismanoid | 0:3edb3708c8c5 | 1573 | #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 1574 | #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1 |
whismanoid | 0:3edb3708c8c5 | 1575 | #endif |
whismanoid | 0:3edb3708c8c5 | 1576 | // |
whismanoid | 0:3edb3708c8c5 | 1577 | #ifndef HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 1578 | #define HAS_BUTTON1_DEMO_INTERRUPT 1 |
whismanoid | 0:3edb3708c8c5 | 1579 | #endif |
whismanoid | 0:3edb3708c8c5 | 1580 | #ifndef HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 1581 | #define HAS_BUTTON2_DEMO_INTERRUPT 1 |
whismanoid | 0:3edb3708c8c5 | 1582 | #endif |
whismanoid | 0:3edb3708c8c5 | 1583 | // |
whismanoid | 0:3edb3708c8c5 | 1584 | #if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 1585 | # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 1586 | // avoid runtime error on button1 press [mbed-os-5.11] |
whismanoid | 0:3edb3708c8c5 | 1587 | // instead of using InterruptIn, use DigitalIn and poll in main while(1) |
whismanoid | 0:3edb3708c8c5 | 1588 | DigitalIn button1(BUTTON1); |
whismanoid | 0:3edb3708c8c5 | 1589 | # else |
whismanoid | 0:3edb3708c8c5 | 1590 | InterruptIn button1(BUTTON1); |
whismanoid | 0:3edb3708c8c5 | 1591 | # endif |
whismanoid | 0:3edb3708c8c5 | 1592 | #elif HAS_BUTTON1_DEMO |
whismanoid | 0:3edb3708c8c5 | 1593 | DigitalIn button1(BUTTON1); |
whismanoid | 0:3edb3708c8c5 | 1594 | #endif |
whismanoid | 0:3edb3708c8c5 | 1595 | #if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 1596 | # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 1597 | // avoid runtime error on button1 press [mbed-os-5.11] |
whismanoid | 0:3edb3708c8c5 | 1598 | // instead of using InterruptIn, use DigitalIn and poll in main while(1) |
whismanoid | 0:3edb3708c8c5 | 1599 | DigitalIn button2(BUTTON2); |
whismanoid | 0:3edb3708c8c5 | 1600 | # else |
whismanoid | 0:3edb3708c8c5 | 1601 | InterruptIn button2(BUTTON2); |
whismanoid | 0:3edb3708c8c5 | 1602 | # endif |
whismanoid | 0:3edb3708c8c5 | 1603 | #elif HAS_BUTTON2_DEMO |
whismanoid | 0:3edb3708c8c5 | 1604 | DigitalIn button2(BUTTON2); |
whismanoid | 0:3edb3708c8c5 | 1605 | #endif |
whismanoid | 0:3edb3708c8c5 | 1606 | |
whismanoid | 0:3edb3708c8c5 | 1607 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1608 | // Ticker is the periodic interrupt timer itself |
whismanoid | 0:3edb3708c8c5 | 1609 | #define USE_PERIODIC_TIMER 0 |
whismanoid | 0:3edb3708c8c5 | 1610 | #if USE_PERIODIC_TIMER |
whismanoid | 0:3edb3708c8c5 | 1611 | Ticker periodicInterruptTimer; |
whismanoid | 0:3edb3708c8c5 | 1612 | us_timestamp_t periodicInterruptTimer_interval_usec = 50; |
whismanoid | 0:3edb3708c8c5 | 1613 | us_timestamp_t periodicInterruptTimer_interval_usec_MAX = 1000; |
whismanoid | 0:3edb3708c8c5 | 1614 | us_timestamp_t periodicInterruptTimer_interval_usec_MIN = 20; |
whismanoid | 0:3edb3708c8c5 | 1615 | #endif |
whismanoid | 0:3edb3708c8c5 | 1616 | |
whismanoid | 0:3edb3708c8c5 | 1617 | |
whismanoid | 0:3edb3708c8c5 | 1618 | #if APPLICATION_MAX11131 // hardware interface functions |
whismanoid | 0:3edb3708c8c5 | 1619 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1620 | void print_value(CmdLine& cmdLine, int16_t value_u12, int channelId) |
whismanoid | 0:3edb3708c8c5 | 1621 | { |
whismanoid | 0:3edb3708c8c5 | 1622 | int channelPairIndex = channelId / 2; |
whismanoid | 0:3edb3708c8c5 | 1623 | // 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 | 1624 | // unused variable: int UCHn = (g_MAX11131_device.UNIPOLAR >> (10 - channelPairIndex)) & 0x01; |
whismanoid | 0:3edb3708c8c5 | 1625 | int BCHn = (g_MAX11131_device.BIPOLAR >> (10 - channelPairIndex)) & 0x01; |
whismanoid | 0:3edb3708c8c5 | 1626 | // unused variable: int RANGEn = (g_MAX11131_device.RANGE >> (10 - channelPairIndex)) & 0x01; |
whismanoid | 0:3edb3708c8c5 | 1627 | // |
whismanoid | 0:3edb3708c8c5 | 1628 | cmdLine.serial().printf(" ch="); |
whismanoid | 0:3edb3708c8c5 | 1629 | // TODO1: if CHANID=0 don't print ch=channelId |
whismanoid | 0:3edb3708c8c5 | 1630 | if ((g_MAX11131_device.isExternalClock == 0) || (g_MAX11131_device.chan_id_0_1 == 1)) |
whismanoid | 0:3edb3708c8c5 | 1631 | { |
whismanoid | 0:3edb3708c8c5 | 1632 | // Internal clock modes always use channel ID. |
whismanoid | 0:3edb3708c8c5 | 1633 | // External clock modes use channel ID if ADC_MODE_CONTROL.CHAN_ID is 1. |
whismanoid | 0:3edb3708c8c5 | 1634 | cmdLine.serial().printf("%d", channelId); |
whismanoid | 0:3edb3708c8c5 | 1635 | } else { |
whismanoid | 0:3edb3708c8c5 | 1636 | cmdLine.serial().printf("?"); |
whismanoid | 0:3edb3708c8c5 | 1637 | } |
whismanoid | 0:3edb3708c8c5 | 1638 | if (BCHn) |
whismanoid | 0:3edb3708c8c5 | 1639 | { |
whismanoid | 3:8913cb4a8b9f | 1640 | cmdLine.serial().printf(" xb=%ld", g_MAX11131_device.TwosComplementValue(value_u12)); |
whismanoid | 0:3edb3708c8c5 | 1641 | } |
whismanoid | 0:3edb3708c8c5 | 1642 | else |
whismanoid | 0:3edb3708c8c5 | 1643 | { |
whismanoid | 0:3edb3708c8c5 | 1644 | cmdLine.serial().printf(" xu=%d", value_u12); |
whismanoid | 0:3edb3708c8c5 | 1645 | } |
whismanoid | 0:3edb3708c8c5 | 1646 | cmdLine.serial().printf(" = 0x%4.4x = %6.4fV", |
whismanoid | 0:3edb3708c8c5 | 1647 | (value_u12 & 0xFFFF), |
whismanoid | 0:3edb3708c8c5 | 1648 | g_MAX11131_device.VoltageOfCode(value_u12, channelId) |
whismanoid | 0:3edb3708c8c5 | 1649 | ); |
whismanoid | 0:3edb3708c8c5 | 1650 | // dtostrf width and precision: 2.5v / 4096 LSB = 0.0006103515625 volts per LSB |
whismanoid | 0:3edb3708c8c5 | 1651 | } |
whismanoid | 0:3edb3708c8c5 | 1652 | |
whismanoid | 0:3edb3708c8c5 | 1653 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1654 | // read data words |
whismanoid | 0:3edb3708c8c5 | 1655 | // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 1656 | // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 1657 | // For internal clock modes, the data format always includes the channel address. |
whismanoid | 0:3edb3708c8c5 | 1658 | // misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 1659 | void AINcode_print_value_chanID(CmdLine& cmdLine, int nWords) |
whismanoid | 0:3edb3708c8c5 | 1660 | { |
whismanoid | 0:3edb3708c8c5 | 1661 | cmdLine.serial().printf("ScanRead_nWords_chanID nWords=%d\r\n", nWords); |
whismanoid | 0:3edb3708c8c5 | 1662 | for (int index = 0; index < nWords; index++) { |
whismanoid | 0:3edb3708c8c5 | 1663 | //~ int16_t misoData16 = MAX11131_ScanRead(); |
whismanoid | 0:3edb3708c8c5 | 1664 | // For internal clock modes, the data format always includes the channel address. |
whismanoid | 0:3edb3708c8c5 | 1665 | // misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 1666 | int16_t value_u12 = (g_MAX11131_device.RAW_misoData16[index] & 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 1667 | int channelId = ((g_MAX11131_device.RAW_misoData16[index] >> 12) & 0x000F); |
whismanoid | 0:3edb3708c8c5 | 1668 | // diagnostic: print raw MISO data |
whismanoid | 0:3edb3708c8c5 | 1669 | cmdLine.serial().printf(" MAX11131.MISO[%u]=0x%4.4x:", index, |
whismanoid | 0:3edb3708c8c5 | 1670 | (g_MAX11131_device.RAW_misoData16[index] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 1671 | print_value(cmdLine, value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 1672 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 1673 | } |
whismanoid | 0:3edb3708c8c5 | 1674 | } |
whismanoid | 0:3edb3708c8c5 | 1675 | |
whismanoid | 0:3edb3708c8c5 | 1676 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1677 | // read data words |
whismanoid | 0:3edb3708c8c5 | 1678 | // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 1679 | // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 1680 | // For external clock modes, the data format returned depends on the CHAN_ID bit. |
whismanoid | 0:3edb3708c8c5 | 1681 | // when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x |
whismanoid | 0:3edb3708c8c5 | 1682 | // when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 1683 | void AINcode_print_value_externalClock(CmdLine& cmdLine, int nWords) |
whismanoid | 0:3edb3708c8c5 | 1684 | { |
whismanoid | 0:3edb3708c8c5 | 1685 | // For external clock modes, the data format returned depends on the CHAN_ID bit. |
whismanoid | 0:3edb3708c8c5 | 1686 | // when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x |
whismanoid | 0:3edb3708c8c5 | 1687 | // when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 1688 | // For internal clock modes, the data format always includes the channel address. |
whismanoid | 0:3edb3708c8c5 | 1689 | // misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 1690 | if (g_MAX11131_device.chan_id_0_1 != 0) { |
whismanoid | 0:3edb3708c8c5 | 1691 | AINcode_print_value_chanID(cmdLine, nWords); |
whismanoid | 0:3edb3708c8c5 | 1692 | return; |
whismanoid | 0:3edb3708c8c5 | 1693 | } |
whismanoid | 0:3edb3708c8c5 | 1694 | cmdLine.serial().printf("ScanRead_nWords_externalClock nWords=%d\r\n", nWords); |
whismanoid | 0:3edb3708c8c5 | 1695 | for (int index = 0; index < nWords; index++) { |
whismanoid | 0:3edb3708c8c5 | 1696 | // int16_t misoData16 = MAX11131_ScanRead(); |
whismanoid | 0:3edb3708c8c5 | 1697 | int16_t value_u12 = ((g_MAX11131_device.RAW_misoData16[index] >> 3) & 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 1698 | int channelId = g_MAX11131_device.channelNumber_0_15; |
whismanoid | 0:3edb3708c8c5 | 1699 | // diagnostic: print raw MISO data |
whismanoid | 0:3edb3708c8c5 | 1700 | cmdLine.serial().printf(" MAX11131.MISO[%u]=0x%4.4x:", index, |
whismanoid | 0:3edb3708c8c5 | 1701 | (g_MAX11131_device.RAW_misoData16[index] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 1702 | print_value(cmdLine, value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 1703 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 1704 | } |
whismanoid | 0:3edb3708c8c5 | 1705 | } |
whismanoid | 0:3edb3708c8c5 | 1706 | |
whismanoid | 0:3edb3708c8c5 | 1707 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1708 | // read data words and calculate mean, stddev |
whismanoid | 0:3edb3708c8c5 | 1709 | // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 1710 | // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 1711 | void AINcode_print_value_chanID_mean(CmdLine& cmdLine, int nWords) |
whismanoid | 0:3edb3708c8c5 | 1712 | { |
whismanoid | 0:3edb3708c8c5 | 1713 | cmdLine.serial().printf("ScanRead_nWords_chanID_mean nWords=%d\r\n", nWords); |
whismanoid | 0:3edb3708c8c5 | 1714 | double Sx = 0; |
whismanoid | 0:3edb3708c8c5 | 1715 | double Sxx = 0; |
whismanoid | 0:3edb3708c8c5 | 1716 | for (int index = 0; index < nWords; index++) { |
whismanoid | 0:3edb3708c8c5 | 1717 | //~ int16_t misoData16 = MAX11131_ScanRead(); |
whismanoid | 0:3edb3708c8c5 | 1718 | // For internal clock modes, the data format always includes the channel address. |
whismanoid | 0:3edb3708c8c5 | 1719 | // misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 1720 | int16_t value_u12 = (g_MAX11131_device.RAW_misoData16[index] & 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 1721 | int channelId = ((g_MAX11131_device.RAW_misoData16[index] >> 12) & 0x000F); |
whismanoid | 0:3edb3708c8c5 | 1722 | // TODO: sign-extend value_s12 from value_u12 |
whismanoid | 0:3edb3708c8c5 | 1723 | // |
whismanoid | 0:3edb3708c8c5 | 1724 | cmdLine.serial().printf("n=%d", index); |
whismanoid | 0:3edb3708c8c5 | 1725 | print_value(cmdLine, value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 1726 | // |
whismanoid | 0:3edb3708c8c5 | 1727 | Sx = Sx + value_u12; |
whismanoid | 0:3edb3708c8c5 | 1728 | Sxx = Sxx + ((double)value_u12 * value_u12); |
whismanoid | 0:3edb3708c8c5 | 1729 | cmdLine.serial().printf(" Sx=%f Sxx=%f\r\n", Sx, Sxx); |
whismanoid | 0:3edb3708c8c5 | 1730 | } |
whismanoid | 0:3edb3708c8c5 | 1731 | double mean = Sx / nWords; |
whismanoid | 0:3edb3708c8c5 | 1732 | cmdLine.serial().printf(" mean=%f=0x%4.4x", mean, (int)mean); |
whismanoid | 0:3edb3708c8c5 | 1733 | // calculate standard deviation from N, Sx, Sxx |
whismanoid | 0:3edb3708c8c5 | 1734 | if (nWords >= 2) |
whismanoid | 0:3edb3708c8c5 | 1735 | { |
whismanoid | 0:3edb3708c8c5 | 1736 | double variance = (Sxx - ( Sx * Sx / nWords)) / (nWords - 1); |
whismanoid | 0:3edb3708c8c5 | 1737 | // stddev = square root of variance |
whismanoid | 0:3edb3708c8c5 | 1738 | double stddev = sqrt(variance); |
whismanoid | 0:3edb3708c8c5 | 1739 | cmdLine.serial().printf(" variance=%f stddev=%f", variance, stddev); |
whismanoid | 0:3edb3708c8c5 | 1740 | } |
whismanoid | 0:3edb3708c8c5 | 1741 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 1742 | } |
whismanoid | 0:3edb3708c8c5 | 1743 | |
whismanoid | 0:3edb3708c8c5 | 1744 | /* MAX11131_print_register_verbose |
whismanoid | 0:3edb3708c8c5 | 1745 | * |
whismanoid | 0:3edb3708c8c5 | 1746 | * TODO: document this function |
whismanoid | 0:3edb3708c8c5 | 1747 | * This header was inserted by uncrustify; see uncrustify_func_header.txt. |
whismanoid | 0:3edb3708c8c5 | 1748 | * |
whismanoid | 0:3edb3708c8c5 | 1749 | */ |
whismanoid | 0:3edb3708c8c5 | 1750 | void MAX11131_print_register_verbose(CmdLine& cmdLine, int16_t registerData) |
whismanoid | 0:3edb3708c8c5 | 1751 | { |
whismanoid | 0:3edb3708c8c5 | 1752 | if (registerData & 0x8000) |
whismanoid | 0:3edb3708c8c5 | 1753 | { |
whismanoid | 0:3edb3708c8c5 | 1754 | switch (registerData & 0xF800) |
whismanoid | 0:3edb3708c8c5 | 1755 | { |
whismanoid | 0:3edb3708c8c5 | 1756 | 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 | 1757 | cmdLine.serial().printf(" ADC_CONFIGURATION"); |
whismanoid | 0:3edb3708c8c5 | 1758 | { |
whismanoid | 0:3edb3708c8c5 | 1759 | // define write-only register ADC_CONFIGURATION |
whismanoid | 0:3edb3708c8c5 | 1760 | //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 | 1761 | const int REFSEL_LSB = 10; const int REFSEL_BITS = 0x01; // ADC_CONFIGURATION.REFSEL |
whismanoid | 0:3edb3708c8c5 | 1762 | const int AVGON_LSB = 9; const int AVGON_BITS = 0x01; // ADC_CONFIGURATION.AVGON |
whismanoid | 0:3edb3708c8c5 | 1763 | const int NAVG_LSB = 7; const int NAVG_BITS = 0x03; // ADC_CONFIGURATION.NAVG[1:0] |
whismanoid | 0:3edb3708c8c5 | 1764 | const int NSCAN_LSB = 5; const int NSCAN_BITS = 0x03; // ADC_CONFIGURATION.NSCAN[1:0] |
whismanoid | 0:3edb3708c8c5 | 1765 | const int SPM_LSB = 3; const int SPM_BITS = 0x03; // ADC_CONFIGURATION.SPM[1:0] |
whismanoid | 0:3edb3708c8c5 | 1766 | const int ECHO_LSB = 2; const int ECHO_BITS = 0x01; // ADC_CONFIGURATION.ECHO |
whismanoid | 0:3edb3708c8c5 | 1767 | |
whismanoid | 0:3edb3708c8c5 | 1768 | const int REFSEL = ((registerData >> REFSEL_LSB) & REFSEL_BITS); |
whismanoid | 0:3edb3708c8c5 | 1769 | const int AVGON = ((registerData >> AVGON_LSB) & AVGON_BITS); |
whismanoid | 0:3edb3708c8c5 | 1770 | const int NAVG = ((registerData >> NAVG_LSB) & NAVG_BITS); |
whismanoid | 0:3edb3708c8c5 | 1771 | const int NSCAN = ((registerData >> NSCAN_LSB) & NSCAN_BITS); |
whismanoid | 0:3edb3708c8c5 | 1772 | const int SPM = ((registerData >> SPM_LSB) & SPM_BITS); |
whismanoid | 0:3edb3708c8c5 | 1773 | const int ECHO = ((registerData >> ECHO_LSB) & ECHO_BITS); |
whismanoid | 0:3edb3708c8c5 | 1774 | |
whismanoid | 0:3edb3708c8c5 | 1775 | if (REFSEL) { |
whismanoid | 0:3edb3708c8c5 | 1776 | cmdLine.serial().printf(" REFSEL=%d", REFSEL); |
whismanoid | 0:3edb3708c8c5 | 1777 | } |
whismanoid | 0:3edb3708c8c5 | 1778 | if (AVGON) { |
whismanoid | 0:3edb3708c8c5 | 1779 | cmdLine.serial().printf(" AVGON=%d", AVGON); |
whismanoid | 0:3edb3708c8c5 | 1780 | } |
whismanoid | 0:3edb3708c8c5 | 1781 | if (NAVG) { |
whismanoid | 0:3edb3708c8c5 | 1782 | cmdLine.serial().printf(" NAVG=%d", NAVG); |
whismanoid | 0:3edb3708c8c5 | 1783 | } |
whismanoid | 0:3edb3708c8c5 | 1784 | if (NSCAN) { |
whismanoid | 0:3edb3708c8c5 | 1785 | cmdLine.serial().printf(" NSCAN=%d", NSCAN); |
whismanoid | 0:3edb3708c8c5 | 1786 | } |
whismanoid | 0:3edb3708c8c5 | 1787 | if (SPM) { |
whismanoid | 0:3edb3708c8c5 | 1788 | cmdLine.serial().printf(" SPM=%d", SPM); |
whismanoid | 0:3edb3708c8c5 | 1789 | } |
whismanoid | 0:3edb3708c8c5 | 1790 | if (ECHO) { |
whismanoid | 0:3edb3708c8c5 | 1791 | cmdLine.serial().printf(" ECHO=%d", ECHO); |
whismanoid | 0:3edb3708c8c5 | 1792 | } |
whismanoid | 0:3edb3708c8c5 | 1793 | } |
whismanoid | 0:3edb3708c8c5 | 1794 | break; |
whismanoid | 0:3edb3708c8c5 | 1795 | 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 | 1796 | cmdLine.serial().printf(" UNIPOLAR 0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 1797 | if ((registerData >> 2) & 0x01) { |
whismanoid | 0:3edb3708c8c5 | 1798 | cmdLine.serial().printf(" PDIFF_COM"); |
whismanoid | 0:3edb3708c8c5 | 1799 | } |
whismanoid | 0:3edb3708c8c5 | 1800 | break; |
whismanoid | 0:3edb3708c8c5 | 1801 | 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 | 1802 | cmdLine.serial().printf(" BIPOLAR 0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 1803 | break; |
whismanoid | 0:3edb3708c8c5 | 1804 | 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 | 1805 | cmdLine.serial().printf(" RANGE 0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 1806 | break; |
whismanoid | 0:3edb3708c8c5 | 1807 | 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 | 1808 | cmdLine.serial().printf(" CSCAN0 0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 1809 | break; |
whismanoid | 0:3edb3708c8c5 | 1810 | 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 | 1811 | cmdLine.serial().printf(" CSCAN1 0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 1812 | break; |
whismanoid | 0:3edb3708c8c5 | 1813 | case 0xB000: // SAMPLESET 0xB000..0xB7FF format: 1 0 1 1 0 SEQ_LENGTH[7:0] x x x |
whismanoid | 0:3edb3708c8c5 | 1814 | cmdLine.serial().printf(" SAMPLESET SEQ_LENGTH[7:0]=0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 1815 | cmdLine.serial().printf(" so length=%d channels", (((registerData >> 3) & 0xFF) + 1)); |
whismanoid | 0:3edb3708c8c5 | 1816 | break; |
whismanoid | 0:3edb3708c8c5 | 1817 | default: |
whismanoid | 0:3edb3708c8c5 | 1818 | cmdLine.serial().printf(" ???"); |
whismanoid | 0:3edb3708c8c5 | 1819 | break; |
whismanoid | 0:3edb3708c8c5 | 1820 | } |
whismanoid | 0:3edb3708c8c5 | 1821 | } |
whismanoid | 0:3edb3708c8c5 | 1822 | else |
whismanoid | 0:3edb3708c8c5 | 1823 | { |
whismanoid | 0:3edb3708c8c5 | 1824 | // 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 | 1825 | cmdLine.serial().printf(" ADC_MODE_CONTROL"); |
whismanoid | 0:3edb3708c8c5 | 1826 | |
whismanoid | 0:3edb3708c8c5 | 1827 | // define write-only register ADC_MODE_CONTROL |
whismanoid | 0:3edb3708c8c5 | 1828 | //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 | 1829 | const int SCAN_LSB = 11; const int SCAN_BITS = 0x0F; //!< ADC_MODE_CONTROL.SCAN[3:0] ADC Scan Control (command) |
whismanoid | 0:3edb3708c8c5 | 1830 | 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 | 1831 | 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 | 1832 | 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 | 1833 | const int CHAN_ID_LSB = 2; const int CHAN_ID_BITS = 0x01; //!< ADC_MODE_CONTROL.CHAN_ID |
whismanoid | 0:3edb3708c8c5 | 1834 | const int SWCNV_LSB = 1; const int SWCNV_BITS = 0x01; //!< ADC_MODE_CONTROL.SWCNV |
whismanoid | 0:3edb3708c8c5 | 1835 | |
whismanoid | 0:3edb3708c8c5 | 1836 | const int SCAN = ((registerData >> SCAN_LSB) & SCAN_BITS); |
whismanoid | 0:3edb3708c8c5 | 1837 | const int CHSEL = ((registerData >> CHSEL_LSB) & CHSEL_BITS); |
whismanoid | 0:3edb3708c8c5 | 1838 | const int RESET = ((registerData >> RESET_LSB) & RESET_BITS); |
whismanoid | 0:3edb3708c8c5 | 1839 | const int PM = ((registerData >> PM_LSB) & PM_BITS); |
whismanoid | 0:3edb3708c8c5 | 1840 | const int CHANID = ((registerData >> CHAN_ID_LSB) & CHAN_ID_BITS); |
whismanoid | 0:3edb3708c8c5 | 1841 | const int SWCNV = ((registerData >> SWCNV_LSB) & SWCNV_BITS); |
whismanoid | 0:3edb3708c8c5 | 1842 | |
whismanoid | 0:3edb3708c8c5 | 1843 | switch (SCAN) |
whismanoid | 0:3edb3708c8c5 | 1844 | { |
whismanoid | 0:3edb3708c8c5 | 1845 | case MAX11131::SCAN_0000_NOP: |
whismanoid | 0:3edb3708c8c5 | 1846 | cmdLine.serial().printf(" SCAN_0000_NOP"); |
whismanoid | 0:3edb3708c8c5 | 1847 | break; |
whismanoid | 0:3edb3708c8c5 | 1848 | case MAX11131::SCAN_0001_Manual: |
whismanoid | 0:3edb3708c8c5 | 1849 | cmdLine.serial().printf(" SCAN_0001_Manual CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 1850 | break; |
whismanoid | 0:3edb3708c8c5 | 1851 | case MAX11131::SCAN_0010_Repeat: |
whismanoid | 0:3edb3708c8c5 | 1852 | cmdLine.serial().printf(" SCAN_0010_Repeat CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 1853 | break; |
whismanoid | 0:3edb3708c8c5 | 1854 | case MAX11131::SCAN_0011_StandardInternalClock: |
whismanoid | 0:3edb3708c8c5 | 1855 | cmdLine.serial().printf(" SCAN_0011_StandardInt CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 1856 | break; |
whismanoid | 0:3edb3708c8c5 | 1857 | case MAX11131::SCAN_0100_StandardExternalClock: |
whismanoid | 0:3edb3708c8c5 | 1858 | cmdLine.serial().printf(" SCAN_0100_StandardExt CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 1859 | break; |
whismanoid | 0:3edb3708c8c5 | 1860 | case MAX11131::SCAN_0101_UpperInternalClock: |
whismanoid | 0:3edb3708c8c5 | 1861 | cmdLine.serial().printf(" SCAN_0101_UpperInt CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 1862 | break; |
whismanoid | 0:3edb3708c8c5 | 1863 | case MAX11131::SCAN_0110_UpperExternalClock: |
whismanoid | 0:3edb3708c8c5 | 1864 | cmdLine.serial().printf(" SCAN_0110_UpperExt CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 1865 | break; |
whismanoid | 0:3edb3708c8c5 | 1866 | case MAX11131::SCAN_0111_CustomInternalClock: |
whismanoid | 0:3edb3708c8c5 | 1867 | cmdLine.serial().printf(" SCAN_0111_CustomInt"); |
whismanoid | 0:3edb3708c8c5 | 1868 | break; |
whismanoid | 0:3edb3708c8c5 | 1869 | case MAX11131::SCAN_1000_CustomExternalClock: |
whismanoid | 0:3edb3708c8c5 | 1870 | cmdLine.serial().printf(" SCAN_1000_CustomExt"); |
whismanoid | 0:3edb3708c8c5 | 1871 | break; |
whismanoid | 0:3edb3708c8c5 | 1872 | case MAX11131::SCAN_1001_SampleSetExternalClock: |
whismanoid | 0:3edb3708c8c5 | 1873 | cmdLine.serial().printf(" SCAN_1001_SampleSetExt"); |
whismanoid | 0:3edb3708c8c5 | 1874 | break; |
whismanoid | 0:3edb3708c8c5 | 1875 | default: |
whismanoid | 0:3edb3708c8c5 | 1876 | cmdLine.serial().printf(" SCAN=%d", SCAN); |
whismanoid | 0:3edb3708c8c5 | 1877 | cmdLine.serial().printf(" CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 1878 | } |
whismanoid | 0:3edb3708c8c5 | 1879 | if (RESET) { |
whismanoid | 0:3edb3708c8c5 | 1880 | cmdLine.serial().printf(" RESET=%d", RESET); |
whismanoid | 0:3edb3708c8c5 | 1881 | } |
whismanoid | 0:3edb3708c8c5 | 1882 | if (PM) { |
whismanoid | 0:3edb3708c8c5 | 1883 | cmdLine.serial().printf(" PM=%d", PM); |
whismanoid | 0:3edb3708c8c5 | 1884 | } |
whismanoid | 0:3edb3708c8c5 | 1885 | if (SCAN != MAX11131::SCAN_0000_NOP) |
whismanoid | 0:3edb3708c8c5 | 1886 | { |
whismanoid | 0:3edb3708c8c5 | 1887 | if (g_MAX11131_device.isExternalClock) |
whismanoid | 0:3edb3708c8c5 | 1888 | { |
whismanoid | 0:3edb3708c8c5 | 1889 | // if external clock mode, print CHANID |
whismanoid | 0:3edb3708c8c5 | 1890 | cmdLine.serial().printf(" CHANID=%d", CHANID); |
whismanoid | 0:3edb3708c8c5 | 1891 | } |
whismanoid | 0:3edb3708c8c5 | 1892 | else |
whismanoid | 0:3edb3708c8c5 | 1893 | { |
whismanoid | 0:3edb3708c8c5 | 1894 | // if internal clock mode, print SWCNV |
whismanoid | 0:3edb3708c8c5 | 1895 | cmdLine.serial().printf(" SWCNV=%d", SWCNV); |
whismanoid | 0:3edb3708c8c5 | 1896 | } |
whismanoid | 0:3edb3708c8c5 | 1897 | } |
whismanoid | 0:3edb3708c8c5 | 1898 | } |
whismanoid | 0:3edb3708c8c5 | 1899 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 1900 | } |
whismanoid | 0:3edb3708c8c5 | 1901 | #endif |
whismanoid | 0:3edb3708c8c5 | 1902 | |
whismanoid | 0:3edb3708c8c5 | 1903 | |
whismanoid | 0:3edb3708c8c5 | 1904 | #if APPLICATION_MAX5171 // hardware interface functions |
whismanoid | 0:3edb3708c8c5 | 1905 | #endif |
whismanoid | 0:3edb3708c8c5 | 1906 | |
whismanoid | 0:3edb3708c8c5 | 1907 | |
whismanoid | 0:3edb3708c8c5 | 1908 | #if APPLICATION_MAX11410 // hardware interface functions |
whismanoid | 0:3edb3708c8c5 | 1909 | #endif |
whismanoid | 0:3edb3708c8c5 | 1910 | |
whismanoid | 0:3edb3708c8c5 | 1911 | |
whismanoid | 0:3edb3708c8c5 | 1912 | #if APPLICATION_MAX12345 // hardware interface functions |
whismanoid | 0:3edb3708c8c5 | 1913 | #endif |
whismanoid | 0:3edb3708c8c5 | 1914 | |
whismanoid | 0:3edb3708c8c5 | 1915 | |
whismanoid | 0:3edb3708c8c5 | 1916 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1917 | // print banner message to serial port |
whismanoid | 0:3edb3708c8c5 | 1918 | void print_banner() |
whismanoid | 0:3edb3708c8c5 | 1919 | { |
whismanoid | 0:3edb3708c8c5 | 1920 | #if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 1921 | DAPLINKserial.printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 1922 | # if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 1923 | DAPLINKserial.printf("MAX32630"); |
whismanoid | 0:3edb3708c8c5 | 1924 | # elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 1925 | DAPLINKserial.printf("MAX32625MBED"); |
whismanoid | 0:3edb3708c8c5 | 1926 | # elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 1927 | DAPLINKserial.printf("NUCLEO_F446RE"); |
whismanoid | 0:3edb3708c8c5 | 1928 | # elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 1929 | DAPLINKserial.printf("NUCLEO_F401RE"); |
whismanoid | 0:3edb3708c8c5 | 1930 | # elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 1931 | DAPLINKserial.printf("LPC1768"); |
whismanoid | 0:3edb3708c8c5 | 1932 | # else |
whismanoid | 0:3edb3708c8c5 | 1933 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 1934 | DAPLINKserial.printf("unknownTarget"); |
whismanoid | 0:3edb3708c8c5 | 1935 | # endif |
whismanoid | 0:3edb3708c8c5 | 1936 | DAPLINKserial.printf(" DAPLINKserial\r\n"); |
whismanoid | 0:3edb3708c8c5 | 1937 | #endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 1938 | |
whismanoid | 7:bf501f8cb637 | 1939 | serial.printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 1940 | # if defined(TARGET_MAX32630) |
whismanoid | 7:bf501f8cb637 | 1941 | serial.printf("MAX32630"); |
whismanoid | 0:3edb3708c8c5 | 1942 | # elif defined(TARGET_MAX32625MBED) |
whismanoid | 7:bf501f8cb637 | 1943 | serial.printf("MAX32625MBED"); |
whismanoid | 0:3edb3708c8c5 | 1944 | # elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 7:bf501f8cb637 | 1945 | serial.printf("NUCLEO_F446RE"); |
whismanoid | 0:3edb3708c8c5 | 1946 | # elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 7:bf501f8cb637 | 1947 | serial.printf("NUCLEO_F401RE"); |
whismanoid | 0:3edb3708c8c5 | 1948 | # elif defined(TARGET_LPC1768) |
whismanoid | 7:bf501f8cb637 | 1949 | serial.printf("LPC1768"); |
whismanoid | 0:3edb3708c8c5 | 1950 | # else |
whismanoid | 0:3edb3708c8c5 | 1951 | // unknown target |
whismanoid | 7:bf501f8cb637 | 1952 | serial.printf("unknownTarget"); |
whismanoid | 0:3edb3708c8c5 | 1953 | # endif |
whismanoid | 7:bf501f8cb637 | 1954 | serial.printf(" Tester\r\n"); |
whismanoid | 0:3edb3708c8c5 | 1955 | } |
whismanoid | 0:3edb3708c8c5 | 1956 | |
whismanoid | 7:bf501f8cb637 | 1957 | // DigitalInOut pin resource: print the pin index names to serial |
whismanoid | 0:3edb3708c8c5 | 1958 | #if HAS_digitalInOuts |
whismanoid | 0:3edb3708c8c5 | 1959 | void list_digitalInOutPins(Stream& serialStream) |
whismanoid | 0:3edb3708c8c5 | 1960 | { |
whismanoid | 0:3edb3708c8c5 | 1961 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 1962 | serialStream.printf(" 0"); |
whismanoid | 0:3edb3708c8c5 | 1963 | #endif |
whismanoid | 0:3edb3708c8c5 | 1964 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 1965 | serialStream.printf(" 1"); |
whismanoid | 0:3edb3708c8c5 | 1966 | #endif |
whismanoid | 0:3edb3708c8c5 | 1967 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 1968 | serialStream.printf(" 2"); |
whismanoid | 0:3edb3708c8c5 | 1969 | #endif |
whismanoid | 0:3edb3708c8c5 | 1970 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 1971 | serialStream.printf(" 3"); |
whismanoid | 0:3edb3708c8c5 | 1972 | #endif |
whismanoid | 0:3edb3708c8c5 | 1973 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 1974 | serialStream.printf(" 4"); |
whismanoid | 0:3edb3708c8c5 | 1975 | #endif |
whismanoid | 0:3edb3708c8c5 | 1976 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 1977 | serialStream.printf(" 5"); |
whismanoid | 0:3edb3708c8c5 | 1978 | #endif |
whismanoid | 0:3edb3708c8c5 | 1979 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 1980 | serialStream.printf(" 6"); |
whismanoid | 0:3edb3708c8c5 | 1981 | #endif |
whismanoid | 0:3edb3708c8c5 | 1982 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 1983 | serialStream.printf(" 7"); |
whismanoid | 0:3edb3708c8c5 | 1984 | #endif |
whismanoid | 0:3edb3708c8c5 | 1985 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 1986 | serialStream.printf(" 8"); |
whismanoid | 0:3edb3708c8c5 | 1987 | #endif |
whismanoid | 0:3edb3708c8c5 | 1988 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 1989 | serialStream.printf(" 9"); |
whismanoid | 0:3edb3708c8c5 | 1990 | #endif |
whismanoid | 0:3edb3708c8c5 | 1991 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 1992 | serialStream.printf(" 10"); |
whismanoid | 0:3edb3708c8c5 | 1993 | #endif |
whismanoid | 0:3edb3708c8c5 | 1994 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 1995 | serialStream.printf(" 11"); |
whismanoid | 0:3edb3708c8c5 | 1996 | #endif |
whismanoid | 0:3edb3708c8c5 | 1997 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 1998 | serialStream.printf(" 12"); |
whismanoid | 0:3edb3708c8c5 | 1999 | #endif |
whismanoid | 0:3edb3708c8c5 | 2000 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 2001 | serialStream.printf(" 13"); |
whismanoid | 0:3edb3708c8c5 | 2002 | #endif |
whismanoid | 0:3edb3708c8c5 | 2003 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 2004 | serialStream.printf(" 14"); |
whismanoid | 0:3edb3708c8c5 | 2005 | #endif |
whismanoid | 0:3edb3708c8c5 | 2006 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 2007 | serialStream.printf(" 15"); |
whismanoid | 0:3edb3708c8c5 | 2008 | #endif |
whismanoid | 0:3edb3708c8c5 | 2009 | #if HAS_digitalInOut16 |
whismanoid | 0:3edb3708c8c5 | 2010 | serialStream.printf(" 16"); |
whismanoid | 0:3edb3708c8c5 | 2011 | #endif |
whismanoid | 0:3edb3708c8c5 | 2012 | #if HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 2013 | serialStream.printf(" 17"); |
whismanoid | 0:3edb3708c8c5 | 2014 | #endif |
whismanoid | 0:3edb3708c8c5 | 2015 | } |
whismanoid | 0:3edb3708c8c5 | 2016 | #endif |
whismanoid | 0:3edb3708c8c5 | 2017 | |
whismanoid | 0:3edb3708c8c5 | 2018 | // DigitalInOut pin resource: present? |
whismanoid | 0:3edb3708c8c5 | 2019 | #if HAS_digitalInOuts |
whismanoid | 0:3edb3708c8c5 | 2020 | bool has_digitalInOutPin(int cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2021 | { |
whismanoid | 0:3edb3708c8c5 | 2022 | switch (cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2023 | { |
whismanoid | 0:3edb3708c8c5 | 2024 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 2025 | case '0': case 0x00: return true; |
whismanoid | 0:3edb3708c8c5 | 2026 | #endif |
whismanoid | 0:3edb3708c8c5 | 2027 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 2028 | case '1': case 0x01: return true; |
whismanoid | 0:3edb3708c8c5 | 2029 | #endif |
whismanoid | 0:3edb3708c8c5 | 2030 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 2031 | case '2': case 0x02: return true; |
whismanoid | 0:3edb3708c8c5 | 2032 | #endif |
whismanoid | 0:3edb3708c8c5 | 2033 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 2034 | case '3': case 0x03: return true; |
whismanoid | 0:3edb3708c8c5 | 2035 | #endif |
whismanoid | 0:3edb3708c8c5 | 2036 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 2037 | case '4': case 0x04: return true; |
whismanoid | 0:3edb3708c8c5 | 2038 | #endif |
whismanoid | 0:3edb3708c8c5 | 2039 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 2040 | case '5': case 0x05: return true; |
whismanoid | 0:3edb3708c8c5 | 2041 | #endif |
whismanoid | 0:3edb3708c8c5 | 2042 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 2043 | case '6': case 0x06: return true; |
whismanoid | 0:3edb3708c8c5 | 2044 | #endif |
whismanoid | 0:3edb3708c8c5 | 2045 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 2046 | case '7': case 0x07: return true; |
whismanoid | 0:3edb3708c8c5 | 2047 | #endif |
whismanoid | 0:3edb3708c8c5 | 2048 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 2049 | case '8': case 0x08: return true; |
whismanoid | 0:3edb3708c8c5 | 2050 | #endif |
whismanoid | 0:3edb3708c8c5 | 2051 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 2052 | case '9': case 0x09: return true; |
whismanoid | 0:3edb3708c8c5 | 2053 | #endif |
whismanoid | 0:3edb3708c8c5 | 2054 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 2055 | case 'a': case 0x0a: return true; |
whismanoid | 0:3edb3708c8c5 | 2056 | #endif |
whismanoid | 0:3edb3708c8c5 | 2057 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 2058 | case 'b': case 0x0b: return true; |
whismanoid | 0:3edb3708c8c5 | 2059 | #endif |
whismanoid | 0:3edb3708c8c5 | 2060 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 2061 | case 'c': case 0x0c: return true; |
whismanoid | 0:3edb3708c8c5 | 2062 | #endif |
whismanoid | 0:3edb3708c8c5 | 2063 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 2064 | case 'd': case 0x0d: return true; |
whismanoid | 0:3edb3708c8c5 | 2065 | #endif |
whismanoid | 0:3edb3708c8c5 | 2066 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 2067 | case 'e': case 0x0e: return true; |
whismanoid | 0:3edb3708c8c5 | 2068 | #endif |
whismanoid | 0:3edb3708c8c5 | 2069 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 2070 | case 'f': case 0x0f: return true; |
whismanoid | 0:3edb3708c8c5 | 2071 | #endif |
whismanoid | 0:3edb3708c8c5 | 2072 | default: |
whismanoid | 0:3edb3708c8c5 | 2073 | return false; |
whismanoid | 0:3edb3708c8c5 | 2074 | } |
whismanoid | 0:3edb3708c8c5 | 2075 | } |
whismanoid | 0:3edb3708c8c5 | 2076 | #endif |
whismanoid | 0:3edb3708c8c5 | 2077 | |
whismanoid | 0:3edb3708c8c5 | 2078 | // DigitalInOut pin resource: search index |
whismanoid | 0:3edb3708c8c5 | 2079 | #if HAS_digitalInOuts |
whismanoid | 0:3edb3708c8c5 | 2080 | DigitalInOut& find_digitalInOutPin(int cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2081 | { |
whismanoid | 0:3edb3708c8c5 | 2082 | switch (cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2083 | { |
whismanoid | 0:3edb3708c8c5 | 2084 | default: // default to the first defined digitalInOut pin |
whismanoid | 0:3edb3708c8c5 | 2085 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 2086 | case '0': case 0x00: return digitalInOut0; |
whismanoid | 0:3edb3708c8c5 | 2087 | #endif |
whismanoid | 0:3edb3708c8c5 | 2088 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 2089 | case '1': case 0x01: return digitalInOut1; |
whismanoid | 0:3edb3708c8c5 | 2090 | #endif |
whismanoid | 0:3edb3708c8c5 | 2091 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 2092 | case '2': case 0x02: return digitalInOut2; |
whismanoid | 0:3edb3708c8c5 | 2093 | #endif |
whismanoid | 0:3edb3708c8c5 | 2094 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 2095 | case '3': case 0x03: return digitalInOut3; |
whismanoid | 0:3edb3708c8c5 | 2096 | #endif |
whismanoid | 0:3edb3708c8c5 | 2097 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 2098 | case '4': case 0x04: return digitalInOut4; |
whismanoid | 0:3edb3708c8c5 | 2099 | #endif |
whismanoid | 0:3edb3708c8c5 | 2100 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 2101 | case '5': case 0x05: return digitalInOut5; |
whismanoid | 0:3edb3708c8c5 | 2102 | #endif |
whismanoid | 0:3edb3708c8c5 | 2103 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 2104 | case '6': case 0x06: return digitalInOut6; |
whismanoid | 0:3edb3708c8c5 | 2105 | #endif |
whismanoid | 0:3edb3708c8c5 | 2106 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 2107 | case '7': case 0x07: return digitalInOut7; |
whismanoid | 0:3edb3708c8c5 | 2108 | #endif |
whismanoid | 0:3edb3708c8c5 | 2109 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 2110 | case '8': case 0x08: return digitalInOut8; |
whismanoid | 0:3edb3708c8c5 | 2111 | #endif |
whismanoid | 0:3edb3708c8c5 | 2112 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 2113 | case '9': case 0x09: return digitalInOut9; |
whismanoid | 0:3edb3708c8c5 | 2114 | #endif |
whismanoid | 0:3edb3708c8c5 | 2115 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 2116 | case 'a': case 0x0a: return digitalInOut10; |
whismanoid | 0:3edb3708c8c5 | 2117 | #endif |
whismanoid | 0:3edb3708c8c5 | 2118 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 2119 | case 'b': case 0x0b: return digitalInOut11; |
whismanoid | 0:3edb3708c8c5 | 2120 | #endif |
whismanoid | 0:3edb3708c8c5 | 2121 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 2122 | case 'c': case 0x0c: return digitalInOut12; |
whismanoid | 0:3edb3708c8c5 | 2123 | #endif |
whismanoid | 0:3edb3708c8c5 | 2124 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 2125 | case 'd': case 0x0d: return digitalInOut13; |
whismanoid | 0:3edb3708c8c5 | 2126 | #endif |
whismanoid | 0:3edb3708c8c5 | 2127 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 2128 | case 'e': case 0x0e: return digitalInOut14; |
whismanoid | 0:3edb3708c8c5 | 2129 | #endif |
whismanoid | 0:3edb3708c8c5 | 2130 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 2131 | case 'f': case 0x0f: return digitalInOut15; |
whismanoid | 0:3edb3708c8c5 | 2132 | #endif |
whismanoid | 0:3edb3708c8c5 | 2133 | #if HAS_digitalInOut16 |
whismanoid | 0:3edb3708c8c5 | 2134 | case 'g': case 0x10: return digitalInOut16; |
whismanoid | 0:3edb3708c8c5 | 2135 | #endif |
whismanoid | 0:3edb3708c8c5 | 2136 | #if HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 2137 | case 'h': case 0x11: return digitalInOut17; |
whismanoid | 0:3edb3708c8c5 | 2138 | #endif |
whismanoid | 0:3edb3708c8c5 | 2139 | } |
whismanoid | 0:3edb3708c8c5 | 2140 | } |
whismanoid | 0:3edb3708c8c5 | 2141 | #endif |
whismanoid | 0:3edb3708c8c5 | 2142 | |
whismanoid | 7:bf501f8cb637 | 2143 | // AnalogIn pin resource: print the pin index names to serial |
whismanoid | 0:3edb3708c8c5 | 2144 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 2145 | void list_analogInPins(Stream& serialStream) |
whismanoid | 0:3edb3708c8c5 | 2146 | { |
whismanoid | 0:3edb3708c8c5 | 2147 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2148 | serialStream.printf(" 0"); |
whismanoid | 0:3edb3708c8c5 | 2149 | #endif |
whismanoid | 0:3edb3708c8c5 | 2150 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 2151 | serialStream.printf(" 1"); |
whismanoid | 0:3edb3708c8c5 | 2152 | #endif |
whismanoid | 0:3edb3708c8c5 | 2153 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 2154 | serialStream.printf(" 2"); |
whismanoid | 0:3edb3708c8c5 | 2155 | #endif |
whismanoid | 0:3edb3708c8c5 | 2156 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 2157 | serialStream.printf(" 3"); |
whismanoid | 0:3edb3708c8c5 | 2158 | #endif |
whismanoid | 0:3edb3708c8c5 | 2159 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 2160 | serialStream.printf(" 4"); |
whismanoid | 0:3edb3708c8c5 | 2161 | #endif |
whismanoid | 0:3edb3708c8c5 | 2162 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 2163 | serialStream.printf(" 5"); |
whismanoid | 0:3edb3708c8c5 | 2164 | #endif |
whismanoid | 0:3edb3708c8c5 | 2165 | #if HAS_analogIn6 |
whismanoid | 0:3edb3708c8c5 | 2166 | serialStream.printf(" 6"); |
whismanoid | 0:3edb3708c8c5 | 2167 | #endif |
whismanoid | 0:3edb3708c8c5 | 2168 | #if HAS_analogIn7 |
whismanoid | 0:3edb3708c8c5 | 2169 | serialStream.printf(" 7"); |
whismanoid | 0:3edb3708c8c5 | 2170 | #endif |
whismanoid | 0:3edb3708c8c5 | 2171 | #if HAS_analogIn8 |
whismanoid | 0:3edb3708c8c5 | 2172 | serialStream.printf(" 8"); |
whismanoid | 0:3edb3708c8c5 | 2173 | #endif |
whismanoid | 0:3edb3708c8c5 | 2174 | #if HAS_analogIn9 |
whismanoid | 0:3edb3708c8c5 | 2175 | serialStream.printf(" 9"); |
whismanoid | 0:3edb3708c8c5 | 2176 | #endif |
whismanoid | 0:3edb3708c8c5 | 2177 | #if HAS_analogIn10 |
whismanoid | 0:3edb3708c8c5 | 2178 | serialStream.printf(" a"); |
whismanoid | 0:3edb3708c8c5 | 2179 | #endif |
whismanoid | 0:3edb3708c8c5 | 2180 | #if HAS_analogIn11 |
whismanoid | 0:3edb3708c8c5 | 2181 | serialStream.printf(" b"); |
whismanoid | 0:3edb3708c8c5 | 2182 | #endif |
whismanoid | 0:3edb3708c8c5 | 2183 | #if HAS_analogIn12 |
whismanoid | 0:3edb3708c8c5 | 2184 | serialStream.printf(" c"); |
whismanoid | 0:3edb3708c8c5 | 2185 | #endif |
whismanoid | 0:3edb3708c8c5 | 2186 | #if HAS_analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2187 | serialStream.printf(" d"); |
whismanoid | 0:3edb3708c8c5 | 2188 | #endif |
whismanoid | 0:3edb3708c8c5 | 2189 | #if HAS_analogIn14 |
whismanoid | 0:3edb3708c8c5 | 2190 | serialStream.printf(" e"); |
whismanoid | 0:3edb3708c8c5 | 2191 | #endif |
whismanoid | 0:3edb3708c8c5 | 2192 | #if HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 2193 | serialStream.printf(" f"); |
whismanoid | 0:3edb3708c8c5 | 2194 | #endif |
whismanoid | 0:3edb3708c8c5 | 2195 | } |
whismanoid | 0:3edb3708c8c5 | 2196 | #endif |
whismanoid | 0:3edb3708c8c5 | 2197 | |
whismanoid | 0:3edb3708c8c5 | 2198 | // AnalogIn pin resource: present? |
whismanoid | 0:3edb3708c8c5 | 2199 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 2200 | bool has_analogInPin(int cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2201 | { |
whismanoid | 0:3edb3708c8c5 | 2202 | switch (cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2203 | { |
whismanoid | 0:3edb3708c8c5 | 2204 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2205 | case '0': case 0x00: return true; |
whismanoid | 0:3edb3708c8c5 | 2206 | #endif |
whismanoid | 0:3edb3708c8c5 | 2207 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 2208 | case '1': case 0x01: return true; |
whismanoid | 0:3edb3708c8c5 | 2209 | #endif |
whismanoid | 0:3edb3708c8c5 | 2210 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 2211 | case '2': case 0x02: return true; |
whismanoid | 0:3edb3708c8c5 | 2212 | #endif |
whismanoid | 0:3edb3708c8c5 | 2213 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 2214 | case '3': case 0x03: return true; |
whismanoid | 0:3edb3708c8c5 | 2215 | #endif |
whismanoid | 0:3edb3708c8c5 | 2216 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 2217 | case '4': case 0x04: return true; |
whismanoid | 0:3edb3708c8c5 | 2218 | #endif |
whismanoid | 0:3edb3708c8c5 | 2219 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 2220 | case '5': case 0x05: return true; |
whismanoid | 0:3edb3708c8c5 | 2221 | #endif |
whismanoid | 0:3edb3708c8c5 | 2222 | #if HAS_analogIn6 |
whismanoid | 0:3edb3708c8c5 | 2223 | case '6': case 0x06: return true; |
whismanoid | 0:3edb3708c8c5 | 2224 | #endif |
whismanoid | 0:3edb3708c8c5 | 2225 | #if HAS_analogIn7 |
whismanoid | 0:3edb3708c8c5 | 2226 | case '7': case 0x07: return true; |
whismanoid | 0:3edb3708c8c5 | 2227 | #endif |
whismanoid | 0:3edb3708c8c5 | 2228 | #if HAS_analogIn8 |
whismanoid | 0:3edb3708c8c5 | 2229 | case '8': case 0x08: return true; |
whismanoid | 0:3edb3708c8c5 | 2230 | #endif |
whismanoid | 0:3edb3708c8c5 | 2231 | #if HAS_analogIn9 |
whismanoid | 0:3edb3708c8c5 | 2232 | case '9': case 0x09: return true; |
whismanoid | 0:3edb3708c8c5 | 2233 | #endif |
whismanoid | 0:3edb3708c8c5 | 2234 | #if HAS_analogIn10 |
whismanoid | 0:3edb3708c8c5 | 2235 | case 'a': case 0x0a: return true; |
whismanoid | 0:3edb3708c8c5 | 2236 | #endif |
whismanoid | 0:3edb3708c8c5 | 2237 | #if HAS_analogIn11 |
whismanoid | 0:3edb3708c8c5 | 2238 | case 'b': case 0x0b: return true; |
whismanoid | 0:3edb3708c8c5 | 2239 | #endif |
whismanoid | 0:3edb3708c8c5 | 2240 | #if HAS_analogIn12 |
whismanoid | 0:3edb3708c8c5 | 2241 | case 'c': case 0x0c: return true; |
whismanoid | 0:3edb3708c8c5 | 2242 | #endif |
whismanoid | 0:3edb3708c8c5 | 2243 | #if HAS_analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2244 | case 'd': case 0x0d: return true; |
whismanoid | 0:3edb3708c8c5 | 2245 | #endif |
whismanoid | 0:3edb3708c8c5 | 2246 | #if HAS_analogIn14 |
whismanoid | 0:3edb3708c8c5 | 2247 | case 'e': case 0x0e: return true; |
whismanoid | 0:3edb3708c8c5 | 2248 | #endif |
whismanoid | 0:3edb3708c8c5 | 2249 | #if HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 2250 | case 'f': case 0x0f: return true; |
whismanoid | 0:3edb3708c8c5 | 2251 | #endif |
whismanoid | 0:3edb3708c8c5 | 2252 | default: |
whismanoid | 0:3edb3708c8c5 | 2253 | return false; |
whismanoid | 0:3edb3708c8c5 | 2254 | } |
whismanoid | 0:3edb3708c8c5 | 2255 | } |
whismanoid | 0:3edb3708c8c5 | 2256 | #endif |
whismanoid | 0:3edb3708c8c5 | 2257 | |
whismanoid | 0:3edb3708c8c5 | 2258 | // AnalogIn pin resource: search index |
whismanoid | 0:3edb3708c8c5 | 2259 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 2260 | AnalogIn& find_analogInPin(int cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2261 | { |
whismanoid | 0:3edb3708c8c5 | 2262 | switch (cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2263 | { |
whismanoid | 0:3edb3708c8c5 | 2264 | default: // default to the first defined analogIn pin |
whismanoid | 0:3edb3708c8c5 | 2265 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2266 | case '0': case 0x00: return analogIn0; |
whismanoid | 0:3edb3708c8c5 | 2267 | #endif |
whismanoid | 0:3edb3708c8c5 | 2268 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 2269 | case '1': case 0x01: return analogIn1; |
whismanoid | 0:3edb3708c8c5 | 2270 | #endif |
whismanoid | 0:3edb3708c8c5 | 2271 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 2272 | case '2': case 0x02: return analogIn2; |
whismanoid | 0:3edb3708c8c5 | 2273 | #endif |
whismanoid | 0:3edb3708c8c5 | 2274 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 2275 | case '3': case 0x03: return analogIn3; |
whismanoid | 0:3edb3708c8c5 | 2276 | #endif |
whismanoid | 0:3edb3708c8c5 | 2277 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 2278 | case '4': case 0x04: return analogIn4; |
whismanoid | 0:3edb3708c8c5 | 2279 | #endif |
whismanoid | 0:3edb3708c8c5 | 2280 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 2281 | case '5': case 0x05: return analogIn5; |
whismanoid | 0:3edb3708c8c5 | 2282 | #endif |
whismanoid | 0:3edb3708c8c5 | 2283 | #if HAS_analogIn6 |
whismanoid | 0:3edb3708c8c5 | 2284 | case '6': case 0x06: return analogIn6; |
whismanoid | 0:3edb3708c8c5 | 2285 | #endif |
whismanoid | 0:3edb3708c8c5 | 2286 | #if HAS_analogIn7 |
whismanoid | 0:3edb3708c8c5 | 2287 | case '7': case 0x07: return analogIn7; |
whismanoid | 0:3edb3708c8c5 | 2288 | #endif |
whismanoid | 0:3edb3708c8c5 | 2289 | #if HAS_analogIn8 |
whismanoid | 0:3edb3708c8c5 | 2290 | case '8': case 0x08: return analogIn8; |
whismanoid | 0:3edb3708c8c5 | 2291 | #endif |
whismanoid | 0:3edb3708c8c5 | 2292 | #if HAS_analogIn9 |
whismanoid | 0:3edb3708c8c5 | 2293 | case '9': case 0x09: return analogIn9; |
whismanoid | 0:3edb3708c8c5 | 2294 | #endif |
whismanoid | 0:3edb3708c8c5 | 2295 | #if HAS_analogIn10 |
whismanoid | 0:3edb3708c8c5 | 2296 | case 'a': case 0x0a: return analogIn10; |
whismanoid | 0:3edb3708c8c5 | 2297 | #endif |
whismanoid | 0:3edb3708c8c5 | 2298 | #if HAS_analogIn11 |
whismanoid | 0:3edb3708c8c5 | 2299 | case 'b': case 0x0b: return analogIn11; |
whismanoid | 0:3edb3708c8c5 | 2300 | #endif |
whismanoid | 0:3edb3708c8c5 | 2301 | #if HAS_analogIn12 |
whismanoid | 0:3edb3708c8c5 | 2302 | case 'c': case 0x0c: return analogIn12; |
whismanoid | 0:3edb3708c8c5 | 2303 | #endif |
whismanoid | 0:3edb3708c8c5 | 2304 | #if HAS_analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2305 | case 'd': case 0x0d: return analogIn13; |
whismanoid | 0:3edb3708c8c5 | 2306 | #endif |
whismanoid | 0:3edb3708c8c5 | 2307 | #if HAS_analogIn14 |
whismanoid | 0:3edb3708c8c5 | 2308 | case 'e': case 0x0e: return analogIn14; |
whismanoid | 0:3edb3708c8c5 | 2309 | #endif |
whismanoid | 0:3edb3708c8c5 | 2310 | #if HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 2311 | case 'f': case 0x0f: return analogIn15; |
whismanoid | 0:3edb3708c8c5 | 2312 | #endif |
whismanoid | 0:3edb3708c8c5 | 2313 | } |
whismanoid | 0:3edb3708c8c5 | 2314 | } |
whismanoid | 0:3edb3708c8c5 | 2315 | #endif |
whismanoid | 0:3edb3708c8c5 | 2316 | |
whismanoid | 0:3edb3708c8c5 | 2317 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 2318 | const float analogInPin_fullScaleVoltage[] = { |
whismanoid | 0:3edb3708c8c5 | 2319 | # if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 2320 | ADC_FULL_SCALE_VOLTAGE, // analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2321 | ADC_FULL_SCALE_VOLTAGE, // analogIn1 |
whismanoid | 0:3edb3708c8c5 | 2322 | ADC_FULL_SCALE_VOLTAGE, // analogIn2 |
whismanoid | 0:3edb3708c8c5 | 2323 | ADC_FULL_SCALE_VOLTAGE, // analogIn3 |
whismanoid | 0:3edb3708c8c5 | 2324 | ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 2325 | ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 2326 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 2327 | ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 2328 | ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 2329 | ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V |
whismanoid | 0:3edb3708c8c5 | 2330 | ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined? |
whismanoid | 0:3edb3708c8c5 | 2331 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 2332 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 2333 | ADC_FULL_SCALE_VOLTAGE, // analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2334 | ADC_FULL_SCALE_VOLTAGE, // analogIn14 |
whismanoid | 0:3edb3708c8c5 | 2335 | ADC_FULL_SCALE_VOLTAGE // analogIn15 |
whismanoid | 0:3edb3708c8c5 | 2336 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 2337 | ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 2338 | ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 2339 | ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 2340 | ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 2341 | ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 2342 | ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 2343 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 2344 | ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 2345 | ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 2346 | ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V |
whismanoid | 0:3edb3708c8c5 | 2347 | ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined? |
whismanoid | 0:3edb3708c8c5 | 2348 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 2349 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 2350 | ADC_FULL_SCALE_VOLTAGE, // analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2351 | ADC_FULL_SCALE_VOLTAGE, // analogIn14 |
whismanoid | 0:3edb3708c8c5 | 2352 | ADC_FULL_SCALE_VOLTAGE // analogIn15 |
whismanoid | 0:3edb3708c8c5 | 2353 | #elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 2354 | ADC_FULL_SCALE_VOLTAGE, // analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2355 | ADC_FULL_SCALE_VOLTAGE, // analogIn1 |
whismanoid | 0:3edb3708c8c5 | 2356 | ADC_FULL_SCALE_VOLTAGE, // analogIn2 |
whismanoid | 0:3edb3708c8c5 | 2357 | ADC_FULL_SCALE_VOLTAGE, // analogIn3 |
whismanoid | 0:3edb3708c8c5 | 2358 | ADC_FULL_SCALE_VOLTAGE, // analogIn4 |
whismanoid | 0:3edb3708c8c5 | 2359 | ADC_FULL_SCALE_VOLTAGE, // analogIn5 |
whismanoid | 0:3edb3708c8c5 | 2360 | ADC_FULL_SCALE_VOLTAGE, // analogIn6 |
whismanoid | 0:3edb3708c8c5 | 2361 | ADC_FULL_SCALE_VOLTAGE, // analogIn7 |
whismanoid | 0:3edb3708c8c5 | 2362 | ADC_FULL_SCALE_VOLTAGE, // analogIn8 |
whismanoid | 0:3edb3708c8c5 | 2363 | ADC_FULL_SCALE_VOLTAGE, // analogIn9 |
whismanoid | 0:3edb3708c8c5 | 2364 | ADC_FULL_SCALE_VOLTAGE, // analogIn10 |
whismanoid | 0:3edb3708c8c5 | 2365 | ADC_FULL_SCALE_VOLTAGE, // analogIn11 |
whismanoid | 0:3edb3708c8c5 | 2366 | ADC_FULL_SCALE_VOLTAGE, // analogIn12 |
whismanoid | 0:3edb3708c8c5 | 2367 | ADC_FULL_SCALE_VOLTAGE, // analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2368 | ADC_FULL_SCALE_VOLTAGE, // analogIn14 |
whismanoid | 0:3edb3708c8c5 | 2369 | ADC_FULL_SCALE_VOLTAGE // analogIn15 |
whismanoid | 0:3edb3708c8c5 | 2370 | #elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 2371 | ADC_FULL_SCALE_VOLTAGE, // analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2372 | ADC_FULL_SCALE_VOLTAGE, // analogIn1 |
whismanoid | 0:3edb3708c8c5 | 2373 | ADC_FULL_SCALE_VOLTAGE, // analogIn2 |
whismanoid | 0:3edb3708c8c5 | 2374 | ADC_FULL_SCALE_VOLTAGE, // analogIn3 |
whismanoid | 0:3edb3708c8c5 | 2375 | ADC_FULL_SCALE_VOLTAGE, // analogIn4 |
whismanoid | 0:3edb3708c8c5 | 2376 | ADC_FULL_SCALE_VOLTAGE, // analogIn5 |
whismanoid | 0:3edb3708c8c5 | 2377 | ADC_FULL_SCALE_VOLTAGE, // analogIn6 |
whismanoid | 0:3edb3708c8c5 | 2378 | ADC_FULL_SCALE_VOLTAGE, // analogIn7 |
whismanoid | 0:3edb3708c8c5 | 2379 | ADC_FULL_SCALE_VOLTAGE, // analogIn8 |
whismanoid | 0:3edb3708c8c5 | 2380 | ADC_FULL_SCALE_VOLTAGE, // analogIn9 |
whismanoid | 0:3edb3708c8c5 | 2381 | ADC_FULL_SCALE_VOLTAGE, // analogIn10 |
whismanoid | 0:3edb3708c8c5 | 2382 | ADC_FULL_SCALE_VOLTAGE, // analogIn11 |
whismanoid | 0:3edb3708c8c5 | 2383 | ADC_FULL_SCALE_VOLTAGE, // analogIn12 |
whismanoid | 0:3edb3708c8c5 | 2384 | ADC_FULL_SCALE_VOLTAGE, // analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2385 | ADC_FULL_SCALE_VOLTAGE, // analogIn14 |
whismanoid | 0:3edb3708c8c5 | 2386 | ADC_FULL_SCALE_VOLTAGE // analogIn15 |
whismanoid | 0:3edb3708c8c5 | 2387 | //#elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 2388 | #else |
whismanoid | 0:3edb3708c8c5 | 2389 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 2390 | ADC_FULL_SCALE_VOLTAGE, // analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2391 | ADC_FULL_SCALE_VOLTAGE, // analogIn1 |
whismanoid | 0:3edb3708c8c5 | 2392 | ADC_FULL_SCALE_VOLTAGE, // analogIn2 |
whismanoid | 0:3edb3708c8c5 | 2393 | ADC_FULL_SCALE_VOLTAGE, // analogIn3 |
whismanoid | 0:3edb3708c8c5 | 2394 | ADC_FULL_SCALE_VOLTAGE, // analogIn4 |
whismanoid | 0:3edb3708c8c5 | 2395 | ADC_FULL_SCALE_VOLTAGE, // analogIn5 |
whismanoid | 0:3edb3708c8c5 | 2396 | ADC_FULL_SCALE_VOLTAGE, // analogIn6 |
whismanoid | 0:3edb3708c8c5 | 2397 | ADC_FULL_SCALE_VOLTAGE, // analogIn7 |
whismanoid | 0:3edb3708c8c5 | 2398 | ADC_FULL_SCALE_VOLTAGE, // analogIn8 |
whismanoid | 0:3edb3708c8c5 | 2399 | ADC_FULL_SCALE_VOLTAGE, // analogIn9 |
whismanoid | 0:3edb3708c8c5 | 2400 | ADC_FULL_SCALE_VOLTAGE, // analogIn10 |
whismanoid | 0:3edb3708c8c5 | 2401 | ADC_FULL_SCALE_VOLTAGE, // analogIn11 |
whismanoid | 0:3edb3708c8c5 | 2402 | ADC_FULL_SCALE_VOLTAGE, // analogIn12 |
whismanoid | 0:3edb3708c8c5 | 2403 | ADC_FULL_SCALE_VOLTAGE, // analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2404 | ADC_FULL_SCALE_VOLTAGE, // analogIn14 |
whismanoid | 0:3edb3708c8c5 | 2405 | ADC_FULL_SCALE_VOLTAGE // analogIn15 |
whismanoid | 0:3edb3708c8c5 | 2406 | # endif |
whismanoid | 0:3edb3708c8c5 | 2407 | }; |
whismanoid | 0:3edb3708c8c5 | 2408 | #endif |
whismanoid | 0:3edb3708c8c5 | 2409 | |
whismanoid | 0:3edb3708c8c5 | 2410 | #if HAS_I2C // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 2411 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2412 | // Search I2C device address list |
whismanoid | 0:3edb3708c8c5 | 2413 | // |
whismanoid | 0:3edb3708c8c5 | 2414 | // @param[in] deviceAddress7First = I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified. |
whismanoid | 0:3edb3708c8c5 | 2415 | // @param[in] deviceAddress7Last = I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified. |
whismanoid | 0:3edb3708c8c5 | 2416 | // @param[in] numDevicesFoundLimit = maximum number of devices to detect before halting search; in case SCL stuck low or pullups missing. |
whismanoid | 0:3edb3708c8c5 | 2417 | // @returns deviceAddress on success; 0 on failure |
whismanoid | 0:3edb3708c8c5 | 2418 | // @post g_I2C_deviceAddress7 is updated with any device that did ACK |
whismanoid | 0:3edb3708c8c5 | 2419 | // |
whismanoid | 0:3edb3708c8c5 | 2420 | void HuntAttachedI2CDevices(CmdLine& cmdLine, uint8_t deviceAddress7First, uint8_t deviceAddress7Last, |
whismanoid | 0:3edb3708c8c5 | 2421 | const uint8_t numDevicesFoundLimit = 20) |
whismanoid | 0:3edb3708c8c5 | 2422 | { |
whismanoid | 0:3edb3708c8c5 | 2423 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 0:3edb3708c8c5 | 2424 | I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 2425 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 2426 | |
whismanoid | 0:3edb3708c8c5 | 2427 | // %IP -- I2C probe |
whismanoid | 0:3edb3708c8c5 | 2428 | // TODO: i2c transfer |
whismanoid | 0:3edb3708c8c5 | 2429 | //const int addr7bit = 0x48; // 7 bit I2C address |
whismanoid | 0:3edb3708c8c5 | 2430 | //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 |
whismanoid | 0:3edb3708c8c5 | 2431 | // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 2432 | // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 2433 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 2434 | // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 2435 | // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 2436 | // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 2437 | // /* 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 | 2438 | // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... |
whismanoid | 0:3edb3708c8c5 | 2439 | |
whismanoid | 0:3edb3708c8c5 | 2440 | //const char probeWriteData[] = { 0x00 }; |
whismanoid | 0:3edb3708c8c5 | 2441 | //int probeWriteDataLength = 1; |
whismanoid | 0:3edb3708c8c5 | 2442 | //bool isRepeatedStart = false; |
whismanoid | 0:3edb3708c8c5 | 2443 | 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 | 2444 | deviceAddress7First, |
whismanoid | 0:3edb3708c8c5 | 2445 | deviceAddress7First << 1, |
whismanoid | 0:3edb3708c8c5 | 2446 | deviceAddress7Last, |
whismanoid | 0:3edb3708c8c5 | 2447 | deviceAddress7Last << 1, |
whismanoid | 0:3edb3708c8c5 | 2448 | numDevicesFoundLimit); // HuntAttachedI2CDevices |
whismanoid | 0:3edb3708c8c5 | 2449 | //~ const int i2cFileDescriptor = i2c_open_adapter(1); |
whismanoid | 0:3edb3708c8c5 | 2450 | uint8_t numDevicesFound = 0; |
whismanoid | 0:3edb3708c8c5 | 2451 | uint8_t last_valid_deviceAddress7 = 0; |
whismanoid | 0:3edb3708c8c5 | 2452 | for (uint8_t deviceAddress7 = deviceAddress7First; deviceAddress7 <= deviceAddress7Last; deviceAddress7++) |
whismanoid | 0:3edb3708c8c5 | 2453 | { |
whismanoid | 0:3edb3708c8c5 | 2454 | //cmdLine.serial().printf(" (0x%2.2X >> 1) ", (deviceAddress7 << 1)); |
whismanoid | 0:3edb3708c8c5 | 2455 | //if (i2c_ioctl_I2C_SLAVE_i2cDeviceAddress7bits(i2cFileDescriptor, deviceAddress7) == 0) |
whismanoid | 0:3edb3708c8c5 | 2456 | int addr8bit = deviceAddress7 * 2; |
whismanoid | 0:3edb3708c8c5 | 2457 | // |
whismanoid | 0:3edb3708c8c5 | 2458 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 2459 | // Returns 0 on success (ack), nonzero on failure (nack) |
whismanoid | 0:3edb3708c8c5 | 2460 | //bool gotACK = (i2cMaster.write (addr8bit, probeWriteData, probeWriteDataLength, isRepeatedStart) == 0); |
whismanoid | 0:3edb3708c8c5 | 2461 | // |
whismanoid | 0:3edb3708c8c5 | 2462 | // SMBusQuick test |
whismanoid | 0:3edb3708c8c5 | 2463 | i2cMaster.start(); |
whismanoid | 0:3edb3708c8c5 | 2464 | // /** Write single byte out on the I2C bus |
whismanoid | 0:3edb3708c8c5 | 2465 | // * |
whismanoid | 0:3edb3708c8c5 | 2466 | // * @param data data to write out on bus |
whismanoid | 0:3edb3708c8c5 | 2467 | // * |
whismanoid | 0:3edb3708c8c5 | 2468 | // * @returns |
whismanoid | 0:3edb3708c8c5 | 2469 | // * '0' - NAK was received |
whismanoid | 0:3edb3708c8c5 | 2470 | // * '1' - ACK was received, |
whismanoid | 0:3edb3708c8c5 | 2471 | // * '2' - timeout |
whismanoid | 0:3edb3708c8c5 | 2472 | // */ |
whismanoid | 0:3edb3708c8c5 | 2473 | // int write(int data); |
whismanoid | 0:3edb3708c8c5 | 2474 | int writeStatus = i2cMaster.write(addr8bit); |
whismanoid | 0:3edb3708c8c5 | 2475 | i2cMaster.stop(); |
whismanoid | 0:3edb3708c8c5 | 2476 | bool gotACK = (writeStatus == 1); // ACK was received |
whismanoid | 0:3edb3708c8c5 | 2477 | if (writeStatus == 2) // timeout |
whismanoid | 0:3edb3708c8c5 | 2478 | { |
whismanoid | 0:3edb3708c8c5 | 2479 | cmdLine.serial().printf("- timeout\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2480 | } |
whismanoid | 0:3edb3708c8c5 | 2481 | // |
whismanoid | 0:3edb3708c8c5 | 2482 | if (gotACK) |
whismanoid | 0:3edb3708c8c5 | 2483 | { |
whismanoid | 0:3edb3708c8c5 | 2484 | // @return status; error if (fileDescriptor < 0) |
whismanoid | 0:3edb3708c8c5 | 2485 | cmdLine.serial().printf("+ ADDR=0x%2.2X (0x%2.2X >> 1) ACK\r\n", deviceAddress7, (deviceAddress7 << 1)); |
whismanoid | 0:3edb3708c8c5 | 2486 | numDevicesFound++; |
whismanoid | 0:3edb3708c8c5 | 2487 | last_valid_deviceAddress7 = deviceAddress7; |
whismanoid | 0:3edb3708c8c5 | 2488 | if (numDevicesFound > numDevicesFoundLimit) |
whismanoid | 0:3edb3708c8c5 | 2489 | { |
whismanoid | 0:3edb3708c8c5 | 2490 | break; |
whismanoid | 0:3edb3708c8c5 | 2491 | } |
whismanoid | 0:3edb3708c8c5 | 2492 | continue; |
whismanoid | 0:3edb3708c8c5 | 2493 | } |
whismanoid | 0:3edb3708c8c5 | 2494 | } |
whismanoid | 0:3edb3708c8c5 | 2495 | if (numDevicesFound == 0) |
whismanoid | 0:3edb3708c8c5 | 2496 | { |
whismanoid | 0:3edb3708c8c5 | 2497 | cmdLine.serial().printf("- No I2C devices found. Maybe SCL/SDA are swapped?\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2498 | } |
whismanoid | 0:3edb3708c8c5 | 2499 | else if (numDevicesFound > numDevicesFoundLimit) |
whismanoid | 0:3edb3708c8c5 | 2500 | { |
whismanoid | 0:3edb3708c8c5 | 2501 | cmdLine.serial().printf("- Many I2C devices found. SCL/SDA missing pullup resistors? SCL stuck low?\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2502 | } |
whismanoid | 0:3edb3708c8c5 | 2503 | else |
whismanoid | 0:3edb3708c8c5 | 2504 | { |
whismanoid | 0:3edb3708c8c5 | 2505 | //~ i2c_ioctl_I2C_SLAVE_i2cDeviceAddress7bits(i2cFileDescriptor, last_valid_deviceAddress7); |
whismanoid | 0:3edb3708c8c5 | 2506 | g_I2C_deviceAddress7 = last_valid_deviceAddress7; |
whismanoid | 0:3edb3708c8c5 | 2507 | } |
whismanoid | 0:3edb3708c8c5 | 2508 | //~ i2c_close(i2cFileDescriptor); |
whismanoid | 0:3edb3708c8c5 | 2509 | } |
whismanoid | 0:3edb3708c8c5 | 2510 | #endif // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 2511 | |
whismanoid | 0:3edb3708c8c5 | 2512 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2513 | // periodic interrupt timer onTimerTick handler triggered by Ticker |
whismanoid | 0:3edb3708c8c5 | 2514 | // analogIn0 (MAX32630:AIN_4 = AIN0 / 5.0) controls angular speed |
whismanoid | 0:3edb3708c8c5 | 2515 | // analogIn1 (MAX32630:AIN_5 = AIN1 / 5.0) controls PWM duty cycle |
whismanoid | 0:3edb3708c8c5 | 2516 | // note: measured 500ns overhead for MAX32630FTHR digitalInOut1.write(0); digitalInOut1.write(1); |
whismanoid | 0:3edb3708c8c5 | 2517 | #if USE_PERIODIC_TIMER |
whismanoid | 0:3edb3708c8c5 | 2518 | void onTimerTick() { |
whismanoid | 0:3edb3708c8c5 | 2519 | } // onTimerTick |
whismanoid | 0:3edb3708c8c5 | 2520 | #endif |
whismanoid | 0:3edb3708c8c5 | 2521 | |
whismanoid | 0:3edb3708c8c5 | 2522 | #if USE_PERIODIC_TIMER |
whismanoid | 0:3edb3708c8c5 | 2523 | // periodic interrupt timer command handlers -- enable timer |
whismanoid | 0:3edb3708c8c5 | 2524 | void cmd_TE() |
whismanoid | 0:3edb3708c8c5 | 2525 | { |
whismanoid | 0:3edb3708c8c5 | 2526 | //us_timestamp_t interval_usec = 100000; // 100ms |
whismanoid | 0:3edb3708c8c5 | 2527 | periodicInterruptTimer_interval_usec = 100000; // 100ms |
whismanoid | 0:3edb3708c8c5 | 2528 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 2529 | DAPLINKserial.printf(" Timer Enable %d us\r\n", periodicInterruptTimer_interval_usec); |
whismanoid | 0:3edb3708c8c5 | 2530 | # endif |
whismanoid | 7:bf501f8cb637 | 2531 | serial.printf(" Timer Enable %d us", periodicInterruptTimer_interval_usec); |
whismanoid | 0:3edb3708c8c5 | 2532 | periodicInterruptTimer.attach_us(&onTimerTick, periodicInterruptTimer_interval_usec); |
whismanoid | 0:3edb3708c8c5 | 2533 | // -- periodicInterruptTimer.attach(&onTimerTick, interval_sec); // the address of the function to be attached (onTimerTick) and the interval (2 seconds) |
whismanoid | 0:3edb3708c8c5 | 2534 | // -- periodicInterruptTimer.attach_us(&onTimerTick, interval_usec); // the address of the function to be attached (onTimerTick) and the interval (2 seconds) |
whismanoid | 0:3edb3708c8c5 | 2535 | // -- periodicInterruptTimer.attach(Callback<void()> func, float t); |
whismanoid | 0:3edb3708c8c5 | 2536 | // -- periodicInterruptTimer.attach_us(Callback<void()> func, us_timestamp_t t); |
whismanoid | 0:3edb3708c8c5 | 2537 | // TODO1: cmd_T add cSubCommand to change interval of Ticker periodic interrupt timer |
whismanoid | 0:3edb3708c8c5 | 2538 | } |
whismanoid | 0:3edb3708c8c5 | 2539 | #endif |
whismanoid | 0:3edb3708c8c5 | 2540 | |
whismanoid | 0:3edb3708c8c5 | 2541 | #if USE_PERIODIC_TIMER |
whismanoid | 0:3edb3708c8c5 | 2542 | // periodic interrupt timer command handlers -- disable timer |
whismanoid | 0:3edb3708c8c5 | 2543 | void cmd_TD() |
whismanoid | 0:3edb3708c8c5 | 2544 | { |
whismanoid | 0:3edb3708c8c5 | 2545 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 2546 | DAPLINKserial.printf(" Timer Disable\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2547 | # endif |
whismanoid | 7:bf501f8cb637 | 2548 | serial.printf(" Timer Disable "); |
whismanoid | 0:3edb3708c8c5 | 2549 | periodicInterruptTimer.detach(); // Detach the function |
whismanoid | 0:3edb3708c8c5 | 2550 | } |
whismanoid | 0:3edb3708c8c5 | 2551 | #endif |
whismanoid | 0:3edb3708c8c5 | 2552 | |
whismanoid | 0:3edb3708c8c5 | 2553 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2554 | // When user presses button BUTTON1, perform a demo configuration |
whismanoid | 0:3edb3708c8c5 | 2555 | #if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 2556 | void onButton1FallingEdge(void) |
whismanoid | 0:3edb3708c8c5 | 2557 | { |
whismanoid | 0:3edb3708c8c5 | 2558 | void SelfTest(CmdLine & cmdLine); |
whismanoid | 0:3edb3708c8c5 | 2559 | |
whismanoid | 7:bf501f8cb637 | 2560 | SelfTest(cmdLine_serial); |
whismanoid | 0:3edb3708c8c5 | 2561 | |
whismanoid | 0:3edb3708c8c5 | 2562 | #if 0 // APPLICATION_MAX5715 // onButton1FallingEdge BUTTON1 demo configuration MAX5715BOB |
whismanoid | 0:3edb3708c8c5 | 2563 | //~ cmdLine.serial().printf("MAX5715_REF(REF_AlwaysOn_2V500)"); |
whismanoid | 0:3edb3708c8c5 | 2564 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); |
whismanoid | 0:3edb3708c8c5 | 2565 | |
whismanoid | 0:3edb3708c8c5 | 2566 | uint16_t code = 4095; |
whismanoid | 0:3edb3708c8c5 | 2567 | //~ cmdLine.serial().printf("CODEallLOADall code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 2568 | g_MAX5715_device.CODEallLOADall(code); |
whismanoid | 0:3edb3708c8c5 | 2569 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 2570 | |
whismanoid | 0:3edb3708c8c5 | 2571 | } |
whismanoid | 0:3edb3708c8c5 | 2572 | #endif // HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 2573 | |
whismanoid | 0:3edb3708c8c5 | 2574 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2575 | // When user presses button BUTTON2, perform a demo configuration |
whismanoid | 0:3edb3708c8c5 | 2576 | #if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 2577 | void onButton2FallingEdge(void) |
whismanoid | 0:3edb3708c8c5 | 2578 | { |
whismanoid | 0:3edb3708c8c5 | 2579 | // TODO1: BUTTON2 demo configuration LED blink |
whismanoid | 0:3edb3708c8c5 | 2580 | |
whismanoid | 0:3edb3708c8c5 | 2581 | #if APPLICATION_MAX5715 // onButton2FallingEdge BUTTON2 demo configuration MAX5715BOB |
whismanoid | 0:3edb3708c8c5 | 2582 | //~ cmdLine.serial().printf("MAX5715_REF(REF_AlwaysOn_2V048)"); |
whismanoid | 0:3edb3708c8c5 | 2583 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048); |
whismanoid | 0:3edb3708c8c5 | 2584 | // |
whismanoid | 0:3edb3708c8c5 | 2585 | uint16_t ch = 0; |
whismanoid | 0:3edb3708c8c5 | 2586 | uint16_t code = 0xccc; |
whismanoid | 0:3edb3708c8c5 | 2587 | //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 2588 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 2589 | // |
whismanoid | 0:3edb3708c8c5 | 2590 | ch = 1; |
whismanoid | 0:3edb3708c8c5 | 2591 | code = 0x800; |
whismanoid | 0:3edb3708c8c5 | 2592 | //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 2593 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 2594 | // |
whismanoid | 0:3edb3708c8c5 | 2595 | ch = 2; |
whismanoid | 0:3edb3708c8c5 | 2596 | code = 0x666; |
whismanoid | 0:3edb3708c8c5 | 2597 | //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 2598 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 2599 | // |
whismanoid | 0:3edb3708c8c5 | 2600 | ch = 3; |
whismanoid | 0:3edb3708c8c5 | 2601 | code = 0xFFF; |
whismanoid | 0:3edb3708c8c5 | 2602 | //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 2603 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 2604 | #elif APPLICATION_MAX11131 // onButton2FallingEdge BUTTON2 demo configuration MAX11131BOB |
whismanoid | 0:3edb3708c8c5 | 2605 | // TODO1: demo |
whismanoid | 0:3edb3708c8c5 | 2606 | // MAX11131 > 4 |
whismanoid | 0:3edb3708c8c5 | 2607 | // ScanStandardExternalClock ch=9 pm=0 id=1 |
whismanoid | 0:3edb3708c8c5 | 2608 | // ScanRead_nWords_chanID nWords=10 |
whismanoid | 0:3edb3708c8c5 | 2609 | // ch=0 xu=2964 = 0x0b94 = 1.8091V |
whismanoid | 0:3edb3708c8c5 | 2610 | // ch=1 xu=2227 = 0x08b3 = 1.3593V |
whismanoid | 0:3edb3708c8c5 | 2611 | // ch=2 xu=1570 = 0x0622 = 0.9583V |
whismanoid | 0:3edb3708c8c5 | 2612 | // ch=3 xu=865 = 0x0361 = 0.5280V |
whismanoid | 0:3edb3708c8c5 | 2613 | // ch=4 xu=630 = 0x0276 = 0.3845V |
whismanoid | 0:3edb3708c8c5 | 2614 | // ch=5 xu=594 = 0x0252 = 0.3625V |
whismanoid | 0:3edb3708c8c5 | 2615 | // ch=6 xu=461 = 0x01cd = 0.2814V |
whismanoid | 0:3edb3708c8c5 | 2616 | // ch=7 xu=364 = 0x016c = 0.2222V |
whismanoid | 0:3edb3708c8c5 | 2617 | // ch=8 xu=480 = 0x01e0 = 0.2930V |
whismanoid | 0:3edb3708c8c5 | 2618 | // ch=9 xu=616 = 0x0268 = 0.3760V |
whismanoid | 0:3edb3708c8c5 | 2619 | g_MAX11131_device.channelNumber_0_15 = 9; |
whismanoid | 0:3edb3708c8c5 | 2620 | g_MAX11131_device.PowerManagement_0_2 = 0; |
whismanoid | 0:3edb3708c8c5 | 2621 | g_MAX11131_device.chan_id_0_1 = 1; |
whismanoid | 0:3edb3708c8c5 | 2622 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 2623 | // |
whismanoid | 0:3edb3708c8c5 | 2624 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 2625 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 2626 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 2627 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 2628 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 2629 | // |
whismanoid | 0:3edb3708c8c5 | 2630 | // TODO: compare with mbed/Arduino AIN0-AIN3 |
whismanoid | 0:3edb3708c8c5 | 2631 | // |
whismanoid | 0:3edb3708c8c5 | 2632 | #elif APPLICATION_MAX5171 // onButton2FallingEdge BUTTON2 demo configuration MAX5171BOB |
whismanoid | 0:3edb3708c8c5 | 2633 | // TODO: demo |
whismanoid | 0:3edb3708c8c5 | 2634 | uint16_t code = 0xccc; |
whismanoid | 0:3edb3708c8c5 | 2635 | g_MAX5171_device.CODE(code); |
whismanoid | 0:3edb3708c8c5 | 2636 | #elif APPLICATION_MAX11410 // onButton2FallingEdge BUTTON2 demo configuration MAX11410BOB |
whismanoid | 0:3edb3708c8c5 | 2637 | // TODO: demo |
whismanoid | 0:3edb3708c8c5 | 2638 | g_MAX11410_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 2639 | #elif APPLICATION_MAX12345 // onButton2FallingEdge BUTTON2 demo configuration MAX12345BOB |
whismanoid | 0:3edb3708c8c5 | 2640 | // TODO: demo |
whismanoid | 0:3edb3708c8c5 | 2641 | g_MAX12345_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 2642 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 2643 | rgb_led.blue(); // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 2644 | |
whismanoid | 0:3edb3708c8c5 | 2645 | } |
whismanoid | 0:3edb3708c8c5 | 2646 | #endif // HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 2647 | |
whismanoid | 0:3edb3708c8c5 | 2648 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2649 | // TODO1: use MaximTinyTester encapsulate SelfTest support functions |
whismanoid | 0:3edb3708c8c5 | 2650 | //-------------------------------------------------- |
whismanoid | 2:b3a8a0ca0a94 | 2651 | #if APPLICATION_MAX5715 // SelfTest |
whismanoid | 2:b3a8a0ca0a94 | 2652 | // |
whismanoid | 2:b3a8a0ca0a94 | 2653 | // Note: ide.mbed.com does not support C++11 Lambda Expressions |
whismanoid | 2:b3a8a0ca0a94 | 2654 | // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ |
whismanoid | 2:b3a8a0ca0a94 | 2655 | // |
whismanoid | 2:b3a8a0ca0a94 | 2656 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2657 | // uint8_t MAX5715::Init(void) |
whismanoid | 2:b3a8a0ca0a94 | 2658 | // uint8_t (*fn_MAX5715_Init)() = [](){ return g_MAX5715_device.Init(); }; |
whismanoid | 2:b3a8a0ca0a94 | 2659 | uint8_t fn_MAX5715_Init() { return g_MAX5715_device.Init(); }; |
whismanoid | 2:b3a8a0ca0a94 | 2660 | // |
whismanoid | 2:b3a8a0ca0a94 | 2661 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2662 | // uint16_t MAX5715::DACCodeOfVoltage(double voltageV) |
whismanoid | 2:b3a8a0ca0a94 | 2663 | // uint16_t (*fn_MAX5715_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5715_device.DACCodeOfVoltage(voltageV); }; |
whismanoid | 2:b3a8a0ca0a94 | 2664 | uint16_t fn_MAX5715_DACCodeOfVoltage(double voltageV) { return g_MAX5715_device.DACCodeOfVoltage(voltageV); }; |
whismanoid | 2:b3a8a0ca0a94 | 2665 | // |
whismanoid | 2:b3a8a0ca0a94 | 2666 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2667 | // double MAX5715::VoltageOfCode(uint16_t value_u14) |
whismanoid | 2:b3a8a0ca0a94 | 2668 | //double (*fn_MAX5715_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5715_device.VoltageOfCode(value_u14); }; |
whismanoid | 2:b3a8a0ca0a94 | 2669 | double fn_MAX5715_VoltageOfCode(uint16_t value_u14) { return g_MAX5715_device.VoltageOfCode(value_u14); }; |
whismanoid | 2:b3a8a0ca0a94 | 2670 | // |
whismanoid | 2:b3a8a0ca0a94 | 2671 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2672 | // void MAX5715::CODEnLOADn(uint8_t channel_0_3, uint16_t dacCodeLsbs) |
whismanoid | 2:b3a8a0ca0a94 | 2673 | // 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 | 2674 | void fn_MAX5715_CODEnLOADn (uint8_t channel_0_3, uint16_t dacCodeLsbs) { return g_MAX5715_device.CODEnLOADn(channel_0_3, dacCodeLsbs); }; |
whismanoid | 2:b3a8a0ca0a94 | 2675 | // |
whismanoid | 2:b3a8a0ca0a94 | 2676 | #endif // APPLICATION_MAX5715 // SelfTest |
whismanoid | 2:b3a8a0ca0a94 | 2677 | //-------------------------------------------------- |
whismanoid | 2:b3a8a0ca0a94 | 2678 | #if APPLICATION_MAX11131 // SelfTest |
whismanoid | 2:b3a8a0ca0a94 | 2679 | // |
whismanoid | 2:b3a8a0ca0a94 | 2680 | // Note: ide.mbed.com does not support C++11 Lambda Expressions |
whismanoid | 2:b3a8a0ca0a94 | 2681 | // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ |
whismanoid | 2:b3a8a0ca0a94 | 2682 | // |
whismanoid | 2:b3a8a0ca0a94 | 2683 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2684 | // |
whismanoid | 2:b3a8a0ca0a94 | 2685 | #endif // APPLICATION_MAX11131 // SelfTest |
whismanoid | 2:b3a8a0ca0a94 | 2686 | //-------------------------------------------------- |
whismanoid | 2:b3a8a0ca0a94 | 2687 | #if APPLICATION_MAX5171 // SelfTest |
whismanoid | 2:b3a8a0ca0a94 | 2688 | // |
whismanoid | 2:b3a8a0ca0a94 | 2689 | // Note: ide.mbed.com does not support C++11 Lambda Expressions |
whismanoid | 2:b3a8a0ca0a94 | 2690 | // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ |
whismanoid | 2:b3a8a0ca0a94 | 2691 | // |
whismanoid | 2:b3a8a0ca0a94 | 2692 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2693 | // uint8_t MAX5171::Init(void) |
whismanoid | 2:b3a8a0ca0a94 | 2694 | // uint8_t (*fn_MAX5171_Init)() = [](){ return g_MAX5171_device.Init(); }; |
whismanoid | 2:b3a8a0ca0a94 | 2695 | uint8_t fn_MAX5171_Init() { return g_MAX5171_device.Init(); }; |
whismanoid | 2:b3a8a0ca0a94 | 2696 | // |
whismanoid | 2:b3a8a0ca0a94 | 2697 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2698 | // uint16_t MAX5171::DACCodeOfVoltage(double voltageV) |
whismanoid | 2:b3a8a0ca0a94 | 2699 | // uint16_t (*fn_MAX5171_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5171_device.DACCodeOfVoltage(voltageV); }; |
whismanoid | 2:b3a8a0ca0a94 | 2700 | uint16_t fn_MAX5171_DACCodeOfVoltage(double voltageV) { return g_MAX5171_device.DACCodeOfVoltage(voltageV); }; |
whismanoid | 2:b3a8a0ca0a94 | 2701 | // |
whismanoid | 2:b3a8a0ca0a94 | 2702 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2703 | // double MAX5171::VoltageOfCode(uint16_t value_u14) |
whismanoid | 2:b3a8a0ca0a94 | 2704 | // double (*fn_MAX5171_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5171_device.VoltageOfCode(value_u14); }; |
whismanoid | 2:b3a8a0ca0a94 | 2705 | double fn_MAX5171_VoltageOfCode(uint16_t value_u14) { return g_MAX5171_device.VoltageOfCode(value_u14); }; |
whismanoid | 2:b3a8a0ca0a94 | 2706 | // |
whismanoid | 2:b3a8a0ca0a94 | 2707 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2708 | // uint8_t MAX5171::CODE_LOAD(uint16_t dacCodeLsbs) |
whismanoid | 2:b3a8a0ca0a94 | 2709 | // uint8_t (*fn_MAX5171_CODE_LOAD)(uint16_t dacCodeLsbs) = [](uint16_t dacCodeLsbs){ return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); }; |
whismanoid | 2:b3a8a0ca0a94 | 2710 | uint8_t fn_MAX5171_CODE_LOAD(uint16_t dacCodeLsbs) { return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); }; |
whismanoid | 2:b3a8a0ca0a94 | 2711 | // |
whismanoid | 2:b3a8a0ca0a94 | 2712 | // |
whismanoid | 2:b3a8a0ca0a94 | 2713 | #endif // APPLICATION_MAX5171 // SelfTest |
whismanoid | 2:b3a8a0ca0a94 | 2714 | //-------------------------------------------------- |
whismanoid | 2:b3a8a0ca0a94 | 2715 | #if APPLICATION_MAX11410 // SelfTest |
whismanoid | 2:b3a8a0ca0a94 | 2716 | // |
whismanoid | 2:b3a8a0ca0a94 | 2717 | // Note: ide.mbed.com does not support C++11 Lambda Expressions |
whismanoid | 2:b3a8a0ca0a94 | 2718 | // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ |
whismanoid | 2:b3a8a0ca0a94 | 2719 | // |
whismanoid | 2:b3a8a0ca0a94 | 2720 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2721 | // |
whismanoid | 2:b3a8a0ca0a94 | 2722 | #endif // APPLICATION_MAX11410 // SelfTest |
whismanoid | 2:b3a8a0ca0a94 | 2723 | //-------------------------------------------------- |
whismanoid | 2:b3a8a0ca0a94 | 2724 | #if APPLICATION_MAX12345 // SelfTest |
whismanoid | 2:b3a8a0ca0a94 | 2725 | // |
whismanoid | 2:b3a8a0ca0a94 | 2726 | // Note: ide.mbed.com does not support C++11 Lambda Expressions |
whismanoid | 2:b3a8a0ca0a94 | 2727 | // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ |
whismanoid | 2:b3a8a0ca0a94 | 2728 | // |
whismanoid | 2:b3a8a0ca0a94 | 2729 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 2:b3a8a0ca0a94 | 2730 | // |
whismanoid | 2:b3a8a0ca0a94 | 2731 | #endif // APPLICATION_MAX12345 // SelfTest |
whismanoid | 2:b3a8a0ca0a94 | 2732 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2733 | void SelfTest_print_DACCodeOfVoltage(CmdLine& cmdLine, double voltageV) |
whismanoid | 0:3edb3708c8c5 | 2734 | { |
whismanoid | 0:3edb3708c8c5 | 2735 | cmdLine.serial().printf("DACCodeOfVoltage(%6.4fV)", voltageV); |
whismanoid | 0:3edb3708c8c5 | 2736 | // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001 |
whismanoid | 0:3edb3708c8c5 | 2737 | // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001 |
whismanoid | 0:3edb3708c8c5 | 2738 | //~ dtostrf(voltageV, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 2739 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 2740 | //~ cmdLine.serial().printf("V)"); |
whismanoid | 0:3edb3708c8c5 | 2741 | } |
whismanoid | 0:3edb3708c8c5 | 2742 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2743 | #if APPLICATION_MAX5171 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 2744 | void SelfTest_print_VoltageOfCode(CmdLine& cmdLine, uint16_t value_u14) |
whismanoid | 0:3edb3708c8c5 | 2745 | { |
whismanoid | 0:3edb3708c8c5 | 2746 | cmdLine.serial().printf("VoltageOfCode(%d)", value_u14); |
whismanoid | 0:3edb3708c8c5 | 2747 | } |
whismanoid | 0:3edb3708c8c5 | 2748 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 2749 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2750 | #if APPLICATION_MAX5715 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 2751 | void SelfTest_print_Vref(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 2752 | { |
whismanoid | 0:3edb3708c8c5 | 2753 | cmdLine.serial().printf("VRef = %6.4fV LSB=%6.4fV", g_MAX5715_device.VRef, (g_MAX5715_device.VRef / 4095)); |
whismanoid | 0:3edb3708c8c5 | 2754 | //~ dtostrf(g_MAX5715_device.VRef, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 2755 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 2756 | //~ cmdLine.serial().printf("V LSB="); |
whismanoid | 0:3edb3708c8c5 | 2757 | // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001 |
whismanoid | 0:3edb3708c8c5 | 2758 | // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001 |
whismanoid | 0:3edb3708c8c5 | 2759 | //~ dtostrf( (g_MAX5715_device.VRef / 4095), 6, 4, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 2760 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 2761 | //~ cmdLine.serial().printf("V"); |
whismanoid | 0:3edb3708c8c5 | 2762 | } |
whismanoid | 0:3edb3708c8c5 | 2763 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 2764 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2765 | #if APPLICATION_MAX5171 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 2766 | void SelfTest_print_Vref(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 2767 | { |
whismanoid | 0:3edb3708c8c5 | 2768 | cmdLine.serial().printf("VRef = %7.5fV LSB=%7.5fV", g_MAX5171_device.VRef, (g_MAX5171_device.VRef / 16383)); |
whismanoid | 0:3edb3708c8c5 | 2769 | // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001 |
whismanoid | 0:3edb3708c8c5 | 2770 | // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001 |
whismanoid | 0:3edb3708c8c5 | 2771 | } |
whismanoid | 0:3edb3708c8c5 | 2772 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 2773 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2774 | #if HAS_SPI2_MAX541 |
whismanoid | 0:3edb3708c8c5 | 2775 | MAX541 max541(spi2_max541, spi2_max541_cs); |
whismanoid | 0:3edb3708c8c5 | 2776 | #endif |
whismanoid | 0:3edb3708c8c5 | 2777 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2778 | bool SelfTest_MAX541_Voltage(CmdLine & cmdLine, MAX541 &max541, double voltageV) |
whismanoid | 0:3edb3708c8c5 | 2779 | { |
whismanoid | 0:3edb3708c8c5 | 2780 | max541.Set_Voltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 2781 | // 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 | 2782 | cmdLine.serial().printf("\r\n Test Fixture: MAX541 set output to 0x%4.4x = %1.3fV", |
whismanoid | 0:3edb3708c8c5 | 2783 | max541.Get_Code(), max541.Get_Voltage()); |
whismanoid | 0:3edb3708c8c5 | 2784 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2785 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 8:6bdfb1376fed | 2786 | MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4, led1, led2, led3); |
whismanoid | 0:3edb3708c8c5 | 2787 | tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support |
whismanoid | 0:3edb3708c8c5 | 2788 | tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support |
whismanoid | 0:3edb3708c8c5 | 2789 | tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support |
whismanoid | 0:3edb3708c8c5 | 2790 | tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support |
whismanoid | 0:3edb3708c8c5 | 2791 | tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support |
whismanoid | 0:3edb3708c8c5 | 2792 | tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support |
whismanoid | 0:3edb3708c8c5 | 2793 | // low range channels AIN0, AIN1, AIN2, AIN3 |
whismanoid | 0:3edb3708c8c5 | 2794 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2795 | // Platform board uses simple analog inputs |
whismanoid | 8:6bdfb1376fed | 2796 | MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5, led1, led2, led3); |
whismanoid | 0:3edb3708c8c5 | 2797 | tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support |
whismanoid | 0:3edb3708c8c5 | 2798 | tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support |
whismanoid | 0:3edb3708c8c5 | 2799 | tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support |
whismanoid | 0:3edb3708c8c5 | 2800 | tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support |
whismanoid | 0:3edb3708c8c5 | 2801 | tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support |
whismanoid | 0:3edb3708c8c5 | 2802 | tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support |
whismanoid | 0:3edb3708c8c5 | 2803 | #endif |
whismanoid | 5:82037e281451 | 2804 | tinyTester.Wait_Output_Settling(); // wait for MAX541 to settle |
whismanoid | 0:3edb3708c8c5 | 2805 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 2806 | tinyTester.err_threshold = 0.100; |
whismanoid | 0:3edb3708c8c5 | 2807 | return tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); |
whismanoid | 0:3edb3708c8c5 | 2808 | } |
whismanoid | 0:3edb3708c8c5 | 2809 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2810 | void SelfTest(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 2811 | { |
whismanoid | 0:3edb3708c8c5 | 2812 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2813 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2814 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 8:6bdfb1376fed | 2815 | MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4, led1, led2, led3); |
whismanoid | 0:3edb3708c8c5 | 2816 | tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support |
whismanoid | 0:3edb3708c8c5 | 2817 | tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support |
whismanoid | 0:3edb3708c8c5 | 2818 | tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support |
whismanoid | 0:3edb3708c8c5 | 2819 | tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support |
whismanoid | 0:3edb3708c8c5 | 2820 | tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support |
whismanoid | 0:3edb3708c8c5 | 2821 | tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support |
whismanoid | 0:3edb3708c8c5 | 2822 | // low range channels AIN0, AIN1, AIN2, AIN3 |
whismanoid | 0:3edb3708c8c5 | 2823 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2824 | // Platform board uses simple analog inputs |
whismanoid | 8:6bdfb1376fed | 2825 | MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5, led1, led2, led3); |
whismanoid | 0:3edb3708c8c5 | 2826 | tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support |
whismanoid | 0:3edb3708c8c5 | 2827 | tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support |
whismanoid | 0:3edb3708c8c5 | 2828 | tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support |
whismanoid | 0:3edb3708c8c5 | 2829 | tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support |
whismanoid | 0:3edb3708c8c5 | 2830 | tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support |
whismanoid | 0:3edb3708c8c5 | 2831 | tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support |
whismanoid | 0:3edb3708c8c5 | 2832 | #endif |
whismanoid | 8:6bdfb1376fed | 2833 | tinyTester.clear(); |
whismanoid | 0:3edb3708c8c5 | 2834 | #if APPLICATION_MAX5715 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 2835 | // |
whismanoid | 5:82037e281451 | 2836 | // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 2837 | // |
whismanoid | 1:40369075c365 | 2838 | // Note: ide.mbed.com does not support C++11 Lambda Expressions |
whismanoid | 1:40369075c365 | 2839 | // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ |
whismanoid | 0:3edb3708c8c5 | 2840 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 2841 | // uint8_t MAX5715::Init(void) |
whismanoid | 2:b3a8a0ca0a94 | 2842 | //uint8_t (*fn_MAX5715_Init)() = [](){ return g_MAX5715_device.Init(); }; |
whismanoid | 0:3edb3708c8c5 | 2843 | // |
whismanoid | 0:3edb3708c8c5 | 2844 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 2845 | // uint16_t MAX5715::DACCodeOfVoltage(double voltageV) |
whismanoid | 2:b3a8a0ca0a94 | 2846 | //uint16_t (*fn_MAX5715_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5715_device.DACCodeOfVoltage(voltageV); }; |
whismanoid | 0:3edb3708c8c5 | 2847 | // |
whismanoid | 0:3edb3708c8c5 | 2848 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 2849 | // double MAX5715::VoltageOfCode(uint16_t value_u14) |
whismanoid | 2:b3a8a0ca0a94 | 2850 | //double (*fn_MAX5715_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5715_device.VoltageOfCode(value_u14); }; |
whismanoid | 0:3edb3708c8c5 | 2851 | // |
whismanoid | 0:3edb3708c8c5 | 2852 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 2853 | // void MAX5715::CODEnLOADn(uint8_t channel_0_3, uint16_t dacCodeLsbs) |
whismanoid | 2:b3a8a0ca0a94 | 2854 | //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 | 2855 | // |
whismanoid | 0:3edb3708c8c5 | 2856 | // |
whismanoid | 0:3edb3708c8c5 | 2857 | // |
whismanoid | 0:3edb3708c8c5 | 2858 | // |
whismanoid | 0:3edb3708c8c5 | 2859 | // |
whismanoid | 0:3edb3708c8c5 | 2860 | //------------------------------------------------------------ |
whismanoid | 0:3edb3708c8c5 | 2861 | g_MAX5715_device.VRef = 4.096; // MAX5715 12-bit LSB = 0.0010V |
whismanoid | 0:3edb3708c8c5 | 2862 | SelfTest_print_Vref(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 2863 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2864 | // |
whismanoid | 9:9b4232e20020 | 2865 | tinyTester.blink_time_msec = 20; // quickly speed through the software verification |
whismanoid | 0:3edb3708c8c5 | 2866 | // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 2867 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS |
whismanoid | 0:3edb3708c8c5 | 2868 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0950, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2869 | // |
whismanoid | 0:3edb3708c8c5 | 2870 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0945, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2871 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0944, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2872 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0943, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2873 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0942, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2874 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0941, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2875 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0940, 0x0FFE); // search for code transition |
whismanoid | 0:3edb3708c8c5 | 2876 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0939, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2877 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0938, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2878 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0937, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2879 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0936, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2880 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0935, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 2881 | // |
whismanoid | 0:3edb3708c8c5 | 2882 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0930, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 2883 | // |
whismanoid | 0:3edb3708c8c5 | 2884 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0480, 0x0800); |
whismanoid | 0:3edb3708c8c5 | 2885 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0470, 0x07FF); |
whismanoid | 0:3edb3708c8c5 | 2886 | // |
whismanoid | 0:3edb3708c8c5 | 2887 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x03E8); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 2888 | // |
whismanoid | 0:3edb3708c8c5 | 2889 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0030, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 2890 | // |
whismanoid | 0:3edb3708c8c5 | 2891 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0020, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 2892 | // |
whismanoid | 0:3edb3708c8c5 | 2893 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 2894 | // |
whismanoid | 0:3edb3708c8c5 | 2895 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 2896 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 2897 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 2898 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 2899 | // |
whismanoid | 0:3edb3708c8c5 | 2900 | // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect |
whismanoid | 0:3edb3708c8c5 | 2901 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 4.0950); |
whismanoid | 0:3edb3708c8c5 | 2902 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 4.0940); |
whismanoid | 0:3edb3708c8c5 | 2903 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 2.0480); |
whismanoid | 0:3edb3708c8c5 | 2904 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 2.0470); |
whismanoid | 0:3edb3708c8c5 | 2905 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x03E8, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 2906 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0010); |
whismanoid | 0:3edb3708c8c5 | 2907 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 2908 | // |
whismanoid | 0:3edb3708c8c5 | 2909 | //------------------------------------------------------------ |
whismanoid | 0:3edb3708c8c5 | 2910 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2911 | g_MAX5715_device.VRef = 2.048; // 12-bit LSB = 0.0005V |
whismanoid | 0:3edb3708c8c5 | 2912 | SelfTest_print_Vref(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 2913 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2914 | // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 2915 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS |
whismanoid | 0:3edb3708c8c5 | 2916 | // |
whismanoid | 0:3edb3708c8c5 | 2917 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0480, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2918 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0479, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2919 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0478, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2920 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0477, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2921 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0476, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2922 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0475, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2923 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0474, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2924 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0473, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2925 | // |
whismanoid | 0:3edb3708c8c5 | 2926 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0472, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2927 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0471, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2928 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0470, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2929 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0469, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2930 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0468, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 2931 | // |
whismanoid | 0:3edb3708c8c5 | 2932 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0467, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 2933 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0466, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 2934 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0465, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 2935 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0464, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 2936 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0463, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 2937 | // |
whismanoid | 0:3edb3708c8c5 | 2938 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0240, 0x0800); |
whismanoid | 0:3edb3708c8c5 | 2939 | // |
whismanoid | 0:3edb3708c8c5 | 2940 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0235, 0x07FF); |
whismanoid | 0:3edb3708c8c5 | 2941 | // |
whismanoid | 0:3edb3708c8c5 | 2942 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x07D0); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 2943 | // |
whismanoid | 0:3edb3708c8c5 | 2944 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0017, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 2945 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0016, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 2946 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0015, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 2947 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0014, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 2948 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0013, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 2949 | // |
whismanoid | 0:3edb3708c8c5 | 2950 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0012, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 2951 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0011, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 2952 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 2953 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0009, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 2954 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0008, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 2955 | // |
whismanoid | 0:3edb3708c8c5 | 2956 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0007, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 2957 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0006, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 2958 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0005, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 2959 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0004, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 2960 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0003, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 2961 | // |
whismanoid | 0:3edb3708c8c5 | 2962 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0002, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 2963 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0001, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 2964 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 2965 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 2966 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 2967 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 2968 | // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect |
whismanoid | 0:3edb3708c8c5 | 2969 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 2.0475); |
whismanoid | 0:3edb3708c8c5 | 2970 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 2.0470); |
whismanoid | 0:3edb3708c8c5 | 2971 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFD, 2.0465); |
whismanoid | 0:3edb3708c8c5 | 2972 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 1.0240); |
whismanoid | 0:3edb3708c8c5 | 2973 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 1.0235); |
whismanoid | 0:3edb3708c8c5 | 2974 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07D0, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 2975 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0002, 0.0010); |
whismanoid | 0:3edb3708c8c5 | 2976 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0005); |
whismanoid | 0:3edb3708c8c5 | 2977 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 2978 | // |
whismanoid | 0:3edb3708c8c5 | 2979 | // |
whismanoid | 0:3edb3708c8c5 | 2980 | //------------------------------------------------------------ |
whismanoid | 0:3edb3708c8c5 | 2981 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2982 | g_MAX5715_device.VRef = 2.500; // 12-bit LSB = 0.0006105006105006105V |
whismanoid | 0:3edb3708c8c5 | 2983 | SelfTest_print_Vref(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 2984 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2985 | // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 2986 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS |
whismanoid | 0:3edb3708c8c5 | 2987 | // |
whismanoid | 0:3edb3708c8c5 | 2988 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.5000, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2989 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4999, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2990 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4998, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2991 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4997, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2992 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4996, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2993 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4995, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2994 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4994, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2995 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4993, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2996 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4992, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2997 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4991, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2998 | // |
whismanoid | 0:3edb3708c8c5 | 2999 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4990, 0x0FFE); // search for code transitions |
whismanoid | 0:3edb3708c8c5 | 3000 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4989, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3001 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4988, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3002 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4987, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3003 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4986, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3004 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4985, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3005 | // |
whismanoid | 0:3edb3708c8c5 | 3006 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4984, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 3007 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4983, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 3008 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4982, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 3009 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4981, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 3010 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4980, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 3011 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4979, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 3012 | // |
whismanoid | 0:3edb3708c8c5 | 3013 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4978, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 3014 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4977, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 3015 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4976, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 3016 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4975, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 3017 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4974, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 3018 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4973, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 3019 | // |
whismanoid | 0:3edb3708c8c5 | 3020 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4972, 0x0FFB); |
whismanoid | 0:3edb3708c8c5 | 3021 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4971, 0x0FFB); |
whismanoid | 0:3edb3708c8c5 | 3022 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4970, 0x0FFB); |
whismanoid | 0:3edb3708c8c5 | 3023 | // |
whismanoid | 0:3edb3708c8c5 | 3024 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.2500, 0x0800); |
whismanoid | 0:3edb3708c8c5 | 3025 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.2494, 0x07FF); |
whismanoid | 0:3edb3708c8c5 | 3026 | // |
whismanoid | 0:3edb3708c8c5 | 3027 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x0666); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 3028 | // |
whismanoid | 0:3edb3708c8c5 | 3029 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0019, 0x0003); // search for code transitions |
whismanoid | 0:3edb3708c8c5 | 3030 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0018, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 3031 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0017, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 3032 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0016, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 3033 | // |
whismanoid | 0:3edb3708c8c5 | 3034 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0015, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 3035 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0014, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 3036 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0013, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 3037 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0012, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 3038 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0011, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 3039 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 3040 | // |
whismanoid | 0:3edb3708c8c5 | 3041 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0009, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 3042 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0008, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 3043 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0007, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 3044 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0006, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 3045 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0005, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 3046 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0004, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 3047 | // |
whismanoid | 0:3edb3708c8c5 | 3048 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0003, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 3049 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0002, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 3050 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0001, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 3051 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 3052 | // |
whismanoid | 0:3edb3708c8c5 | 3053 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 3054 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 3055 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 3056 | // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect |
whismanoid | 0:3edb3708c8c5 | 3057 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 2.5000); |
whismanoid | 0:3edb3708c8c5 | 3058 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 2.4988); |
whismanoid | 0:3edb3708c8c5 | 3059 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFD, 2.4976); |
whismanoid | 0:3edb3708c8c5 | 3060 | // |
whismanoid | 0:3edb3708c8c5 | 3061 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 1.2500); |
whismanoid | 0:3edb3708c8c5 | 3062 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 1.2494); |
whismanoid | 0:3edb3708c8c5 | 3063 | // |
whismanoid | 0:3edb3708c8c5 | 3064 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0667, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 3065 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0666, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 3066 | // |
whismanoid | 0:3edb3708c8c5 | 3067 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0002, 0.0012); |
whismanoid | 0:3edb3708c8c5 | 3068 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0006); |
whismanoid | 0:3edb3708c8c5 | 3069 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 3070 | // |
whismanoid | 0:3edb3708c8c5 | 3071 | // |
whismanoid | 0:3edb3708c8c5 | 3072 | // Device Testing: DAC commands, verify using on-board ADC inputs |
whismanoid | 0:3edb3708c8c5 | 3073 | // |
whismanoid | 9:9b4232e20020 | 3074 | tinyTester.blink_time_msec = 75; |
whismanoid | 0:3edb3708c8c5 | 3075 | cmdLine.serial().printf("\r\n MAX5715.Init()"); |
whismanoid | 0:3edb3708c8c5 | 3076 | g_MAX5715_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 3077 | // |
whismanoid | 0:3edb3708c8c5 | 3078 | uint16_t ch = 0; |
whismanoid | 0:3edb3708c8c5 | 3079 | uint16_t code = 0xfff; |
whismanoid | 0:3edb3708c8c5 | 3080 | double voltageV = 0.5; |
whismanoid | 0:3edb3708c8c5 | 3081 | // |
whismanoid | 0:3edb3708c8c5 | 3082 | // full-scale output on ch0, test MAX5715 internal REF options |
whismanoid | 0:3edb3708c8c5 | 3083 | ch = 0; |
whismanoid | 0:3edb3708c8c5 | 3084 | cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 3085 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 3086 | // |
whismanoid | 0:3edb3708c8c5 | 3087 | cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_2V048)"); |
whismanoid | 0:3edb3708c8c5 | 3088 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048); |
whismanoid | 5:82037e281451 | 3089 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3090 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3091 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3092 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 3093 | tinyTester.AnalogIn0_Read_Expect_voltageV(2.048); |
whismanoid | 0:3edb3708c8c5 | 3094 | // |
whismanoid | 0:3edb3708c8c5 | 3095 | cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_4V096)"); |
whismanoid | 0:3edb3708c8c5 | 3096 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_4V096); |
whismanoid | 0:3edb3708c8c5 | 3097 | // MAX32625MBED 4.096V may be as low as 3.3V supply |
whismanoid | 5:82037e281451 | 3098 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3099 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3100 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3101 | tinyTester.err_threshold = 0.50; // 30mV |
whismanoid | 0:3edb3708c8c5 | 3102 | tinyTester.AnalogIn0_Read_Expect_voltageV(3.750); // accept 3.25V to 4.25V |
whismanoid | 0:3edb3708c8c5 | 3103 | // |
whismanoid | 0:3edb3708c8c5 | 3104 | cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_2V500)"); |
whismanoid | 0:3edb3708c8c5 | 3105 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); |
whismanoid | 5:82037e281451 | 3106 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3107 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3108 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3109 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 3110 | tinyTester.AnalogIn0_Read_Expect_voltageV(2.500); |
whismanoid | 0:3edb3708c8c5 | 3111 | // |
whismanoid | 0:3edb3708c8c5 | 3112 | // test the individual channel outputs |
whismanoid | 0:3edb3708c8c5 | 3113 | ch = 0; |
whismanoid | 0:3edb3708c8c5 | 3114 | voltageV = 0.5; |
whismanoid | 0:3edb3708c8c5 | 3115 | code = g_MAX5715_device.DACCodeOfVoltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3116 | cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 3117 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 5:82037e281451 | 3118 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3119 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3120 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3121 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 3122 | tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3123 | // |
whismanoid | 0:3edb3708c8c5 | 3124 | ch = 1; |
whismanoid | 0:3edb3708c8c5 | 3125 | voltageV = 0.2; |
whismanoid | 0:3edb3708c8c5 | 3126 | code = g_MAX5715_device.DACCodeOfVoltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3127 | cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 3128 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 5:82037e281451 | 3129 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3130 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3131 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3132 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 3133 | tinyTester.AnalogIn1_Read_Expect_voltageV(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3134 | // |
whismanoid | 0:3edb3708c8c5 | 3135 | ch = 2; |
whismanoid | 0:3edb3708c8c5 | 3136 | voltageV = 0.4; |
whismanoid | 0:3edb3708c8c5 | 3137 | code = g_MAX5715_device.DACCodeOfVoltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3138 | cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 3139 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 5:82037e281451 | 3140 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3141 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3142 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3143 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 3144 | tinyTester.AnalogIn2_Read_Expect_voltageV(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3145 | // |
whismanoid | 0:3edb3708c8c5 | 3146 | ch = 3; |
whismanoid | 0:3edb3708c8c5 | 3147 | voltageV = 0.25; |
whismanoid | 0:3edb3708c8c5 | 3148 | code = g_MAX5715_device.DACCodeOfVoltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3149 | cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 3150 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 5:82037e281451 | 3151 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3152 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3153 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3154 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 3155 | tinyTester.AnalogIn3_Read_Expect_voltageV(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3156 | // |
whismanoid | 0:3edb3708c8c5 | 3157 | // test that the channels are independent |
whismanoid | 0:3edb3708c8c5 | 3158 | tinyTester.AnalogIn0_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[0])); |
whismanoid | 0:3edb3708c8c5 | 3159 | tinyTester.AnalogIn1_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[1])); |
whismanoid | 0:3edb3708c8c5 | 3160 | tinyTester.AnalogIn2_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[2])); |
whismanoid | 0:3edb3708c8c5 | 3161 | tinyTester.AnalogIn3_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[3])); |
whismanoid | 0:3edb3708c8c5 | 3162 | // |
whismanoid | 0:3edb3708c8c5 | 3163 | #elif APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 3164 | // |
whismanoid | 0:3edb3708c8c5 | 3165 | // MAX11131BOB self-test functions |
whismanoid | 0:3edb3708c8c5 | 3166 | //~ SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3167 | //~ cmdLine.serial().printf("test program not implemented yet"); |
whismanoid | 0:3edb3708c8c5 | 3168 | int16_t value_u12; |
whismanoid | 0:3edb3708c8c5 | 3169 | int channelId; |
whismanoid | 0:3edb3708c8c5 | 3170 | double voltageV = 0.5; |
whismanoid | 0:3edb3708c8c5 | 3171 | // |
whismanoid | 0:3edb3708c8c5 | 3172 | //cmdLine.serial().printf("\r\n 0.0: MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 3173 | //g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 3174 | // |
whismanoid | 0:3edb3708c8c5 | 3175 | // Device Testing: ADC commands, verify with on-board ADC and SPI framing |
whismanoid | 0:3edb3708c8c5 | 3176 | // |
whismanoid | 9:9b4232e20020 | 3177 | tinyTester.blink_time_msec = 75; |
whismanoid | 0:3edb3708c8c5 | 3178 | // MAX11131 SelfTest: MAX11131 SPI connections (Power Supply and GND, SCLK, MOSI, MISO, CS) |
whismanoid | 0:3edb3708c8c5 | 3179 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3180 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 3181 | "\r\n 1.0: Test SCAN_0100_StandardExt -- verify SPI (VDD, GND, SCLK, MOSI, MISO, CS)"); |
whismanoid | 0:3edb3708c8c5 | 3182 | cmdLine.serial().printf("\r\n MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 3183 | g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 3184 | // Send MOSI data Expect MISO data Description |
whismanoid | 0:3edb3708c8c5 | 3185 | // 1000_0000_0000_0000 xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0 |
whismanoid | 0:3edb3708c8c5 | 3186 | // 0010_0111_1010_0100 xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL SCAN_0100_StandardExt CHSEL=15 RESET=1 CHANID=1 |
whismanoid | 0:3edb3708c8c5 | 3187 | // 0000_0000_0000_0000 0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0 |
whismanoid | 0:3edb3708c8c5 | 3188 | // 0000_0000_0000_0000 0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1 |
whismanoid | 0:3edb3708c8c5 | 3189 | // 0000_0000_0000_0000 0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2 |
whismanoid | 0:3edb3708c8c5 | 3190 | // 0000_0000_0000_0000 0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3 |
whismanoid | 0:3edb3708c8c5 | 3191 | // |
whismanoid | 0:3edb3708c8c5 | 3192 | cmdLine.serial().printf("\r\n MOSI <-- 1000_0000_0000_0000 ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0"); |
whismanoid | 0:3edb3708c8c5 | 3193 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 3194 | g_MAX11131_device.SPIwrite16bits(0x8000); |
whismanoid | 0:3edb3708c8c5 | 3195 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 3196 | // |
whismanoid | 0:3edb3708c8c5 | 3197 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 3198 | "\r\n MOSI <-- 0010_0111_1010_0100 ADC_MODE_CONTROL SCAN_0100_StandardExt CHSEL=15 RESET=1 CHANID=1"); |
whismanoid | 0:3edb3708c8c5 | 3199 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 3200 | g_MAX11131_device.SPIwrite16bits(0x27a4); |
whismanoid | 0:3edb3708c8c5 | 3201 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 3202 | // |
whismanoid | 0:3edb3708c8c5 | 3203 | for (int channelIndex = 0; channelIndex < 16; channelIndex++) { |
whismanoid | 0:3edb3708c8c5 | 3204 | //~ cmdLine.serial().printf("\r\n MISO --> expect 0000_xxxx_xxxx_xxxx"); |
whismanoid | 0:3edb3708c8c5 | 3205 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 3206 | g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits(); |
whismanoid | 0:3edb3708c8c5 | 3207 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 3208 | int expect_channelId = channelIndex; |
whismanoid | 0:3edb3708c8c5 | 3209 | int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F; |
whismanoid | 0:3edb3708c8c5 | 3210 | if (actual_channelId != expect_channelId) |
whismanoid | 0:3edb3708c8c5 | 3211 | { |
whismanoid | 3:8913cb4a8b9f | 3212 | tinyTester.FAIL(); |
whismanoid | 0:3edb3708c8c5 | 3213 | cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 3214 | cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); |
whismanoid | 0:3edb3708c8c5 | 3215 | cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId); |
whismanoid | 0:3edb3708c8c5 | 3216 | } |
whismanoid | 0:3edb3708c8c5 | 3217 | else |
whismanoid | 0:3edb3708c8c5 | 3218 | { |
whismanoid | 3:8913cb4a8b9f | 3219 | tinyTester.PASS(); |
whismanoid | 0:3edb3708c8c5 | 3220 | cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 3221 | cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); |
whismanoid | 0:3edb3708c8c5 | 3222 | } |
whismanoid | 0:3edb3708c8c5 | 3223 | } |
whismanoid | 0:3edb3708c8c5 | 3224 | // |
whismanoid | 5:82037e281451 | 3225 | // MAX11131 SelfTest: MAX11131 Supports Internal Clock Modes (CNVST, EOC) |
whismanoid | 0:3edb3708c8c5 | 3226 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3227 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 3228 | "\r\n 1.1: Test SCAN_0011_StandardInt -- verify Internal Clock signals (CNVST, EOC)"); |
whismanoid | 0:3edb3708c8c5 | 3229 | cmdLine.serial().printf("\r\n MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 3230 | g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 3231 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 3232 | g_MAX11131_device.RAW_misoData16[0] = g_MAX11131_device.SPIread16bits(); |
whismanoid | 0:3edb3708c8c5 | 3233 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 3:8913cb4a8b9f | 3234 | // |
whismanoid | 5:82037e281451 | 3235 | // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect |
whismanoid | 3:8913cb4a8b9f | 3236 | tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "initial value before sending commands"); |
whismanoid | 3:8913cb4a8b9f | 3237 | // |
whismanoid | 0:3edb3708c8c5 | 3238 | // Send MOSI data Expect MISO data Description |
whismanoid | 0:3edb3708c8c5 | 3239 | // 1000_0000_0000_0000 xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0 No Averaging |
whismanoid | 0:3edb3708c8c5 | 3240 | // 0001_1001_1010_0000 xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL SCAN_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0 |
whismanoid | 0:3edb3708c8c5 | 3241 | // 0000_0000_0000_0000 0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0 |
whismanoid | 0:3edb3708c8c5 | 3242 | // 0000_0000_0000_0000 0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1 |
whismanoid | 0:3edb3708c8c5 | 3243 | // 0000_0000_0000_0000 0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2 |
whismanoid | 0:3edb3708c8c5 | 3244 | // 0000_0000_0000_0000 0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3 |
whismanoid | 0:3edb3708c8c5 | 3245 | // |
whismanoid | 0:3edb3708c8c5 | 3246 | cmdLine.serial().printf("\r\n MOSI <-- 1000_0000_0000_0000 ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0"); |
whismanoid | 0:3edb3708c8c5 | 3247 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 3248 | g_MAX11131_device.SPIwrite16bits(0x8000); |
whismanoid | 0:3edb3708c8c5 | 3249 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 3250 | // |
whismanoid | 0:3edb3708c8c5 | 3251 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 3252 | "\r\n MOSI <-- 0001_1001_1010_0000 ADC_MODE_CONTROL SCAN_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0"); |
whismanoid | 0:3edb3708c8c5 | 3253 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 3254 | g_MAX11131_device.SPIwrite16bits(0x19a0); |
whismanoid | 0:3edb3708c8c5 | 3255 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 3256 | // |
whismanoid | 0:3edb3708c8c5 | 3257 | for (int channelIndex = 0; channelIndex < 4; channelIndex++) { |
whismanoid | 0:3edb3708c8c5 | 3258 | //~ cmdLine.serial().printf("\r\n MISO --> expect 0000_xxxx_xxxx_xxxx"); |
whismanoid | 0:3edb3708c8c5 | 3259 | //~ wait_ms(200); // delay |
whismanoid | 0:3edb3708c8c5 | 3260 | g_MAX11131_device.CNVSToutputPulseLow(); |
whismanoid | 0:3edb3708c8c5 | 3261 | //~ g_MAX11131_device.CNVSToutputValue(0); |
whismanoid | 0:3edb3708c8c5 | 3262 | //~ wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 3263 | //~ g_MAX11131_device.CNVSToutputValue(1); |
whismanoid | 0:3edb3708c8c5 | 3264 | // g_MAX11131_device.EOCinputWaitUntilLow(); // infinite wait hazard, need to fail if timeout exceeded |
whismanoid | 5:82037e281451 | 3265 | // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect |
whismanoid | 3:8913cb4a8b9f | 3266 | tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 0, "after CNVST pulse"); |
whismanoid | 0:3edb3708c8c5 | 3267 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 3268 | g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits(); |
whismanoid | 0:3edb3708c8c5 | 3269 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 5:82037e281451 | 3270 | // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect |
whismanoid | 3:8913cb4a8b9f | 3271 | tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "after SPI read"); |
whismanoid | 0:3edb3708c8c5 | 3272 | int expect_channelId = channelIndex; |
whismanoid | 0:3edb3708c8c5 | 3273 | int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F; |
whismanoid | 0:3edb3708c8c5 | 3274 | if (actual_channelId != expect_channelId) |
whismanoid | 0:3edb3708c8c5 | 3275 | { |
whismanoid | 3:8913cb4a8b9f | 3276 | tinyTester.FAIL(); |
whismanoid | 0:3edb3708c8c5 | 3277 | cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 3278 | cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); |
whismanoid | 0:3edb3708c8c5 | 3279 | cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId); |
whismanoid | 0:3edb3708c8c5 | 3280 | } |
whismanoid | 0:3edb3708c8c5 | 3281 | else |
whismanoid | 0:3edb3708c8c5 | 3282 | { |
whismanoid | 3:8913cb4a8b9f | 3283 | tinyTester.PASS(); |
whismanoid | 0:3edb3708c8c5 | 3284 | cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 3285 | cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); |
whismanoid | 0:3edb3708c8c5 | 3286 | } |
whismanoid | 0:3edb3708c8c5 | 3287 | } |
whismanoid | 0:3edb3708c8c5 | 3288 | // |
whismanoid | 5:82037e281451 | 3289 | // MAX11131 SelfTest: Test Fixture: MAX541ACPA+ to MAX32625MBED.AIN0/AIN4 |
whismanoid | 0:3edb3708c8c5 | 3290 | // Test Fixture: MAX541 connected to spi2 |
whismanoid | 0:3edb3708c8c5 | 3291 | // 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 | 3292 | // DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header |
whismanoid | 0:3edb3708c8c5 | 3293 | // Test Fixture: MAX541 spi2 init |
whismanoid | 0:3edb3708c8c5 | 3294 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3295 | cmdLine.serial().printf("\r\n 2.0: Test Fixture: MAX541 connected to spi2 (P2.4 P2.5 P2.7)?"); |
whismanoid | 0:3edb3708c8c5 | 3296 | bool SelfTest_has_max541 = false; |
whismanoid | 0:3edb3708c8c5 | 3297 | // Check actual MAX541 reference voltage |
whismanoid | 0:3edb3708c8c5 | 3298 | cmdLine.serial().printf("\r\n Test Fixture: MAX541 midscale voltage measure with MAX32625MBED AIN0/4"); |
whismanoid | 0:3edb3708c8c5 | 3299 | max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale |
whismanoid | 5:82037e281451 | 3300 | tinyTester.Wait_Output_Settling(); // wait for MAX541 to settle |
whismanoid | 5:82037e281451 | 3301 | // |
whismanoid | 0:3edb3708c8c5 | 3302 | 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 | 3303 | const int average_count = 100; |
whismanoid | 0:3edb3708c8c5 | 3304 | const double average_K = 0.25; |
whismanoid | 0:3edb3708c8c5 | 3305 | for (int count = 0; count < average_count; count++) { |
whismanoid | 0:3edb3708c8c5 | 3306 | double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 3307 | max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V); |
whismanoid | 0:3edb3708c8c5 | 3308 | } |
whismanoid | 0:3edb3708c8c5 | 3309 | if (max541_midscale_V > 1.0f) { |
whismanoid | 0:3edb3708c8c5 | 3310 | max541.VRef = 2.0 * max541_midscale_V; |
whismanoid | 0:3edb3708c8c5 | 3311 | cmdLine.serial().printf("\r\n Test Fixture: MAX541 midscale = %1.3fV, so fullscale = %1.3fV", |
whismanoid | 0:3edb3708c8c5 | 3312 | max541_midscale_V, max541.VRef); |
whismanoid | 0:3edb3708c8c5 | 3313 | // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4 |
whismanoid | 0:3edb3708c8c5 | 3314 | voltageV = 1.0f; |
whismanoid | 0:3edb3708c8c5 | 3315 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3316 | } |
whismanoid | 0:3edb3708c8c5 | 3317 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 3318 | voltageV = 0.0f; |
whismanoid | 0:3edb3708c8c5 | 3319 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3320 | } |
whismanoid | 0:3edb3708c8c5 | 3321 | if (SelfTest_has_max541) { |
whismanoid | 5:82037e281451 | 3322 | voltageV = 2.7f; |
whismanoid | 0:3edb3708c8c5 | 3323 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3324 | } |
whismanoid | 0:3edb3708c8c5 | 3325 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 3326 | voltageV = 1.65f; |
whismanoid | 0:3edb3708c8c5 | 3327 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3328 | } |
whismanoid | 0:3edb3708c8c5 | 3329 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 3330 | voltageV = 2.0f; |
whismanoid | 0:3edb3708c8c5 | 3331 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3332 | } |
whismanoid | 0:3edb3708c8c5 | 3333 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 3334 | voltageV = 0.25f; |
whismanoid | 0:3edb3708c8c5 | 3335 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3336 | } |
whismanoid | 0:3edb3708c8c5 | 3337 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 3338 | voltageV = 0.5f; |
whismanoid | 0:3edb3708c8c5 | 3339 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3340 | } |
whismanoid | 0:3edb3708c8c5 | 3341 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 3342 | voltageV = 1.0f; |
whismanoid | 0:3edb3708c8c5 | 3343 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3344 | } |
whismanoid | 0:3edb3708c8c5 | 3345 | if (SelfTest_has_max541 == false) { |
whismanoid | 0:3edb3708c8c5 | 3346 | // don't fail just because we're missing the test fixture... |
whismanoid | 0:3edb3708c8c5 | 3347 | cmdLine.serial().printf("\r\n Test Fixture: MAX541 not present"); |
whismanoid | 0:3edb3708c8c5 | 3348 | //~ g_SelfTest_nFail--; |
whismanoid | 0:3edb3708c8c5 | 3349 | } |
whismanoid | 0:3edb3708c8c5 | 3350 | // |
whismanoid | 0:3edb3708c8c5 | 3351 | // TODO1: MAX11131 SelfTest: if Test Fixture: drive MAX541, compare MAX32625MBED.AIN0/AIN4 and MAX11131 AIN0 |
whismanoid | 0:3edb3708c8c5 | 3352 | // indirectly verify the reference voltage by reading a known input voltage |
whismanoid | 0:3edb3708c8c5 | 3353 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 3354 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3355 | cmdLine.serial().printf("\r\n 2.1: TODO1: Check MAX11131 reference voltage using SCAN_0001_Manual"); |
whismanoid | 0:3edb3708c8c5 | 3356 | voltageV = 1.0f; |
whismanoid | 0:3edb3708c8c5 | 3357 | SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3358 | cmdLine.serial().printf("\r\n MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 3359 | g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 3360 | // 1 ScanManual ch=0 pm=0 id=1 |
whismanoid | 0:3edb3708c8c5 | 3361 | g_MAX11131_device.channelNumber_0_15 = 0; |
whismanoid | 0:3edb3708c8c5 | 3362 | g_MAX11131_device.PowerManagement_0_2 = 0; |
whismanoid | 0:3edb3708c8c5 | 3363 | g_MAX11131_device.chan_id_0_1 = 1; |
whismanoid | 0:3edb3708c8c5 | 3364 | cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15); |
whismanoid | 0:3edb3708c8c5 | 3365 | cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2); |
whismanoid | 0:3edb3708c8c5 | 3366 | cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 3367 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); |
whismanoid | 0:3edb3708c8c5 | 3368 | cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d", |
whismanoid | 0:3edb3708c8c5 | 3369 | g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 3370 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); |
whismanoid | 0:3edb3708c8c5 | 3371 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 3372 | cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); |
whismanoid | 0:3edb3708c8c5 | 3373 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 3374 | // |
whismanoid | 0:3edb3708c8c5 | 3375 | // 2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here? |
whismanoid | 0:3edb3708c8c5 | 3376 | // |
whismanoid | 0:3edb3708c8c5 | 3377 | cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d", |
whismanoid | 0:3edb3708c8c5 | 3378 | g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 3379 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 3380 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 3381 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 3382 | cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); |
whismanoid | 0:3edb3708c8c5 | 3383 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 3384 | // |
whismanoid | 0:3edb3708c8c5 | 3385 | // 2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here? |
whismanoid | 0:3edb3708c8c5 | 3386 | // |
whismanoid | 0:3edb3708c8c5 | 3387 | // compare with mbed/Arduino AIN0-AIN3 |
whismanoid | 0:3edb3708c8c5 | 3388 | // MAX32625MBED.AIN4 = MAX11131.AIN0 |
whismanoid | 0:3edb3708c8c5 | 3389 | channelId = 0; |
whismanoid | 0:3edb3708c8c5 | 3390 | value_u12 = g_MAX11131_device.AINcode[channelId]; |
whismanoid | 0:3edb3708c8c5 | 3391 | voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); |
whismanoid | 3:8913cb4a8b9f | 3392 | // |
whismanoid | 5:82037e281451 | 3393 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 3:8913cb4a8b9f | 3394 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3395 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 3:8913cb4a8b9f | 3396 | tinyTester.err_threshold = 0.100; |
whismanoid | 3:8913cb4a8b9f | 3397 | tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); |
whismanoid | 3:8913cb4a8b9f | 3398 | // |
whismanoid | 0:3edb3708c8c5 | 3399 | } |
whismanoid | 0:3edb3708c8c5 | 3400 | // |
whismanoid | 0:3edb3708c8c5 | 3401 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 3402 | voltageV = 1.0f; |
whismanoid | 0:3edb3708c8c5 | 3403 | SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3404 | } |
whismanoid | 0:3edb3708c8c5 | 3405 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3406 | cmdLine.serial().printf("\r\n 3.1: Test SCAN_0001_Manual"); |
whismanoid | 0:3edb3708c8c5 | 3407 | cmdLine.serial().printf("\r\n MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 3408 | g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 3409 | // 1 ScanManual ch=0 pm=0 id=1 |
whismanoid | 0:3edb3708c8c5 | 3410 | g_MAX11131_device.channelNumber_0_15 = 0; |
whismanoid | 0:3edb3708c8c5 | 3411 | g_MAX11131_device.PowerManagement_0_2 = 0; |
whismanoid | 0:3edb3708c8c5 | 3412 | g_MAX11131_device.chan_id_0_1 = 1; |
whismanoid | 0:3edb3708c8c5 | 3413 | cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15); |
whismanoid | 0:3edb3708c8c5 | 3414 | cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2); |
whismanoid | 0:3edb3708c8c5 | 3415 | cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 3416 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); |
whismanoid | 0:3edb3708c8c5 | 3417 | cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d", |
whismanoid | 0:3edb3708c8c5 | 3418 | g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 3419 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 3420 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 3421 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 3422 | cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); |
whismanoid | 0:3edb3708c8c5 | 3423 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 3424 | // compare with mbed/Arduino AIN0-AIN3 |
whismanoid | 0:3edb3708c8c5 | 3425 | // MAX32625MBED.AIN4 = MAX11131.AIN0 |
whismanoid | 0:3edb3708c8c5 | 3426 | channelId = 0; |
whismanoid | 0:3edb3708c8c5 | 3427 | value_u12 = g_MAX11131_device.AINcode[channelId]; |
whismanoid | 0:3edb3708c8c5 | 3428 | voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); |
whismanoid | 3:8913cb4a8b9f | 3429 | // |
whismanoid | 5:82037e281451 | 3430 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 3:8913cb4a8b9f | 3431 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3432 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 3:8913cb4a8b9f | 3433 | tinyTester.err_threshold = 0.100; |
whismanoid | 3:8913cb4a8b9f | 3434 | tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); |
whismanoid | 3:8913cb4a8b9f | 3435 | // |
whismanoid | 0:3edb3708c8c5 | 3436 | // |
whismanoid | 0:3edb3708c8c5 | 3437 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3438 | cmdLine.serial().printf("\r\n 3.4: Test SCAN_0100_StandardExternalClock"); |
whismanoid | 0:3edb3708c8c5 | 3439 | cmdLine.serial().printf("\r\n MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 3440 | g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 3441 | // MAX11131 > 4 |
whismanoid | 0:3edb3708c8c5 | 3442 | // ScanStandardExternalClock ch=9 pm=0 id=1 |
whismanoid | 0:3edb3708c8c5 | 3443 | // ScanRead_nWords_chanID nWords=10 |
whismanoid | 0:3edb3708c8c5 | 3444 | // ch=0 xu=2964 = 0x0b94 = 1.8091V |
whismanoid | 0:3edb3708c8c5 | 3445 | // ch=1 xu=2227 = 0x08b3 = 1.3593V |
whismanoid | 0:3edb3708c8c5 | 3446 | // ch=2 xu=1570 = 0x0622 = 0.9583V |
whismanoid | 0:3edb3708c8c5 | 3447 | // ch=3 xu=865 = 0x0361 = 0.5280V |
whismanoid | 0:3edb3708c8c5 | 3448 | // ch=4 xu=630 = 0x0276 = 0.3845V |
whismanoid | 0:3edb3708c8c5 | 3449 | // ch=5 xu=594 = 0x0252 = 0.3625V |
whismanoid | 0:3edb3708c8c5 | 3450 | // ch=6 xu=461 = 0x01cd = 0.2814V |
whismanoid | 0:3edb3708c8c5 | 3451 | // ch=7 xu=364 = 0x016c = 0.2222V |
whismanoid | 0:3edb3708c8c5 | 3452 | // ch=8 xu=480 = 0x01e0 = 0.2930V |
whismanoid | 0:3edb3708c8c5 | 3453 | // ch=9 xu=616 = 0x0268 = 0.3760V |
whismanoid | 0:3edb3708c8c5 | 3454 | g_MAX11131_device.channelNumber_0_15 = 9; |
whismanoid | 0:3edb3708c8c5 | 3455 | g_MAX11131_device.PowerManagement_0_2 = 0; |
whismanoid | 0:3edb3708c8c5 | 3456 | g_MAX11131_device.chan_id_0_1 = 1; |
whismanoid | 0:3edb3708c8c5 | 3457 | cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15); |
whismanoid | 0:3edb3708c8c5 | 3458 | cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2); |
whismanoid | 0:3edb3708c8c5 | 3459 | cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 3460 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 3461 | cmdLine.serial().printf("\r\n MAX11131.ScanStandardExternalClock -- NumWords = %d", |
whismanoid | 0:3edb3708c8c5 | 3462 | g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 3463 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 3464 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 3465 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 3466 | cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); |
whismanoid | 0:3edb3708c8c5 | 3467 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 3468 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 5:82037e281451 | 3469 | // expect g_MAX11131_device.NumWords == g_MAX11131_device.channelNumber_0_15 + 1; |
whismanoid | 5:82037e281451 | 3470 | // expect RAW_misoData16[index] msnybble 0,1,2,3,... |
whismanoid | 0:3edb3708c8c5 | 3471 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 5:82037e281451 | 3472 | // compare with mbed/Arduino AIN0-AIN3 |
whismanoid | 0:3edb3708c8c5 | 3473 | // MAX32625MBED.AIN4 = MAX11131.AIN0 |
whismanoid | 0:3edb3708c8c5 | 3474 | channelId = 0; |
whismanoid | 0:3edb3708c8c5 | 3475 | value_u12 = g_MAX11131_device.AINcode[channelId]; |
whismanoid | 0:3edb3708c8c5 | 3476 | voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); |
whismanoid | 5:82037e281451 | 3477 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 3:8913cb4a8b9f | 3478 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3479 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 3:8913cb4a8b9f | 3480 | tinyTester.err_threshold = 0.100; |
whismanoid | 3:8913cb4a8b9f | 3481 | tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); |
whismanoid | 5:82037e281451 | 3482 | // compare MAX32625MBED.AIN5 = MAX11131.AIN1 |
whismanoid | 0:3edb3708c8c5 | 3483 | //channelId = 1; |
whismanoid | 0:3edb3708c8c5 | 3484 | //value_u12 = g_MAX11131_device.AINcode[channelId]; |
whismanoid | 0:3edb3708c8c5 | 3485 | //voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 3486 | //SelfTest_AnalogInput_Expect_ch_V(cmdLine, 5, voltageV, 0.100); |
whismanoid | 0:3edb3708c8c5 | 3487 | // |
whismanoid | 0:3edb3708c8c5 | 3488 | #elif APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 3489 | |
whismanoid | 5:82037e281451 | 3490 | // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 3491 | // |
whismanoid | 1:40369075c365 | 3492 | // Note: ide.mbed.com does not support C++11 Lambda Expressions |
whismanoid | 1:40369075c365 | 3493 | // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ |
whismanoid | 0:3edb3708c8c5 | 3494 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 3495 | // uint8_t MAX5171::Init(void) |
whismanoid | 2:b3a8a0ca0a94 | 3496 | //uint8_t (*fn_MAX5171_Init)() = [](){ return g_MAX5171_device.Init(); }; |
whismanoid | 0:3edb3708c8c5 | 3497 | // |
whismanoid | 0:3edb3708c8c5 | 3498 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 3499 | // uint16_t MAX5171::DACCodeOfVoltage(double voltageV) |
whismanoid | 2:b3a8a0ca0a94 | 3500 | //uint16_t (*fn_MAX5171_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5171_device.DACCodeOfVoltage(voltageV); }; |
whismanoid | 0:3edb3708c8c5 | 3501 | // |
whismanoid | 0:3edb3708c8c5 | 3502 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 3503 | // double MAX5171::VoltageOfCode(uint16_t value_u14) |
whismanoid | 2:b3a8a0ca0a94 | 3504 | //double (*fn_MAX5171_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5171_device.VoltageOfCode(value_u14); }; |
whismanoid | 0:3edb3708c8c5 | 3505 | // |
whismanoid | 0:3edb3708c8c5 | 3506 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 3507 | // uint8_t MAX5171::CODE_LOAD(uint16_t dacCodeLsbs) |
whismanoid | 2:b3a8a0ca0a94 | 3508 | //uint8_t (*fn_MAX5171_CODE_LOAD)(uint16_t dacCodeLsbs) = [](uint16_t dacCodeLsbs){ return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); }; |
whismanoid | 0:3edb3708c8c5 | 3509 | // |
whismanoid | 0:3edb3708c8c5 | 3510 | //double one_LSB = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS |
whismanoid | 5:82037e281451 | 3511 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3512 | tinyTester.settle_time_msec = 250; |
whismanoid | 0:3edb3708c8c5 | 3513 | |
whismanoid | 0:3edb3708c8c5 | 3514 | g_MAX5171_device.VRef = 2.500; // MAX5171 14-bit LSB = 0.00015V |
whismanoid | 0:3edb3708c8c5 | 3515 | SelfTest_print_Vref(cmdLine); |
whismanoid | 8:6bdfb1376fed | 3516 | tinyTester.err_threshold = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS |
whismanoid | 0:3edb3708c8c5 | 3517 | // |
whismanoid | 5:82037e281451 | 3518 | // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 9:9b4232e20020 | 3519 | tinyTester.blink_time_msec = 20; // quickly speed through the software verification |
whismanoid | 0:3edb3708c8c5 | 3520 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.499847412109375, 0x3FFF); |
whismanoid | 0:3edb3708c8c5 | 3521 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.49969482421875, 0x3FFE); |
whismanoid | 0:3edb3708c8c5 | 3522 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.499542236328125, 0x3FFD); |
whismanoid | 0:3edb3708c8c5 | 3523 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.4993896484375, 0x3FFC); |
whismanoid | 0:3edb3708c8c5 | 3524 | // |
whismanoid | 0:3edb3708c8c5 | 3525 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.250152587890625, 0x2001); |
whismanoid | 0:3edb3708c8c5 | 3526 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.25, 0x2000); |
whismanoid | 0:3edb3708c8c5 | 3527 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.249847412109375, 0x1FFF); |
whismanoid | 0:3edb3708c8c5 | 3528 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.24969482421875, 0x1FFE); |
whismanoid | 0:3edb3708c8c5 | 3529 | // |
whismanoid | 0:3edb3708c8c5 | 3530 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.000457763671875, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 3531 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.00030517578125, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 3532 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.000152587890625, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 3533 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.00000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 3534 | // |
whismanoid | 5:82037e281451 | 3535 | // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect |
whismanoid | 0:3edb3708c8c5 | 3536 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFF, 2.499847412109375); |
whismanoid | 0:3edb3708c8c5 | 3537 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFE, 2.49969482421875); |
whismanoid | 0:3edb3708c8c5 | 3538 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFD, 2.499542236328125); |
whismanoid | 0:3edb3708c8c5 | 3539 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFC, 2.4993896484375); |
whismanoid | 0:3edb3708c8c5 | 3540 | // |
whismanoid | 0:3edb3708c8c5 | 3541 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x2001, 1.250152587890625); |
whismanoid | 0:3edb3708c8c5 | 3542 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x2000, 1.25); |
whismanoid | 0:3edb3708c8c5 | 3543 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x1FFF, 1.249847412109375); |
whismanoid | 0:3edb3708c8c5 | 3544 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x1FFE, 1.24969482421875); |
whismanoid | 0:3edb3708c8c5 | 3545 | // |
whismanoid | 0:3edb3708c8c5 | 3546 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0003, 0.000457763671875); |
whismanoid | 0:3edb3708c8c5 | 3547 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0002, 0.00030517578125); |
whismanoid | 0:3edb3708c8c5 | 3548 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0001, 0.000152587890625); |
whismanoid | 0:3edb3708c8c5 | 3549 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0000, 0.00000); |
whismanoid | 0:3edb3708c8c5 | 3550 | // |
whismanoid | 0:3edb3708c8c5 | 3551 | // Device Testing: DAC commands, verify using on-board ADC inputs |
whismanoid | 0:3edb3708c8c5 | 3552 | // |
whismanoid | 9:9b4232e20020 | 3553 | tinyTester.blink_time_msec = 75; |
whismanoid | 0:3edb3708c8c5 | 3554 | cmdLine.serial().printf("\r\n MAX5171.Init()"); |
whismanoid | 0:3edb3708c8c5 | 3555 | g_MAX5171_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 3556 | // |
whismanoid | 0:3edb3708c8c5 | 3557 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 3558 | uint16_t code = 0x3FFF; |
whismanoid | 0:3edb3708c8c5 | 3559 | //~ double voltageV = 0.5; |
whismanoid | 0:3edb3708c8c5 | 3560 | // |
whismanoid | 0:3edb3708c8c5 | 3561 | cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 3562 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 5:82037e281451 | 3563 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3564 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3565 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3566 | tinyTester.AnalogIn0_Read_Expect_voltageV(2.500); |
whismanoid | 0:3edb3708c8c5 | 3567 | // |
whismanoid | 0:3edb3708c8c5 | 3568 | code = 0x0000; |
whismanoid | 0:3edb3708c8c5 | 3569 | cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 3570 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 5:82037e281451 | 3571 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3572 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3573 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3574 | tinyTester.AnalogIn0_Read_Expect_voltageV(0.0000); |
whismanoid | 0:3edb3708c8c5 | 3575 | // |
whismanoid | 0:3edb3708c8c5 | 3576 | code = 0x1FFF; |
whismanoid | 0:3edb3708c8c5 | 3577 | cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 3578 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 5:82037e281451 | 3579 | // tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 3580 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3581 | // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3582 | tinyTester.AnalogIn0_Read_Expect_voltageV(1.2500); |
whismanoid | 0:3edb3708c8c5 | 3583 | // |
whismanoid | 0:3edb3708c8c5 | 3584 | // test UPO User Programmable Output, verify using digital input D2 |
whismanoid | 0:3edb3708c8c5 | 3585 | // |
whismanoid | 0:3edb3708c8c5 | 3586 | cmdLine.serial().printf("\r\n MAX5171.UPO_HIGH"); |
whismanoid | 0:3edb3708c8c5 | 3587 | g_MAX5171_device.UPO_HIGH(); |
whismanoid | 0:3edb3708c8c5 | 3588 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3589 | // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin |
whismanoid | 0:3edb3708c8c5 | 3590 | tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command"); |
whismanoid | 0:3edb3708c8c5 | 3591 | // |
whismanoid | 0:3edb3708c8c5 | 3592 | cmdLine.serial().printf("\r\n MAX5171.UPO_LOW"); |
whismanoid | 0:3edb3708c8c5 | 3593 | g_MAX5171_device.UPO_LOW(); |
whismanoid | 0:3edb3708c8c5 | 3594 | tinyTester.Wait_Output_Settling(); |
whismanoid | 5:82037e281451 | 3595 | // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin |
whismanoid | 0:3edb3708c8c5 | 3596 | tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 0, "UPO_pin is low after MAX5171 UPO_LOW command"); |
whismanoid | 0:3edb3708c8c5 | 3597 | // |
whismanoid | 0:3edb3708c8c5 | 3598 | cmdLine.serial().printf("\r\n MAX5171.UPO_HIGH"); |
whismanoid | 0:3edb3708c8c5 | 3599 | g_MAX5171_device.UPO_HIGH(); |
whismanoid | 0:3edb3708c8c5 | 3600 | tinyTester.Wait_Output_Settling(); // wait_ms(100); // delay |
whismanoid | 5:82037e281451 | 3601 | // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin |
whismanoid | 0:3edb3708c8c5 | 3602 | tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command"); |
whismanoid | 0:3edb3708c8c5 | 3603 | // |
whismanoid | 0:3edb3708c8c5 | 3604 | #elif APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 3605 | // |
whismanoid | 0:3edb3708c8c5 | 3606 | // TODO: placeholder for self-test functions |
whismanoid | 0:3edb3708c8c5 | 3607 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3608 | cmdLine.serial().printf("test program not implemented yet"); |
whismanoid | 0:3edb3708c8c5 | 3609 | // |
whismanoid | 0:3edb3708c8c5 | 3610 | #elif APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 3611 | // |
whismanoid | 0:3edb3708c8c5 | 3612 | // TODO: placeholder for self-test functions |
whismanoid | 0:3edb3708c8c5 | 3613 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3614 | cmdLine.serial().printf("test program not implemented yet"); |
whismanoid | 0:3edb3708c8c5 | 3615 | // |
whismanoid | 0:3edb3708c8c5 | 3616 | #else // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 3617 | // TODO: placeholder for self-test functions |
whismanoid | 0:3edb3708c8c5 | 3618 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 3619 | // |
whismanoid | 8:6bdfb1376fed | 3620 | #if INJECT_SELFTEST_FAIL |
whismanoid | 0:3edb3708c8c5 | 3621 | // Test of the pass/fail report mechanism |
whismanoid | 0:3edb3708c8c5 | 3622 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3623 | cmdLine.serial().printf("injecting one false failure for test reporting"); |
whismanoid | 0:3edb3708c8c5 | 3624 | #endif |
whismanoid | 0:3edb3708c8c5 | 3625 | // |
whismanoid | 0:3edb3708c8c5 | 3626 | // Report number of pass and number of fail test results |
whismanoid | 0:3edb3708c8c5 | 3627 | tinyTester.Report_Summary(); |
whismanoid | 0:3edb3708c8c5 | 3628 | } |
whismanoid | 0:3edb3708c8c5 | 3629 | |
whismanoid | 0:3edb3708c8c5 | 3630 | |
whismanoid | 0:3edb3708c8c5 | 3631 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3632 | void main_menu_status(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 3633 | { |
whismanoid | 0:3edb3708c8c5 | 3634 | cmdLine.serial().printf("\r\nMain menu"); |
whismanoid | 0:3edb3708c8c5 | 3635 | #if APPLICATION_MAX5715 // main_menu_status banner |
whismanoid | 0:3edb3708c8c5 | 3636 | cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC"); |
whismanoid | 0:3edb3708c8c5 | 3637 | #elif APPLICATION_MAX11131 // main_menu_status banner |
whismanoid | 0:3edb3708c8c5 | 3638 | cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC"); |
whismanoid | 0:3edb3708c8c5 | 3639 | #elif APPLICATION_MAX5171 // main_menu_status banner |
whismanoid | 0:3edb3708c8c5 | 3640 | cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC"); |
whismanoid | 0:3edb3708c8c5 | 3641 | #elif APPLICATION_MAX11410 // main_menu_status banner |
whismanoid | 0:3edb3708c8c5 | 3642 | cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC"); |
whismanoid | 0:3edb3708c8c5 | 3643 | #elif APPLICATION_MAX12345 // main_menu_status banner |
whismanoid | 0:3edb3708c8c5 | 3644 | cmdLine.serial().printf(" MAX12345"); |
whismanoid | 0:3edb3708c8c5 | 3645 | #else |
whismanoid | 0:3edb3708c8c5 | 3646 | //cmdLine.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 3647 | #endif |
whismanoid | 0:3edb3708c8c5 | 3648 | cmdLine.serial().printf(" %s", TARGET_NAME); |
whismanoid | 0:3edb3708c8c5 | 3649 | if (cmdLine.nameStr()) |
whismanoid | 0:3edb3708c8c5 | 3650 | { |
whismanoid | 0:3edb3708c8c5 | 3651 | cmdLine.serial().printf(" [%s]", cmdLine.nameStr()); |
whismanoid | 0:3edb3708c8c5 | 3652 | } |
whismanoid | 0:3edb3708c8c5 | 3653 | #if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 3654 | cmdLine.serial().printf(" [Button1=DemoConfig1]"); |
whismanoid | 0:3edb3708c8c5 | 3655 | #endif |
whismanoid | 0:3edb3708c8c5 | 3656 | #if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 3657 | cmdLine.serial().printf(" [Button2=DemoConfig2]"); |
whismanoid | 0:3edb3708c8c5 | 3658 | #endif |
whismanoid | 0:3edb3708c8c5 | 3659 | #if HAS_BUTTON1_DEMO |
whismanoid | 0:3edb3708c8c5 | 3660 | // print BUTTON1 status |
whismanoid | 0:3edb3708c8c5 | 3661 | cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read()); |
whismanoid | 0:3edb3708c8c5 | 3662 | #endif |
whismanoid | 0:3edb3708c8c5 | 3663 | #if HAS_BUTTON2_DEMO |
whismanoid | 0:3edb3708c8c5 | 3664 | // print BUTTON1 status |
whismanoid | 0:3edb3708c8c5 | 3665 | cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read()); |
whismanoid | 0:3edb3708c8c5 | 3666 | #endif |
whismanoid | 0:3edb3708c8c5 | 3667 | cmdLine.serial().printf("\r\n ? -- help"); |
whismanoid | 0:3edb3708c8c5 | 3668 | } |
whismanoid | 0:3edb3708c8c5 | 3669 | |
whismanoid | 0:3edb3708c8c5 | 3670 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3671 | void main_menu_help(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 3672 | { |
whismanoid | 0:3edb3708c8c5 | 3673 | // ? -- help |
whismanoid | 0:3edb3708c8c5 | 3674 | //~ cmdLine.serial().printf("\r\nMenu:"); |
whismanoid | 0:3edb3708c8c5 | 3675 | cmdLine.serial().printf("\r\n # -- lines beginning with # are comments"); |
whismanoid | 0:3edb3708c8c5 | 3676 | cmdLine.serial().printf("\r\n . -- SelfTest"); |
whismanoid | 0:3edb3708c8c5 | 3677 | //cmdLine.serial().printf("\r\n ! -- Initial Configuration"); |
whismanoid | 0:3edb3708c8c5 | 3678 | // |
whismanoid | 0:3edb3708c8c5 | 3679 | // % standardize diagnostic commands |
whismanoid | 0:3edb3708c8c5 | 3680 | // %Hpin -- digital output high |
whismanoid | 0:3edb3708c8c5 | 3681 | // %Lpin -- digital output low |
whismanoid | 0:3edb3708c8c5 | 3682 | // %?pin -- digital input |
whismanoid | 0:3edb3708c8c5 | 3683 | // %A %Apin -- analog input |
whismanoid | 0:3edb3708c8c5 | 3684 | // %Ppin df=xx -- pwm output |
whismanoid | 0:3edb3708c8c5 | 3685 | // %Wpin -- measure high pulsewidth input in usec |
whismanoid | 0:3edb3708c8c5 | 3686 | // %wpin -- measure low pulsewidth input in usec |
whismanoid | 0:3edb3708c8c5 | 3687 | // %I... -- I2C diagnostics |
whismanoid | 0:3edb3708c8c5 | 3688 | // %IP -- I2C probe |
whismanoid | 0:3edb3708c8c5 | 3689 | // %IC scl=100khz ADDR=? -- I2C configure |
whismanoid | 0:3edb3708c8c5 | 3690 | // %IW ADDR=? cmd=? data,data,data -- write |
whismanoid | 0:3edb3708c8c5 | 3691 | // %IR ADDR=? RD=? -- read |
whismanoid | 0:3edb3708c8c5 | 3692 | // %I^ cmd=? -- i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 3693 | // %S... -- SPI diagnostics |
whismanoid | 0:3edb3708c8c5 | 3694 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 0:3edb3708c8c5 | 3695 | // %SW -- write (write and read) |
whismanoid | 0:3edb3708c8c5 | 3696 | // %SR -- read (alias for %SW because SPI always write and read) |
whismanoid | 0:3edb3708c8c5 | 3697 | // A-Z,a-z,0-9 reserved for application use |
whismanoid | 0:3edb3708c8c5 | 3698 | // |
whismanoid | 0:3edb3708c8c5 | 3699 | #if HAS_digitalInOuts |
whismanoid | 0:3edb3708c8c5 | 3700 | // %Hpin -- digital output high |
whismanoid | 0:3edb3708c8c5 | 3701 | // %Lpin -- digital output low |
whismanoid | 0:3edb3708c8c5 | 3702 | // %?pin -- digital input |
whismanoid | 0:3edb3708c8c5 | 3703 | cmdLine.serial().printf("\r\n %%Hn {pin:"); |
whismanoid | 0:3edb3708c8c5 | 3704 | list_digitalInOutPins(cmdLine.serial()); |
whismanoid | 0:3edb3708c8c5 | 3705 | cmdLine.serial().printf("} -- High Output"); |
whismanoid | 0:3edb3708c8c5 | 3706 | cmdLine.serial().printf("\r\n %%Ln {pin:"); |
whismanoid | 0:3edb3708c8c5 | 3707 | list_digitalInOutPins(cmdLine.serial()); |
whismanoid | 0:3edb3708c8c5 | 3708 | cmdLine.serial().printf("} -- Low Output"); |
whismanoid | 0:3edb3708c8c5 | 3709 | cmdLine.serial().printf("\r\n %%?n {pin:"); |
whismanoid | 0:3edb3708c8c5 | 3710 | list_digitalInOutPins(cmdLine.serial()); |
whismanoid | 0:3edb3708c8c5 | 3711 | cmdLine.serial().printf("} -- Input"); |
whismanoid | 0:3edb3708c8c5 | 3712 | #endif |
whismanoid | 0:3edb3708c8c5 | 3713 | |
whismanoid | 0:3edb3708c8c5 | 3714 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 3715 | // Menu A) analogRead A0..7 |
whismanoid | 0:3edb3708c8c5 | 3716 | // %A %Apin -- analog input |
whismanoid | 0:3edb3708c8c5 | 3717 | // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0) |
whismanoid | 0:3edb3708c8c5 | 3718 | cmdLine.serial().printf("\r\n %%A -- analogRead"); |
whismanoid | 0:3edb3708c8c5 | 3719 | #endif |
whismanoid | 0:3edb3708c8c5 | 3720 | |
whismanoid | 0:3edb3708c8c5 | 3721 | #if HAS_SPI2_MAX541 |
whismanoid | 0:3edb3708c8c5 | 3722 | // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs); |
whismanoid | 0:3edb3708c8c5 | 3723 | cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)"); |
whismanoid | 0:3edb3708c8c5 | 3724 | #endif |
whismanoid | 0:3edb3708c8c5 | 3725 | |
whismanoid | 0:3edb3708c8c5 | 3726 | #if HAS_I2C // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 3727 | // TODO: support I2C HAS_I2C // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 3728 | // VERIFY: I2C utility commands SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 3729 | // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 3730 | // %I... -- I2C diagnostics |
whismanoid | 0:3edb3708c8c5 | 3731 | // %IP -- I2C probe |
whismanoid | 0:3edb3708c8c5 | 3732 | // %IC scl=100khz ADDR=? -- I2C configure |
whismanoid | 0:3edb3708c8c5 | 3733 | // %IW byte byte ... byte RD=? ADDR=0x -- write |
whismanoid | 0:3edb3708c8c5 | 3734 | // %IR ADDR=? RD=? -- read |
whismanoid | 0:3edb3708c8c5 | 3735 | // %I^ cmd=? -- i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 3736 | //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope |
whismanoid | 0:3edb3708c8c5 | 3737 | cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config", |
whismanoid | 0:3edb3708c8c5 | 3738 | g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz, |
whismanoid | 0:3edb3708c8c5 | 3739 | (g_I2C_SCL_Hz / 1000.)); |
whismanoid | 0:3edb3708c8c5 | 3740 | cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read", |
whismanoid | 0:3edb3708c8c5 | 3741 | g_I2C_deviceAddress7); |
whismanoid | 0:3edb3708c8c5 | 3742 | // |
whismanoid | 0:3edb3708c8c5 | 3743 | #if SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 3744 | // Menu ^ cmd=?) i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 3745 | cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data"); |
whismanoid | 0:3edb3708c8c5 | 3746 | // test low-level I2C i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 3747 | #endif // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 3748 | //cmdLine.serial().printf(" H) Hunt for attached I2C devices"); |
whismanoid | 0:3edb3708c8c5 | 3749 | cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices"); |
whismanoid | 0:3edb3708c8c5 | 3750 | // cmdLine.serial().printf(" s) search i2c address"); |
whismanoid | 0:3edb3708c8c5 | 3751 | #endif // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 3752 | |
whismanoid | 0:3edb3708c8c5 | 3753 | #if HAS_SPI // SUPPORT_SPI |
whismanoid | 0:3edb3708c8c5 | 3754 | // TODO: support SPI HAS_SPI // SUPPORT_SPI |
whismanoid | 0:3edb3708c8c5 | 3755 | // SPI test command S (mosiData)+ |
whismanoid | 0:3edb3708c8c5 | 3756 | // %S... -- SPI diagnostics |
whismanoid | 0:3edb3708c8c5 | 3757 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 0:3edb3708c8c5 | 3758 | // %SW -- write (write and read) |
whismanoid | 0:3edb3708c8c5 | 3759 | // %SR -- read (alias for %SW because SPI always write and read) |
whismanoid | 0:3edb3708c8c5 | 3760 | // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 3761 | // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 3762 | // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 3763 | // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 3764 | // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default) |
whismanoid | 0:3edb3708c8c5 | 3765 | // mode | POL PHA |
whismanoid | 0:3edb3708c8c5 | 3766 | // -----+-------- |
whismanoid | 0:3edb3708c8c5 | 3767 | // 0 | 0 0 |
whismanoid | 0:3edb3708c8c5 | 3768 | // 1 | 0 1 |
whismanoid | 0:3edb3708c8c5 | 3769 | // 2 | 1 0 |
whismanoid | 0:3edb3708c8c5 | 3770 | // 3 | 1 1 |
whismanoid | 0:3edb3708c8c5 | 3771 | //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0"); |
whismanoid | 0:3edb3708c8c5 | 3772 | // 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 | 3773 | cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config", |
whismanoid | 0:3edb3708c8c5 | 3774 | g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.), |
whismanoid | 0:3edb3708c8c5 | 3775 | ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0), |
whismanoid | 0:3edb3708c8c5 | 3776 | ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0)); |
whismanoid | 0:3edb3708c8c5 | 3777 | cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes"); |
whismanoid | 0:3edb3708c8c5 | 3778 | // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0 |
whismanoid | 0:3edb3708c8c5 | 3779 | #endif // SUPPORT_SPI |
whismanoid | 0:3edb3708c8c5 | 3780 | // |
whismanoid | 0:3edb3708c8c5 | 3781 | // Application-specific commands (help text) here |
whismanoid | 0:3edb3708c8c5 | 3782 | // |
whismanoid | 0:3edb3708c8c5 | 3783 | #if APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 3784 | # if APPLICATION_MAX5715 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3785 | # elif APPLICATION_MAX11131 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3786 | # elif APPLICATION_MAX5171 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3787 | # elif APPLICATION_MAX11410 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3788 | # elif APPLICATION_MAX12345 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3789 | # else |
whismanoid | 0:3edb3708c8c5 | 3790 | cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 3791 | # endif |
whismanoid | 0:3edb3708c8c5 | 3792 | #endif // APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 3793 | // |
whismanoid | 0:3edb3708c8c5 | 3794 | #if APPLICATION_MAX5715 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3795 | cmdLine.serial().printf("\r\n 0 ch=? code=? -- CODEn"); |
whismanoid | 0:3edb3708c8c5 | 3796 | cmdLine.serial().printf("\r\n 1 ch=? -- LOADn"); |
whismanoid | 0:3edb3708c8c5 | 3797 | cmdLine.serial().printf("\r\n 2 ch=? code=? -- CODEnLOADall"); |
whismanoid | 0:3edb3708c8c5 | 3798 | cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); |
whismanoid | 0:3edb3708c8c5 | 3799 | cmdLine.serial().printf("\r\n 40 ch=? -- POWERn_Normal"); |
whismanoid | 0:3edb3708c8c5 | 3800 | cmdLine.serial().printf("\r\n 41 ch=? -- POWERn_PD1k"); |
whismanoid | 0:3edb3708c8c5 | 3801 | cmdLine.serial().printf("\r\n 42 ch=? -- POWERn_PD100k"); |
whismanoid | 0:3edb3708c8c5 | 3802 | cmdLine.serial().printf("\r\n 43 ch=? -- POWERn_PDHiZ"); |
whismanoid | 0:3edb3708c8c5 | 3803 | cmdLine.serial().printf("\r\n 50 -- SW_CLEAR"); |
whismanoid | 0:3edb3708c8c5 | 3804 | cmdLine.serial().printf("\r\n 51 -- SW_RESET"); |
whismanoid | 0:3edb3708c8c5 | 3805 | cmdLine.serial().printf("\r\n 60 ch=? -- CONFIGn_LATCHED"); |
whismanoid | 0:3edb3708c8c5 | 3806 | cmdLine.serial().printf("\r\n 61 ch=? -- CONFIGn_TRANSPARENT"); |
whismanoid | 0:3edb3708c8c5 | 3807 | cmdLine.serial().printf("\r\n 68 -- CONFIGall_LATCHED"); |
whismanoid | 0:3edb3708c8c5 | 3808 | cmdLine.serial().printf("\r\n 69 -- CONFIGall_TRANSPARENT"); |
whismanoid | 0:3edb3708c8c5 | 3809 | cmdLine.serial().printf("\r\n 70 -- REF_EXT"); |
whismanoid | 0:3edb3708c8c5 | 3810 | cmdLine.serial().printf("\r\n 71 -- REF_2V500"); |
whismanoid | 0:3edb3708c8c5 | 3811 | cmdLine.serial().printf("\r\n 72 -- REF_2V048"); |
whismanoid | 0:3edb3708c8c5 | 3812 | cmdLine.serial().printf("\r\n 73 -- REF_4V096"); |
whismanoid | 0:3edb3708c8c5 | 3813 | cmdLine.serial().printf("\r\n 74 -- REF_AlwaysOn_EXT"); |
whismanoid | 0:3edb3708c8c5 | 3814 | cmdLine.serial().printf("\r\n 75 -- REF_AlwaysOn_2V500"); |
whismanoid | 0:3edb3708c8c5 | 3815 | cmdLine.serial().printf("\r\n 76 -- REF_AlwaysOn_2V048"); |
whismanoid | 0:3edb3708c8c5 | 3816 | cmdLine.serial().printf("\r\n 77 -- REF_AlwaysOn_4V096"); |
whismanoid | 0:3edb3708c8c5 | 3817 | cmdLine.serial().printf("\r\n 80 code=? -- CODEall"); |
whismanoid | 0:3edb3708c8c5 | 3818 | cmdLine.serial().printf("\r\n 81 -- LOADall"); |
whismanoid | 0:3edb3708c8c5 | 3819 | cmdLine.serial().printf("\r\n 82 code=? -- CODEallLOADall"); |
whismanoid | 0:3edb3708c8c5 | 3820 | //cmdLine.serial().printf("\r\n 83 code=? -- CODEallLOADall"); |
whismanoid | 0:3edb3708c8c5 | 3821 | // |
whismanoid | 0:3edb3708c8c5 | 3822 | // Menu @ -- print device configuration |
whismanoid | 0:3edb3708c8c5 | 3823 | cmdLine.serial().printf("\r\n @ -- print MAX5715 configuration"); |
whismanoid | 0:3edb3708c8c5 | 3824 | // |
whismanoid | 0:3edb3708c8c5 | 3825 | // MAX5717 menu function to drive MAX5717_LDACb_Pin LDAC# |
whismanoid | 0:3edb3708c8c5 | 3826 | // Note: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 3827 | cmdLine.serial().printf("\r\n L -- LDAC# pulse LH high LL low"); |
whismanoid | 0:3edb3708c8c5 | 3828 | // MAX5717 menu function to drive MAX5717_CLRb_Pin CLR# |
whismanoid | 0:3edb3708c8c5 | 3829 | cmdLine.serial().printf("\r\n C -- CLR# pulse CH high CL low"); |
whismanoid | 0:3edb3708c8c5 | 3830 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 3831 | // |
whismanoid | 0:3edb3708c8c5 | 3832 | #if APPLICATION_MAX11131 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3833 | // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void); |
whismanoid | 0:3edb3708c8c5 | 3834 | cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead"); |
whismanoid | 0:3edb3708c8c5 | 3835 | // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 3836 | cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual"); |
whismanoid | 0:3edb3708c8c5 | 3837 | // 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 | 3838 | cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat"); |
whismanoid | 0:3edb3708c8c5 | 3839 | // 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 | 3840 | cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock"); |
whismanoid | 0:3edb3708c8c5 | 3841 | // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 3842 | cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock"); |
whismanoid | 0:3edb3708c8c5 | 3843 | // 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 | 3844 | cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock"); |
whismanoid | 0:3edb3708c8c5 | 3845 | // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 3846 | cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock"); |
whismanoid | 0:3edb3708c8c5 | 3847 | // 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 | 3848 | cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock"); |
whismanoid | 0:3edb3708c8c5 | 3849 | // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 3850 | cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock"); |
whismanoid | 0:3edb3708c8c5 | 3851 | // 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 | 3852 | cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock"); |
whismanoid | 0:3edb3708c8c5 | 3853 | cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration"); |
whismanoid | 0:3edb3708c8c5 | 3854 | cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range"); |
whismanoid | 0:3edb3708c8c5 | 3855 | // cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual"); |
whismanoid | 0:3edb3708c8c5 | 3856 | // Note: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 3857 | #endif // APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 3858 | // |
whismanoid | 0:3edb3708c8c5 | 3859 | #if APPLICATION_MAX5171 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3860 | // TODO1: MAX5171 main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3861 | cmdLine.serial().printf("\r\n 0 code=? -- CODE"); |
whismanoid | 0:3edb3708c8c5 | 3862 | cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD"); |
whismanoid | 0:3edb3708c8c5 | 3863 | cmdLine.serial().printf("\r\n 8 -- LOAD"); |
whismanoid | 0:3edb3708c8c5 | 3864 | cmdLine.serial().printf("\r\n c -- NOP"); |
whismanoid | 0:3edb3708c8c5 | 3865 | cmdLine.serial().printf("\r\n d -- SHUTDOWN"); |
whismanoid | 0:3edb3708c8c5 | 3866 | cmdLine.serial().printf("\r\n e0 -- UPO_LOW"); |
whismanoid | 0:3edb3708c8c5 | 3867 | cmdLine.serial().printf("\r\n e8 -- UPO_HIGH"); |
whismanoid | 0:3edb3708c8c5 | 3868 | cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 3869 | cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 3870 | // Note: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 3871 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 3872 | // |
whismanoid | 0:3edb3708c8c5 | 3873 | #if APPLICATION_MAX11410 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3874 | // TODO1: MAX11410 main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3875 | cmdLine.serial().printf("\r\n w reg=? data=? -- write register"); |
whismanoid | 0:3edb3708c8c5 | 3876 | cmdLine.serial().printf("\r\n r reg=? -- read register"); |
whismanoid | 0:3edb3708c8c5 | 3877 | cmdLine.serial().printf("\r\n TC -- thermocouple config"); |
whismanoid | 0:3edb3708c8c5 | 3878 | cmdLine.serial().printf("\r\n T -- RTD measurement"); |
whismanoid | 0:3edb3708c8c5 | 3879 | cmdLine.serial().printf("\r\n RC -- thermocouple config"); |
whismanoid | 0:3edb3708c8c5 | 3880 | cmdLine.serial().printf("\r\n R -- RTD measurement"); |
whismanoid | 0:3edb3708c8c5 | 3881 | // Note: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 3882 | #endif // APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 3883 | // |
whismanoid | 0:3edb3708c8c5 | 3884 | #if APPLICATION_MAX12345 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 3885 | cmdLine.serial().printf("\r\n 0 -- something"); |
whismanoid | 0:3edb3708c8c5 | 3886 | cmdLine.serial().printf("\r\n 1 -- something"); |
whismanoid | 0:3edb3708c8c5 | 3887 | cmdLine.serial().printf("\r\n 2 -- something"); |
whismanoid | 0:3edb3708c8c5 | 3888 | cmdLine.serial().printf("\r\n A -- something"); |
whismanoid | 0:3edb3708c8c5 | 3889 | cmdLine.serial().printf("\r\n B -- something"); |
whismanoid | 0:3edb3708c8c5 | 3890 | cmdLine.serial().printf("\r\n C -- something"); |
whismanoid | 0:3edb3708c8c5 | 3891 | // Note: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 3892 | #endif // APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 3893 | // |
whismanoid | 0:3edb3708c8c5 | 3894 | } |
whismanoid | 0:3edb3708c8c5 | 3895 | |
whismanoid | 0:3edb3708c8c5 | 3896 | //-------------------------------------------------- |
whismanoid | 10:228a52f8107d | 3897 | // diagnostic commands submenu |
whismanoid | 10:228a52f8107d | 3898 | // invoked by main_menu_onEOLcommandParser case '%' |
whismanoid | 10:228a52f8107d | 3899 | void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 3900 | { |
whismanoid | 10:228a52f8107d | 3901 | // % diagnostic commands submenu |
whismanoid | 10:228a52f8107d | 3902 | // %Hpin -- digital output high |
whismanoid | 10:228a52f8107d | 3903 | // %Lpin -- digital output low |
whismanoid | 10:228a52f8107d | 3904 | // %?pin -- digital input |
whismanoid | 10:228a52f8107d | 3905 | // %A %Apin -- analog input |
whismanoid | 10:228a52f8107d | 3906 | // %Ppin df=xx -- pwm output |
whismanoid | 10:228a52f8107d | 3907 | // %Wpin -- measure high pulsewidth input in usec |
whismanoid | 10:228a52f8107d | 3908 | // %wpin -- measure low pulsewidth input in usec |
whismanoid | 10:228a52f8107d | 3909 | // %I... -- I2C diagnostics |
whismanoid | 10:228a52f8107d | 3910 | // %IP -- I2C probe |
whismanoid | 10:228a52f8107d | 3911 | // %IC scl=100khz ADDR=? -- I2C configure |
whismanoid | 10:228a52f8107d | 3912 | // %IW byte byte ... byte RD=? ADDR=0x -- write |
whismanoid | 10:228a52f8107d | 3913 | // %IR ADDR=? RD=? -- read |
whismanoid | 10:228a52f8107d | 3914 | // %I^ cmd=? -- i2c_smbus_read_word_data |
whismanoid | 10:228a52f8107d | 3915 | // %S... -- SPI diagnostics |
whismanoid | 10:228a52f8107d | 3916 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 10:228a52f8107d | 3917 | // %SW -- write (write and read) |
whismanoid | 10:228a52f8107d | 3918 | // %SR -- read (alias for %SW because SPI always write and read) |
whismanoid | 10:228a52f8107d | 3919 | // A-Z,a-z,0-9 reserved for application use |
whismanoid | 10:228a52f8107d | 3920 | // |
whismanoid | 10:228a52f8107d | 3921 | // get pinIndex from cmdLine[2] |
whismanoid | 10:228a52f8107d | 3922 | //int pinIndex = cmdLine[2]; |
whismanoid | 10:228a52f8107d | 3923 | // *** warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith] |
whismanoid | 10:228a52f8107d | 3924 | //int pinIndex = strtoul((char *)((void *)(cmdLine.str()) + 2), NULL, 10); // strtol(str, NULL, 10): get decimal value |
whismanoid | 10:228a52f8107d | 3925 | // ^ |
whismanoid | 10:228a52f8107d | 3926 | char strPinIndex[3]; |
whismanoid | 10:228a52f8107d | 3927 | strPinIndex[0] = cmdLine[2]; |
whismanoid | 10:228a52f8107d | 3928 | strPinIndex[1] = cmdLine[3]; |
whismanoid | 10:228a52f8107d | 3929 | strPinIndex[2] = '\0'; |
whismanoid | 10:228a52f8107d | 3930 | int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value |
whismanoid | 10:228a52f8107d | 3931 | //cmdLine.serial().printf(" pinIndex=%d ", pinIndex); |
whismanoid | 0:3edb3708c8c5 | 3932 | // |
whismanoid | 10:228a52f8107d | 3933 | // get next character |
whismanoid | 10:228a52f8107d | 3934 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 3935 | { |
whismanoid | 10:228a52f8107d | 3936 | #if HAS_digitalInOuts |
whismanoid | 10:228a52f8107d | 3937 | case 'H': case 'h': |
whismanoid | 10:228a52f8107d | 3938 | { |
whismanoid | 10:228a52f8107d | 3939 | // %Hpin -- digital output high |
whismanoid | 10:228a52f8107d | 3940 | #if ARDUINO_STYLE |
whismanoid | 10:228a52f8107d | 3941 | pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 |
whismanoid | 10:228a52f8107d | 3942 | digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 |
whismanoid | 10:228a52f8107d | 3943 | #else |
whismanoid | 10:228a52f8107d | 3944 | DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); |
whismanoid | 10:228a52f8107d | 3945 | digitalInOutPin.output(); |
whismanoid | 10:228a52f8107d | 3946 | digitalInOutPin.write(1); |
whismanoid | 10:228a52f8107d | 3947 | #endif |
whismanoid | 10:228a52f8107d | 3948 | cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex); |
whismanoid | 10:228a52f8107d | 3949 | } |
whismanoid | 10:228a52f8107d | 3950 | break; |
whismanoid | 10:228a52f8107d | 3951 | case 'L': case 'l': |
whismanoid | 10:228a52f8107d | 3952 | { |
whismanoid | 10:228a52f8107d | 3953 | // %Lpin -- digital output low |
whismanoid | 10:228a52f8107d | 3954 | #if ARDUINO_STYLE |
whismanoid | 10:228a52f8107d | 3955 | pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 |
whismanoid | 10:228a52f8107d | 3956 | digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 |
whismanoid | 10:228a52f8107d | 3957 | #else |
whismanoid | 10:228a52f8107d | 3958 | DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); |
whismanoid | 10:228a52f8107d | 3959 | digitalInOutPin.output(); |
whismanoid | 10:228a52f8107d | 3960 | digitalInOutPin.write(0); |
whismanoid | 10:228a52f8107d | 3961 | #endif |
whismanoid | 10:228a52f8107d | 3962 | cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex); |
whismanoid | 10:228a52f8107d | 3963 | } |
whismanoid | 10:228a52f8107d | 3964 | break; |
whismanoid | 0:3edb3708c8c5 | 3965 | case '?': |
whismanoid | 0:3edb3708c8c5 | 3966 | { |
whismanoid | 10:228a52f8107d | 3967 | // %?pin -- digital input |
whismanoid | 10:228a52f8107d | 3968 | #if ARDUINO_STYLE |
whismanoid | 10:228a52f8107d | 3969 | pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 |
whismanoid | 10:228a52f8107d | 3970 | #else |
whismanoid | 10:228a52f8107d | 3971 | DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); |
whismanoid | 10:228a52f8107d | 3972 | digitalInOutPin.input(); |
whismanoid | 10:228a52f8107d | 3973 | #endif |
whismanoid | 10:228a52f8107d | 3974 | serial.printf(" digitalInOutPin %d Input ", pinIndex); |
whismanoid | 10:228a52f8107d | 3975 | #if ARDUINO_STYLE |
whismanoid | 10:228a52f8107d | 3976 | int value = digitalRead(pinIndex); |
whismanoid | 10:228a52f8107d | 3977 | #else |
whismanoid | 10:228a52f8107d | 3978 | int value = digitalInOutPin.read(); |
whismanoid | 10:228a52f8107d | 3979 | #endif |
whismanoid | 10:228a52f8107d | 3980 | cmdLine.serial().printf("%d ", value); |
whismanoid | 0:3edb3708c8c5 | 3981 | } |
whismanoid | 0:3edb3708c8c5 | 3982 | break; |
whismanoid | 10:228a52f8107d | 3983 | #endif |
whismanoid | 10:228a52f8107d | 3984 | // |
whismanoid | 10:228a52f8107d | 3985 | #if HAS_analogIns |
whismanoid | 10:228a52f8107d | 3986 | case 'A': case 'a': |
whismanoid | 0:3edb3708c8c5 | 3987 | { |
whismanoid | 0:3edb3708c8c5 | 3988 | // %A %Apin -- analog input |
whismanoid | 10:228a52f8107d | 3989 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 10:228a52f8107d | 3990 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 10:228a52f8107d | 3991 | for (int pinIndex = 0; pinIndex < 2; pinIndex++) |
whismanoid | 10:228a52f8107d | 3992 | { |
whismanoid | 10:228a52f8107d | 3993 | int cPinIndex = '0' + pinIndex; |
whismanoid | 10:228a52f8107d | 3994 | AnalogIn& analogInPin = find_analogInPin(cPinIndex); |
whismanoid | 10:228a52f8107d | 3995 | float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; |
whismanoid | 10:228a52f8107d | 3996 | float normValue_0_1 = analogInPin.read(); |
whismanoid | 10:228a52f8107d | 3997 | // |
whismanoid | 10:228a52f8107d | 3998 | int pinIndexH = pinIndex + 4; |
whismanoid | 10:228a52f8107d | 3999 | int cPinIndexH = '0' + pinIndexH; |
whismanoid | 10:228a52f8107d | 4000 | AnalogIn& analogInPinH = find_analogInPin(cPinIndexH); |
whismanoid | 10:228a52f8107d | 4001 | float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH]; |
whismanoid | 10:228a52f8107d | 4002 | float normValueH_0_1 = analogInPinH.read(); |
whismanoid | 10:228a52f8107d | 4003 | // |
whismanoid | 10:228a52f8107d | 4004 | cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV \r\n", |
whismanoid | 10:228a52f8107d | 4005 | cPinIndex, |
whismanoid | 10:228a52f8107d | 4006 | normValue_0_1 * 100.0, |
whismanoid | 10:228a52f8107d | 4007 | normValue_0_1 * adc_full_scale_voltage, |
whismanoid | 10:228a52f8107d | 4008 | cPinIndexH, |
whismanoid | 10:228a52f8107d | 4009 | normValueH_0_1 * 100.0, |
whismanoid | 10:228a52f8107d | 4010 | normValueH_0_1 * adc_full_scale_voltageH |
whismanoid | 10:228a52f8107d | 4011 | ); |
whismanoid | 10:228a52f8107d | 4012 | } |
whismanoid | 10:228a52f8107d | 4013 | for (int pinIndex = 2; pinIndex < 4; pinIndex++) |
whismanoid | 10:228a52f8107d | 4014 | { |
whismanoid | 10:228a52f8107d | 4015 | int cPinIndex = '0' + pinIndex; |
whismanoid | 10:228a52f8107d | 4016 | AnalogIn& analogInPin = find_analogInPin(cPinIndex); |
whismanoid | 10:228a52f8107d | 4017 | float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; |
whismanoid | 10:228a52f8107d | 4018 | float normValue_0_1 = analogInPin.read(); |
whismanoid | 10:228a52f8107d | 4019 | // |
whismanoid | 10:228a52f8107d | 4020 | cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n", |
whismanoid | 10:228a52f8107d | 4021 | cPinIndex, |
whismanoid | 10:228a52f8107d | 4022 | normValue_0_1 * 100.0, |
whismanoid | 10:228a52f8107d | 4023 | normValue_0_1 * adc_full_scale_voltage |
whismanoid | 10:228a52f8107d | 4024 | ); |
whismanoid | 10:228a52f8107d | 4025 | } |
whismanoid | 10:228a52f8107d | 4026 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 10:228a52f8107d | 4027 | // Platform board uses simple analog inputs |
whismanoid | 10:228a52f8107d | 4028 | // assume standard Arduino analog inputs A0-A5 |
whismanoid | 10:228a52f8107d | 4029 | for (int pinIndex = 0; pinIndex < 6; pinIndex++) |
whismanoid | 10:228a52f8107d | 4030 | { |
whismanoid | 10:228a52f8107d | 4031 | int cPinIndex = '0' + pinIndex; |
whismanoid | 10:228a52f8107d | 4032 | AnalogIn& analogInPin = find_analogInPin(cPinIndex); |
whismanoid | 10:228a52f8107d | 4033 | float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; |
whismanoid | 10:228a52f8107d | 4034 | float normValue_0_1 = analogInPin.read(); |
whismanoid | 10:228a52f8107d | 4035 | // |
whismanoid | 10:228a52f8107d | 4036 | cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n", |
whismanoid | 10:228a52f8107d | 4037 | cPinIndex, |
whismanoid | 10:228a52f8107d | 4038 | normValue_0_1 * 100.0, |
whismanoid | 10:228a52f8107d | 4039 | normValue_0_1 * adc_full_scale_voltage |
whismanoid | 10:228a52f8107d | 4040 | ); |
whismanoid | 10:228a52f8107d | 4041 | } |
whismanoid | 10:228a52f8107d | 4042 | #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 10:228a52f8107d | 4043 | } |
whismanoid | 10:228a52f8107d | 4044 | break; |
whismanoid | 10:228a52f8107d | 4045 | #endif |
whismanoid | 10:228a52f8107d | 4046 | // |
whismanoid | 10:228a52f8107d | 4047 | #if HAS_SPI2_MAX541 |
whismanoid | 10:228a52f8107d | 4048 | case 'D': case 'd': |
whismanoid | 10:228a52f8107d | 4049 | { |
whismanoid | 10:228a52f8107d | 4050 | // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV) |
whismanoid | 10:228a52f8107d | 4051 | // MAX541 max541(spi2_max541, spi2_max541_cs); |
whismanoid | 10:228a52f8107d | 4052 | float voltageV = max541.Get_Voltage(); |
whismanoid | 10:228a52f8107d | 4053 | // if (cmdLine[2] == '+') { |
whismanoid | 10:228a52f8107d | 4054 | // // %D+ |
whismanoid | 10:228a52f8107d | 4055 | // voltageV = voltageV * 1.25f; |
whismanoid | 10:228a52f8107d | 4056 | // if (voltageV >= max541.VRef) voltageV = max541.VRef; |
whismanoid | 10:228a52f8107d | 4057 | // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 10:228a52f8107d | 4058 | // } |
whismanoid | 10:228a52f8107d | 4059 | // else if (cmdLine[2] == '-') { |
whismanoid | 10:228a52f8107d | 4060 | // // %D- |
whismanoid | 10:228a52f8107d | 4061 | // voltageV = voltageV * 0.75f; |
whismanoid | 10:228a52f8107d | 4062 | // if (voltageV < 0.1f) voltageV = 0.1f; |
whismanoid | 10:228a52f8107d | 4063 | // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 10:228a52f8107d | 4064 | // } |
whismanoid | 10:228a52f8107d | 4065 | if (cmdLine.parse_float("V", voltageV)) |
whismanoid | 10:228a52f8107d | 4066 | { |
whismanoid | 10:228a52f8107d | 4067 | // %D V=1.234 -- set voltage |
whismanoid | 10:228a52f8107d | 4068 | max541.Set_Voltage(voltageV); |
whismanoid | 10:228a52f8107d | 4069 | } |
whismanoid | 10:228a52f8107d | 4070 | else if (cmdLine.parse_float("TEST", voltageV)) |
whismanoid | 10:228a52f8107d | 4071 | { |
whismanoid | 10:228a52f8107d | 4072 | // %D TEST=1.234 -- set voltage and compare with AIN0 |
whismanoid | 10:228a52f8107d | 4073 | SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 10:228a52f8107d | 4074 | } |
whismanoid | 10:228a52f8107d | 4075 | else if (cmdLine.parse_float("CAL", voltageV)) |
whismanoid | 10:228a52f8107d | 4076 | { |
whismanoid | 10:228a52f8107d | 4077 | // %D CAL=1.234 -- calibrate VRef and compare with AIN0 |
whismanoid | 10:228a52f8107d | 4078 | |
whismanoid | 10:228a52f8107d | 4079 | max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale |
whismanoid | 10:228a52f8107d | 4080 | 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 | 4081 | const int average_count = 100; |
whismanoid | 10:228a52f8107d | 4082 | const double average_K = 0.25; |
whismanoid | 10:228a52f8107d | 4083 | for (int count = 0; count < average_count; count++) { |
whismanoid | 10:228a52f8107d | 4084 | double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 10:228a52f8107d | 4085 | max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V); |
whismanoid | 10:228a52f8107d | 4086 | } |
whismanoid | 10:228a52f8107d | 4087 | max541.VRef = 2.0 * max541_midscale_V; |
whismanoid | 10:228a52f8107d | 4088 | cmdLine.serial().printf( |
whismanoid | 10:228a52f8107d | 4089 | "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV", |
whismanoid | 10:228a52f8107d | 4090 | max541_midscale_V, max541.VRef); |
whismanoid | 10:228a52f8107d | 4091 | // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4 |
whismanoid | 10:228a52f8107d | 4092 | voltageV = 1.0f; |
whismanoid | 10:228a52f8107d | 4093 | SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 10:228a52f8107d | 4094 | } |
whismanoid | 10:228a52f8107d | 4095 | else { |
whismanoid | 10:228a52f8107d | 4096 | // %D -- print MAX541 DAC status |
whismanoid | 10:228a52f8107d | 4097 | cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n", |
whismanoid | 10:228a52f8107d | 4098 | max541.Get_Code(), max541.Get_Voltage(), max541.VRef); |
whismanoid | 10:228a52f8107d | 4099 | } |
whismanoid | 10:228a52f8107d | 4100 | } |
whismanoid | 10:228a52f8107d | 4101 | break; |
whismanoid | 10:228a52f8107d | 4102 | #endif |
whismanoid | 10:228a52f8107d | 4103 | |
whismanoid | 10:228a52f8107d | 4104 | // |
whismanoid | 10:228a52f8107d | 4105 | #if HAS_I2C // SUPPORT_I2C |
whismanoid | 10:228a52f8107d | 4106 | case 'I': case 'i': |
whismanoid | 0:3edb3708c8c5 | 4107 | // %I... -- I2C diagnostics |
whismanoid | 0:3edb3708c8c5 | 4108 | // %IP -- I2C probe |
whismanoid | 0:3edb3708c8c5 | 4109 | // %IC scl=100khz ADDR=? -- I2C configure |
whismanoid | 0:3edb3708c8c5 | 4110 | // %IW byte byte ... byte RD=? ADDR=0x -- write |
whismanoid | 0:3edb3708c8c5 | 4111 | // %IR ADDR=? RD=? -- read |
whismanoid | 0:3edb3708c8c5 | 4112 | // %I^ cmd=? -- i2c_smbus_read_word_data |
whismanoid | 10:228a52f8107d | 4113 | // get next character |
whismanoid | 10:228a52f8107d | 4114 | // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7 |
whismanoid | 10:228a52f8107d | 4115 | cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7); |
whismanoid | 10:228a52f8107d | 4116 | // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count |
whismanoid | 10:228a52f8107d | 4117 | g_I2C_read_count = 0; // read count must be reset every command |
whismanoid | 10:228a52f8107d | 4118 | cmdLine.parse_byte_dec("RD", g_I2C_read_count); |
whismanoid | 10:228a52f8107d | 4119 | // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress |
whismanoid | 10:228a52f8107d | 4120 | cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress); |
whismanoid | 10:228a52f8107d | 4121 | switch (cmdLine[2]) |
whismanoid | 10:228a52f8107d | 4122 | { |
whismanoid | 10:228a52f8107d | 4123 | case 'P': case 'p': |
whismanoid | 10:228a52f8107d | 4124 | { |
whismanoid | 10:228a52f8107d | 4125 | // %IP -- I2C probe |
whismanoid | 10:228a52f8107d | 4126 | HuntAttachedI2CDevices(cmdLine, 0x03, 0x77); |
whismanoid | 10:228a52f8107d | 4127 | } |
whismanoid | 10:228a52f8107d | 4128 | break; |
whismanoid | 10:228a52f8107d | 4129 | case 'C': case 'c': |
whismanoid | 10:228a52f8107d | 4130 | { |
whismanoid | 10:228a52f8107d | 4131 | bool isUpdatedI2CConfig = false; |
whismanoid | 10:228a52f8107d | 4132 | // %IC scl=100khz ADDR=? -- I2C configure |
whismanoid | 10:228a52f8107d | 4133 | // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz |
whismanoid | 10:228a52f8107d | 4134 | if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz)) |
whismanoid | 10:228a52f8107d | 4135 | { |
whismanoid | 10:228a52f8107d | 4136 | isUpdatedI2CConfig = true; |
whismanoid | 10:228a52f8107d | 4137 | // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU |
whismanoid | 10:228a52f8107d | 4138 | if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz) |
whismanoid | 10:228a52f8107d | 4139 | { |
whismanoid | 10:228a52f8107d | 4140 | g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz; |
whismanoid | 10:228a52f8107d | 4141 | } |
whismanoid | 10:228a52f8107d | 4142 | if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz) |
whismanoid | 10:228a52f8107d | 4143 | { |
whismanoid | 10:228a52f8107d | 4144 | g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz; |
whismanoid | 10:228a52f8107d | 4145 | } |
whismanoid | 10:228a52f8107d | 4146 | } |
whismanoid | 10:228a52f8107d | 4147 | if (isUpdatedI2CConfig) |
whismanoid | 10:228a52f8107d | 4148 | { |
whismanoid | 10:228a52f8107d | 4149 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 10:228a52f8107d | 4150 | I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 10:228a52f8107d | 4151 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 10:228a52f8107d | 4152 | i2cMaster.start(); |
whismanoid | 10:228a52f8107d | 4153 | i2cMaster.stop(); |
whismanoid | 10:228a52f8107d | 4154 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 10:228a52f8107d | 4155 | cmdLine.serial().printf( |
whismanoid | 10:228a52f8107d | 4156 | "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config", |
whismanoid | 10:228a52f8107d | 4157 | g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz, |
whismanoid | 10:228a52f8107d | 4158 | (g_I2C_SCL_Hz / 1000.)); |
whismanoid | 10:228a52f8107d | 4159 | i2cMaster.start(); |
whismanoid | 10:228a52f8107d | 4160 | i2cMaster.stop(); |
whismanoid | 10:228a52f8107d | 4161 | } |
whismanoid | 10:228a52f8107d | 4162 | } |
whismanoid | 10:228a52f8107d | 4163 | break; |
whismanoid | 10:228a52f8107d | 4164 | case 'W': case 'w': |
whismanoid | 10:228a52f8107d | 4165 | { |
whismanoid | 10:228a52f8107d | 4166 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 10:228a52f8107d | 4167 | I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 10:228a52f8107d | 4168 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 10:228a52f8107d | 4169 | // %IW byte byte ... byte RD=? ADDR=0x -- write |
whismanoid | 10:228a52f8107d | 4170 | // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; |
whismanoid | 10:228a52f8107d | 4171 | #define MAX_I2C_BYTE_COUNT 32 |
whismanoid | 10:228a52f8107d | 4172 | size_t byteCount = byteCount; |
whismanoid | 10:228a52f8107d | 4173 | static char mosiData[MAX_I2C_BYTE_COUNT]; |
whismanoid | 10:228a52f8107d | 4174 | static char misoData[MAX_I2C_BYTE_COUNT]; |
whismanoid | 10:228a52f8107d | 4175 | if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, |
whismanoid | 10:228a52f8107d | 4176 | MAX_I2C_BYTE_COUNT)) |
whismanoid | 10:228a52f8107d | 4177 | { |
whismanoid | 10:228a52f8107d | 4178 | // hex dump mosiData[0..byteCount-1] |
whismanoid | 10:228a52f8107d | 4179 | cmdLine.serial().printf( |
whismanoid | 10:228a52f8107d | 4180 | "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->", |
whismanoid | 10:228a52f8107d | 4181 | g_I2C_deviceAddress7, |
whismanoid | 10:228a52f8107d | 4182 | (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count); |
whismanoid | 10:228a52f8107d | 4183 | for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 10:228a52f8107d | 4184 | { |
whismanoid | 10:228a52f8107d | 4185 | cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 10:228a52f8107d | 4186 | } |
whismanoid | 10:228a52f8107d | 4187 | // |
whismanoid | 10:228a52f8107d | 4188 | // TODO: i2c transfer |
whismanoid | 10:228a52f8107d | 4189 | //const int addr7bit = 0x48; // 7 bit I2C address |
whismanoid | 10:228a52f8107d | 4190 | //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 |
whismanoid | 10:228a52f8107d | 4191 | // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. |
whismanoid | 10:228a52f8107d | 4192 | // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. |
whismanoid | 10:228a52f8107d | 4193 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 10:228a52f8107d | 4194 | // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. |
whismanoid | 10:228a52f8107d | 4195 | // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. |
whismanoid | 10:228a52f8107d | 4196 | // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. |
whismanoid | 10:228a52f8107d | 4197 | // /* 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 | 4198 | // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... |
whismanoid | 10:228a52f8107d | 4199 | const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90 |
whismanoid | 10:228a52f8107d | 4200 | unsigned int misoLength = 0; |
whismanoid | 10:228a52f8107d | 4201 | bool repeated = (g_I2C_read_count > 0); |
whismanoid | 10:228a52f8107d | 4202 | // |
whismanoid | 10:228a52f8107d | 4203 | int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated); |
whismanoid | 10:228a52f8107d | 4204 | switch (writeStatus) |
whismanoid | 10:228a52f8107d | 4205 | { |
whismanoid | 10:228a52f8107d | 4206 | case 0: cmdLine.serial().printf(" ack "); break; |
whismanoid | 10:228a52f8107d | 4207 | case 1: cmdLine.serial().printf(" nack "); break; |
whismanoid | 10:228a52f8107d | 4208 | default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ", |
whismanoid | 10:228a52f8107d | 4209 | writeStatus); |
whismanoid | 10:228a52f8107d | 4210 | } |
whismanoid | 10:228a52f8107d | 4211 | if (repeated) |
whismanoid | 10:228a52f8107d | 4212 | { |
whismanoid | 10:228a52f8107d | 4213 | int readStatus = |
whismanoid | 10:228a52f8107d | 4214 | i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false); |
whismanoid | 10:228a52f8107d | 4215 | switch (readStatus) |
whismanoid | 10:228a52f8107d | 4216 | { |
whismanoid | 10:228a52f8107d | 4217 | case 1: cmdLine.serial().printf(" nack "); break; |
whismanoid | 10:228a52f8107d | 4218 | case 0: cmdLine.serial().printf(" ack "); break; |
whismanoid | 10:228a52f8107d | 4219 | default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ", |
whismanoid | 10:228a52f8107d | 4220 | readStatus); |
whismanoid | 10:228a52f8107d | 4221 | } |
whismanoid | 10:228a52f8107d | 4222 | } |
whismanoid | 10:228a52f8107d | 4223 | // |
whismanoid | 10:228a52f8107d | 4224 | if (misoLength > 0) |
whismanoid | 10:228a52f8107d | 4225 | { |
whismanoid | 10:228a52f8107d | 4226 | // hex dump misoData[0..byteCount-1] |
whismanoid | 10:228a52f8107d | 4227 | cmdLine.serial().printf(" MISO<-"); |
whismanoid | 10:228a52f8107d | 4228 | for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count; |
whismanoid | 10:228a52f8107d | 4229 | byteIndex++) |
whismanoid | 10:228a52f8107d | 4230 | { |
whismanoid | 10:228a52f8107d | 4231 | cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 10:228a52f8107d | 4232 | } |
whismanoid | 10:228a52f8107d | 4233 | } |
whismanoid | 10:228a52f8107d | 4234 | cmdLine.serial().printf(" "); |
whismanoid | 10:228a52f8107d | 4235 | } |
whismanoid | 10:228a52f8107d | 4236 | } |
whismanoid | 10:228a52f8107d | 4237 | break; |
whismanoid | 10:228a52f8107d | 4238 | case 'R': case 'r': |
whismanoid | 10:228a52f8107d | 4239 | { |
whismanoid | 10:228a52f8107d | 4240 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 10:228a52f8107d | 4241 | I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 10:228a52f8107d | 4242 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 10:228a52f8107d | 4243 | // %IR ADDR=? RD=? -- read |
whismanoid | 10:228a52f8107d | 4244 | // TODO: i2c transfer |
whismanoid | 10:228a52f8107d | 4245 | //const int addr7bit = 0x48; // 7 bit I2C address |
whismanoid | 10:228a52f8107d | 4246 | //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 |
whismanoid | 10:228a52f8107d | 4247 | // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. |
whismanoid | 10:228a52f8107d | 4248 | // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. |
whismanoid | 10:228a52f8107d | 4249 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 10:228a52f8107d | 4250 | // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. |
whismanoid | 10:228a52f8107d | 4251 | // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. |
whismanoid | 10:228a52f8107d | 4252 | // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. |
whismanoid | 10:228a52f8107d | 4253 | // /* 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 | 4254 | // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... |
whismanoid | 10:228a52f8107d | 4255 | } |
whismanoid | 10:228a52f8107d | 4256 | break; |
whismanoid | 10:228a52f8107d | 4257 | case '^': |
whismanoid | 10:228a52f8107d | 4258 | { |
whismanoid | 10:228a52f8107d | 4259 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 10:228a52f8107d | 4260 | I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 10:228a52f8107d | 4261 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 10:228a52f8107d | 4262 | // %I^ cmd=? -- i2c_smbus_read_word_data |
whismanoid | 10:228a52f8107d | 4263 | // TODO: i2c transfer |
whismanoid | 10:228a52f8107d | 4264 | //const int addr7bit = 0x48; // 7 bit I2C address |
whismanoid | 10:228a52f8107d | 4265 | //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 |
whismanoid | 10:228a52f8107d | 4266 | // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. |
whismanoid | 10:228a52f8107d | 4267 | // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. |
whismanoid | 10:228a52f8107d | 4268 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 10:228a52f8107d | 4269 | // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. |
whismanoid | 10:228a52f8107d | 4270 | // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. |
whismanoid | 10:228a52f8107d | 4271 | // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. |
whismanoid | 10:228a52f8107d | 4272 | // /* 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 | 4273 | // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... |
whismanoid | 10:228a52f8107d | 4274 | } |
whismanoid | 10:228a52f8107d | 4275 | break; |
whismanoid | 10:228a52f8107d | 4276 | } // switch(cmdLine[2]) |
whismanoid | 10:228a52f8107d | 4277 | break; |
whismanoid | 10:228a52f8107d | 4278 | #endif |
whismanoid | 10:228a52f8107d | 4279 | // |
whismanoid | 10:228a52f8107d | 4280 | #if HAS_SPI // SUPPORT_SPI |
whismanoid | 10:228a52f8107d | 4281 | case 'S': case 's': |
whismanoid | 10:228a52f8107d | 4282 | { |
whismanoid | 0:3edb3708c8c5 | 4283 | // %S... -- SPI diagnostics |
whismanoid | 0:3edb3708c8c5 | 4284 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 0:3edb3708c8c5 | 4285 | // %SW -- write (write and read) |
whismanoid | 0:3edb3708c8c5 | 4286 | // %SR -- read (alias for %SW because SPI always write and read) |
whismanoid | 0:3edb3708c8c5 | 4287 | // |
whismanoid | 10:228a52f8107d | 4288 | // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d |
whismanoid | 10:228a52f8107d | 4289 | bool isUpdatedSPIConfig = false; |
whismanoid | 10:228a52f8107d | 4290 | // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2 |
whismanoid | 10:228a52f8107d | 4291 | // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1 |
whismanoid | 10:228a52f8107d | 4292 | if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2)) |
whismanoid | 10:228a52f8107d | 4293 | { |
whismanoid | 10:228a52f8107d | 4294 | isUpdatedSPIConfig = true; |
whismanoid | 10:228a52f8107d | 4295 | } |
whismanoid | 10:228a52f8107d | 4296 | if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1)) |
whismanoid | 0:3edb3708c8c5 | 4297 | { |
whismanoid | 10:228a52f8107d | 4298 | isUpdatedSPIConfig = true; |
whismanoid | 10:228a52f8107d | 4299 | } |
whismanoid | 10:228a52f8107d | 4300 | if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1)) |
whismanoid | 10:228a52f8107d | 4301 | { |
whismanoid | 10:228a52f8107d | 4302 | isUpdatedSPIConfig = true; |
whismanoid | 10:228a52f8107d | 4303 | } |
whismanoid | 10:228a52f8107d | 4304 | // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz |
whismanoid | 10:228a52f8107d | 4305 | if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz)) |
whismanoid | 10:228a52f8107d | 4306 | { |
whismanoid | 10:228a52f8107d | 4307 | isUpdatedSPIConfig = true; |
whismanoid | 10:228a52f8107d | 4308 | // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU |
whismanoid | 10:228a52f8107d | 4309 | if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz) |
whismanoid | 0:3edb3708c8c5 | 4310 | { |
whismanoid | 10:228a52f8107d | 4311 | g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz; |
whismanoid | 0:3edb3708c8c5 | 4312 | } |
whismanoid | 10:228a52f8107d | 4313 | if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz) |
whismanoid | 0:3edb3708c8c5 | 4314 | { |
whismanoid | 10:228a52f8107d | 4315 | g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz; |
whismanoid | 10:228a52f8107d | 4316 | } |
whismanoid | 10:228a52f8107d | 4317 | } |
whismanoid | 10:228a52f8107d | 4318 | // Update SPI configuration |
whismanoid | 10:228a52f8107d | 4319 | if (isUpdatedSPIConfig) |
whismanoid | 10:228a52f8107d | 4320 | { |
whismanoid | 10:228a52f8107d | 4321 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 10:228a52f8107d | 4322 | spi_cs = g_SPI_cs_state; |
whismanoid | 10:228a52f8107d | 4323 | spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 |
whismanoid | 10:228a52f8107d | 4324 | #if APPLICATION_MAX5715 |
whismanoid | 10:228a52f8107d | 4325 | g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz); |
whismanoid | 10:228a52f8107d | 4326 | #elif APPLICATION_MAX11131 |
whismanoid | 10:228a52f8107d | 4327 | g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz); |
whismanoid | 10:228a52f8107d | 4328 | #elif APPLICATION_MAX5171 |
whismanoid | 10:228a52f8107d | 4329 | g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz); |
whismanoid | 10:228a52f8107d | 4330 | #elif APPLICATION_MAX11410 |
whismanoid | 10:228a52f8107d | 4331 | g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz); |
whismanoid | 10:228a52f8107d | 4332 | #elif APPLICATION_MAX12345 |
whismanoid | 10:228a52f8107d | 4333 | g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz); |
whismanoid | 0:3edb3708c8c5 | 4334 | #else |
whismanoid | 10:228a52f8107d | 4335 | spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default) |
whismanoid | 0:3edb3708c8c5 | 4336 | #endif |
whismanoid | 0:3edb3708c8c5 | 4337 | // |
whismanoid | 10:228a52f8107d | 4338 | double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz; |
whismanoid | 10:228a52f8107d | 4339 | int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate |
whismanoid | 10:228a52f8107d | 4340 | double actual_SCLK_Hz = SystemCoreClock / actual_divisor; |
whismanoid | 10:228a52f8107d | 4341 | // |
whismanoid | 10:228a52f8107d | 4342 | // 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 | 4343 | cmdLine.serial().printf( |
whismanoid | 10:228a52f8107d | 4344 | "\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 | 4345 | ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0), |
whismanoid | 10:228a52f8107d | 4346 | ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0), |
whismanoid | 10:228a52f8107d | 4347 | g_SPI_cs_state, |
whismanoid | 10:228a52f8107d | 4348 | g_SPI_SCLK_Hz, |
whismanoid | 10:228a52f8107d | 4349 | (g_SPI_SCLK_Hz / 1000000.), |
whismanoid | 10:228a52f8107d | 4350 | ((double)(SystemCoreClock / 1000000.)), |
whismanoid | 10:228a52f8107d | 4351 | ideal_divisor, |
whismanoid | 10:228a52f8107d | 4352 | (actual_SCLK_Hz / 1000000.) |
whismanoid | 10:228a52f8107d | 4353 | ); |
whismanoid | 10:228a52f8107d | 4354 | } |
whismanoid | 10:228a52f8107d | 4355 | // get next character |
whismanoid | 10:228a52f8107d | 4356 | switch (cmdLine[2]) |
whismanoid | 10:228a52f8107d | 4357 | { |
whismanoid | 10:228a52f8107d | 4358 | case 'C': case 's': |
whismanoid | 10:228a52f8107d | 4359 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 10:228a52f8107d | 4360 | break; |
whismanoid | 10:228a52f8107d | 4361 | case 'W': case 'R': case 'w': case 'r': |
whismanoid | 0:3edb3708c8c5 | 4362 | { |
whismanoid | 10:228a52f8107d | 4363 | // %SW -- write (write and read) |
whismanoid | 10:228a52f8107d | 4364 | // %SR -- read (alias for %SW because SPI always write and read) |
whismanoid | 10:228a52f8107d | 4365 | // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; |
whismanoid | 10:228a52f8107d | 4366 | #define MAX_SPI_BYTE_COUNT 32 |
whismanoid | 10:228a52f8107d | 4367 | size_t byteCount = byteCount; |
whismanoid | 10:228a52f8107d | 4368 | static char mosiData[MAX_SPI_BYTE_COUNT]; |
whismanoid | 10:228a52f8107d | 4369 | static char misoData[MAX_SPI_BYTE_COUNT]; |
whismanoid | 10:228a52f8107d | 4370 | if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, |
whismanoid | 10:228a52f8107d | 4371 | MAX_SPI_BYTE_COUNT)) |
whismanoid | 0:3edb3708c8c5 | 4372 | { |
whismanoid | 10:228a52f8107d | 4373 | // hex dump mosiData[0..byteCount-1] |
whismanoid | 10:228a52f8107d | 4374 | cmdLine.serial().printf("\r\nSPI"); |
whismanoid | 10:228a52f8107d | 4375 | if (byteCount > 7) { |
whismanoid | 10:228a52f8107d | 4376 | cmdLine.serial().printf(" byteCount:%d", byteCount); |
whismanoid | 10:228a52f8107d | 4377 | } |
whismanoid | 10:228a52f8107d | 4378 | cmdLine.serial().printf(" MOSI->"); |
whismanoid | 10:228a52f8107d | 4379 | for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 10:228a52f8107d | 4380 | { |
whismanoid | 10:228a52f8107d | 4381 | cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 4382 | } |
whismanoid | 10:228a52f8107d | 4383 | spi_cs = 0; |
whismanoid | 10:228a52f8107d | 4384 | unsigned int numBytesTransferred = |
whismanoid | 10:228a52f8107d | 4385 | spi.write(mosiData, byteCount, misoData, byteCount); |
whismanoid | 10:228a52f8107d | 4386 | spi_cs = 1; |
whismanoid | 10:228a52f8107d | 4387 | // hex dump misoData[0..byteCount-1] |
whismanoid | 10:228a52f8107d | 4388 | cmdLine.serial().printf(" MISO<-"); |
whismanoid | 10:228a52f8107d | 4389 | for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; |
whismanoid | 10:228a52f8107d | 4390 | byteIndex++) |
whismanoid | 10:228a52f8107d | 4391 | { |
whismanoid | 10:228a52f8107d | 4392 | cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 10:228a52f8107d | 4393 | } |
whismanoid | 10:228a52f8107d | 4394 | cmdLine.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 4395 | } |
whismanoid | 0:3edb3708c8c5 | 4396 | } |
whismanoid | 0:3edb3708c8c5 | 4397 | break; |
whismanoid | 10:228a52f8107d | 4398 | } // switch(cmdLine[2]) |
whismanoid | 10:228a52f8107d | 4399 | } // case 'S': // %S... -- SPI diagnostics |
whismanoid | 10:228a52f8107d | 4400 | break; |
whismanoid | 10:228a52f8107d | 4401 | #endif |
whismanoid | 10:228a52f8107d | 4402 | // |
whismanoid | 10:228a52f8107d | 4403 | // A-Z,a-z,0-9 reserved for application use |
whismanoid | 10:228a52f8107d | 4404 | } // switch(cmdLine[1]) |
whismanoid | 10:228a52f8107d | 4405 | } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 4406 | |
whismanoid | 0:3edb3708c8c5 | 4407 | |
whismanoid | 10:228a52f8107d | 4408 | //-------------------------------------------------- |
whismanoid | 10:228a52f8107d | 4409 | #if 0 // APPLICATION_MAX5715 // MAX5715_menu_onEOLcommandParser moved to Test_Menu_MAX5715.cpp |
whismanoid | 10:228a52f8107d | 4410 | bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 4411 | { |
whismanoid | 10:228a52f8107d | 4412 | switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 4413 | { |
whismanoid | 0:3edb3708c8c5 | 4414 | case '0': |
whismanoid | 0:3edb3708c8c5 | 4415 | { |
whismanoid | 0:3edb3708c8c5 | 4416 | // recommended for hex command codes 00..0F |
whismanoid | 0:3edb3708c8c5 | 4417 | // TODO: cmdLine.serial().printf("\r\n 0 ch=? code=? -- CODEn"); |
whismanoid | 0:3edb3708c8c5 | 4418 | // Menu 0 ch=? code=?) CODEn |
whismanoid | 0:3edb3708c8c5 | 4419 | // MAX5715_CODEn(uint8_t channel, uint16_t dacCodeLsbs); |
whismanoid | 0:3edb3708c8c5 | 4420 | // VERIFY: parse strCommandArgs for additional arguments including key=value pairs |
whismanoid | 0:3edb3708c8c5 | 4421 | // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 4422 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 4423 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 4424 | { |
whismanoid | 0:3edb3708c8c5 | 4425 | } |
whismanoid | 0:3edb3708c8c5 | 4426 | uint16_t code = g_MAX5715_device.CODE[ch]; |
whismanoid | 0:3edb3708c8c5 | 4427 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 4428 | { |
whismanoid | 0:3edb3708c8c5 | 4429 | } |
whismanoid | 0:3edb3708c8c5 | 4430 | cmdLine.serial().printf("CODEn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 4431 | g_MAX5715_device.CODEn(ch, code); |
whismanoid | 10:228a52f8107d | 4432 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4433 | } |
whismanoid | 0:3edb3708c8c5 | 4434 | break; |
whismanoid | 0:3edb3708c8c5 | 4435 | case '1': |
whismanoid | 0:3edb3708c8c5 | 4436 | { |
whismanoid | 0:3edb3708c8c5 | 4437 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 4438 | // TODO: cmdLine.serial().printf("\r\n 1 ch=? -- LOADn"); |
whismanoid | 0:3edb3708c8c5 | 4439 | // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 4440 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 4441 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 4442 | { |
whismanoid | 0:3edb3708c8c5 | 4443 | } |
whismanoid | 0:3edb3708c8c5 | 4444 | cmdLine.serial().printf("LOADn ch=%d", ch); |
whismanoid | 0:3edb3708c8c5 | 4445 | g_MAX5715_device.LOADn(ch); |
whismanoid | 10:228a52f8107d | 4446 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4447 | } |
whismanoid | 0:3edb3708c8c5 | 4448 | break; |
whismanoid | 0:3edb3708c8c5 | 4449 | case '2': |
whismanoid | 0:3edb3708c8c5 | 4450 | { |
whismanoid | 0:3edb3708c8c5 | 4451 | // recommended for hex command codes 20..2F |
whismanoid | 0:3edb3708c8c5 | 4452 | // TODO: cmdLine.serial().printf("\r\n 2 ch=? code=? -- CODEnLOADall"); |
whismanoid | 0:3edb3708c8c5 | 4453 | // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 4454 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 4455 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 4456 | { |
whismanoid | 0:3edb3708c8c5 | 4457 | } |
whismanoid | 0:3edb3708c8c5 | 4458 | uint16_t code = g_MAX5715_device.CODE[ch]; |
whismanoid | 0:3edb3708c8c5 | 4459 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 4460 | { |
whismanoid | 0:3edb3708c8c5 | 4461 | } |
whismanoid | 0:3edb3708c8c5 | 4462 | cmdLine.serial().printf("CODEnLOADall ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 4463 | g_MAX5715_device.CODEnLOADall(ch, code); |
whismanoid | 10:228a52f8107d | 4464 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4465 | } |
whismanoid | 0:3edb3708c8c5 | 4466 | break; |
whismanoid | 0:3edb3708c8c5 | 4467 | case '3': |
whismanoid | 0:3edb3708c8c5 | 4468 | { |
whismanoid | 0:3edb3708c8c5 | 4469 | // recommended for hex command codes 30..3F |
whismanoid | 0:3edb3708c8c5 | 4470 | // TODO: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); |
whismanoid | 0:3edb3708c8c5 | 4471 | // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 4472 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 4473 | uint16_t code; |
whismanoid | 0:3edb3708c8c5 | 4474 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 4475 | { |
whismanoid | 0:3edb3708c8c5 | 4476 | } |
whismanoid | 0:3edb3708c8c5 | 4477 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 4478 | { |
whismanoid | 0:3edb3708c8c5 | 4479 | } |
whismanoid | 0:3edb3708c8c5 | 4480 | cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 4481 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 10:228a52f8107d | 4482 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4483 | } |
whismanoid | 0:3edb3708c8c5 | 4484 | break; |
whismanoid | 0:3edb3708c8c5 | 4485 | case '4': |
whismanoid | 0:3edb3708c8c5 | 4486 | { |
whismanoid | 0:3edb3708c8c5 | 4487 | // recommended for hex command codes 40..4F |
whismanoid | 0:3edb3708c8c5 | 4488 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 4489 | { |
whismanoid | 0:3edb3708c8c5 | 4490 | case '0': |
whismanoid | 0:3edb3708c8c5 | 4491 | { |
whismanoid | 0:3edb3708c8c5 | 4492 | // cmdLine.serial().printf("\r\n 40 ch=? -- POWERn_Normal"); |
whismanoid | 0:3edb3708c8c5 | 4493 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4494 | "channel_dcba=%d, POWERn_Normal)", |
whismanoid | 0:3edb3708c8c5 | 4495 | g_MAX5715_device.channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 4496 | g_MAX5715_device.POWER(g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 4497 | channels_bitmask_DCBA, |
whismanoid | 0:3edb3708c8c5 | 4498 | MAX5715::POWERn_Normal); |
whismanoid | 10:228a52f8107d | 4499 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4500 | } |
whismanoid | 0:3edb3708c8c5 | 4501 | break; |
whismanoid | 0:3edb3708c8c5 | 4502 | case '1': |
whismanoid | 0:3edb3708c8c5 | 4503 | { |
whismanoid | 0:3edb3708c8c5 | 4504 | // cmdLine.serial().printf("\r\n 41 ch=? -- POWERn_PD1k"); |
whismanoid | 0:3edb3708c8c5 | 4505 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4506 | "channel_dcba=%d, POWERn_PD1k)", |
whismanoid | 0:3edb3708c8c5 | 4507 | g_MAX5715_device.channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 4508 | g_MAX5715_device.POWER(g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 4509 | channels_bitmask_DCBA, |
whismanoid | 0:3edb3708c8c5 | 4510 | MAX5715::POWERn_PD1k); |
whismanoid | 10:228a52f8107d | 4511 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4512 | } |
whismanoid | 0:3edb3708c8c5 | 4513 | break; |
whismanoid | 0:3edb3708c8c5 | 4514 | case '2': |
whismanoid | 0:3edb3708c8c5 | 4515 | { |
whismanoid | 0:3edb3708c8c5 | 4516 | // cmdLine.serial().printf("\r\n 42 ch=? -- POWERn_PD100k"); |
whismanoid | 0:3edb3708c8c5 | 4517 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4518 | "channel_dcba=%d, POWERn_PD100k)", |
whismanoid | 0:3edb3708c8c5 | 4519 | g_MAX5715_device.channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 4520 | g_MAX5715_device.POWER(g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 4521 | channels_bitmask_DCBA, |
whismanoid | 0:3edb3708c8c5 | 4522 | MAX5715::POWERn_PD100k); |
whismanoid | 10:228a52f8107d | 4523 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4524 | } |
whismanoid | 0:3edb3708c8c5 | 4525 | break; |
whismanoid | 0:3edb3708c8c5 | 4526 | case '3': |
whismanoid | 0:3edb3708c8c5 | 4527 | { |
whismanoid | 0:3edb3708c8c5 | 4528 | // cmdLine.serial().printf("\r\n 43 ch=? -- POWERn_PDHiZ"); |
whismanoid | 0:3edb3708c8c5 | 4529 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4530 | "channel_dcba=%d, POWERn_PDHiZ)", |
whismanoid | 0:3edb3708c8c5 | 4531 | g_MAX5715_device.channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 4532 | g_MAX5715_device.POWER(g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 4533 | channels_bitmask_DCBA, |
whismanoid | 0:3edb3708c8c5 | 4534 | MAX5715::POWERn_PDHiZ); |
whismanoid | 10:228a52f8107d | 4535 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4536 | } |
whismanoid | 0:3edb3708c8c5 | 4537 | break; |
whismanoid | 0:3edb3708c8c5 | 4538 | } |
whismanoid | 0:3edb3708c8c5 | 4539 | break; |
whismanoid | 0:3edb3708c8c5 | 4540 | } |
whismanoid | 0:3edb3708c8c5 | 4541 | break; |
whismanoid | 0:3edb3708c8c5 | 4542 | case '5': |
whismanoid | 0:3edb3708c8c5 | 4543 | { |
whismanoid | 0:3edb3708c8c5 | 4544 | // recommended for hex command codes 50..5F |
whismanoid | 0:3edb3708c8c5 | 4545 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 4546 | { |
whismanoid | 0:3edb3708c8c5 | 4547 | case '0': |
whismanoid | 0:3edb3708c8c5 | 4548 | { |
whismanoid | 0:3edb3708c8c5 | 4549 | // cmdLine.serial().printf("\r\n 50 -- SW_CLEAR"); |
whismanoid | 0:3edb3708c8c5 | 4550 | cmdLine.serial().printf("SW_CLEAR"); |
whismanoid | 0:3edb3708c8c5 | 4551 | g_MAX5715_device.SW_CLEAR(); |
whismanoid | 10:228a52f8107d | 4552 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4553 | } |
whismanoid | 0:3edb3708c8c5 | 4554 | break; |
whismanoid | 0:3edb3708c8c5 | 4555 | case '1': |
whismanoid | 0:3edb3708c8c5 | 4556 | { |
whismanoid | 0:3edb3708c8c5 | 4557 | // cmdLine.serial().printf("\r\n 51 -- SW_RESET"); |
whismanoid | 0:3edb3708c8c5 | 4558 | cmdLine.serial().printf("SW_RESET"); |
whismanoid | 0:3edb3708c8c5 | 4559 | g_MAX5715_device.SW_RESET(); |
whismanoid | 10:228a52f8107d | 4560 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4561 | } |
whismanoid | 0:3edb3708c8c5 | 4562 | break; |
whismanoid | 0:3edb3708c8c5 | 4563 | } |
whismanoid | 0:3edb3708c8c5 | 4564 | } |
whismanoid | 0:3edb3708c8c5 | 4565 | break; |
whismanoid | 0:3edb3708c8c5 | 4566 | case '6': |
whismanoid | 0:3edb3708c8c5 | 4567 | { |
whismanoid | 0:3edb3708c8c5 | 4568 | // recommended for hex command codes 60..6F |
whismanoid | 0:3edb3708c8c5 | 4569 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 4570 | { |
whismanoid | 0:3edb3708c8c5 | 4571 | case '0': |
whismanoid | 0:3edb3708c8c5 | 4572 | { |
whismanoid | 0:3edb3708c8c5 | 4573 | // cmdLine.serial().printf("\r\n 60 ch=? -- CONFIGn_LATCHED"); |
whismanoid | 0:3edb3708c8c5 | 4574 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4575 | "MAX5715_CONFIGn_LATCHED(channel_dcba=%d)", |
whismanoid | 0:3edb3708c8c5 | 4576 | g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 4577 | channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 4578 | g_MAX5715_device.CONFIGn_LATCHED(g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 4579 | channels_bitmask_DCBA); |
whismanoid | 10:228a52f8107d | 4580 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4581 | } |
whismanoid | 0:3edb3708c8c5 | 4582 | break; |
whismanoid | 0:3edb3708c8c5 | 4583 | case '1': |
whismanoid | 0:3edb3708c8c5 | 4584 | { |
whismanoid | 0:3edb3708c8c5 | 4585 | // cmdLine.serial().printf("\r\n 61 ch=? -- CONFIGn_TRANSPARENT"); |
whismanoid | 0:3edb3708c8c5 | 4586 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4587 | "MAX5715_CONFIGn_TRANSPARENT(channel_dcba=%d)", |
whismanoid | 0:3edb3708c8c5 | 4588 | g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 4589 | channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 4590 | g_MAX5715_device.CONFIGn_TRANSPARENT( |
whismanoid | 0:3edb3708c8c5 | 4591 | g_MAX5715_device.channels_bitmask_DCBA); |
whismanoid | 10:228a52f8107d | 4592 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4593 | } |
whismanoid | 0:3edb3708c8c5 | 4594 | break; |
whismanoid | 0:3edb3708c8c5 | 4595 | case '8': |
whismanoid | 0:3edb3708c8c5 | 4596 | { |
whismanoid | 0:3edb3708c8c5 | 4597 | // cmdLine.serial().printf("\r\n 68 -- CONFIGall_LATCHED"); |
whismanoid | 0:3edb3708c8c5 | 4598 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4599 | "MAX5715_CONFIGall_LATCHED()"); |
whismanoid | 0:3edb3708c8c5 | 4600 | g_MAX5715_device.CONFIGall_LATCHED(); |
whismanoid | 10:228a52f8107d | 4601 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4602 | } |
whismanoid | 0:3edb3708c8c5 | 4603 | break; |
whismanoid | 0:3edb3708c8c5 | 4604 | case '9': |
whismanoid | 0:3edb3708c8c5 | 4605 | { |
whismanoid | 0:3edb3708c8c5 | 4606 | // cmdLine.serial().printf("\r\n 69 -- CONFIGall_TRANSPARENT"); |
whismanoid | 0:3edb3708c8c5 | 4607 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4608 | "MAX5715_CONFIGall_TRANSPARENT()"); |
whismanoid | 0:3edb3708c8c5 | 4609 | g_MAX5715_device.CONFIGall_TRANSPARENT(); |
whismanoid | 10:228a52f8107d | 4610 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4611 | } |
whismanoid | 0:3edb3708c8c5 | 4612 | break; |
whismanoid | 0:3edb3708c8c5 | 4613 | } |
whismanoid | 0:3edb3708c8c5 | 4614 | } |
whismanoid | 0:3edb3708c8c5 | 4615 | break; |
whismanoid | 0:3edb3708c8c5 | 4616 | case '7': |
whismanoid | 0:3edb3708c8c5 | 4617 | { |
whismanoid | 0:3edb3708c8c5 | 4618 | // recommended for hex command codes 70..7F |
whismanoid | 0:3edb3708c8c5 | 4619 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 4620 | { |
whismanoid | 0:3edb3708c8c5 | 4621 | case '0': |
whismanoid | 0:3edb3708c8c5 | 4622 | { |
whismanoid | 0:3edb3708c8c5 | 4623 | // cmdLine.serial().printf("\r\n 70 -- REF_EXT"); |
whismanoid | 0:3edb3708c8c5 | 4624 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4625 | "MAX5715_REF(REF_EXT)"); |
whismanoid | 0:3edb3708c8c5 | 4626 | g_MAX5715_device.REF(MAX5715::REF_EXT); |
whismanoid | 10:228a52f8107d | 4627 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4628 | } |
whismanoid | 0:3edb3708c8c5 | 4629 | break; |
whismanoid | 0:3edb3708c8c5 | 4630 | case '1': |
whismanoid | 0:3edb3708c8c5 | 4631 | { |
whismanoid | 0:3edb3708c8c5 | 4632 | // cmdLine.serial().printf("\r\n 71 -- REF_2V500"); |
whismanoid | 0:3edb3708c8c5 | 4633 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4634 | "MAX5715_REF(REF_2V500)"); |
whismanoid | 0:3edb3708c8c5 | 4635 | g_MAX5715_device.REF(MAX5715::REF_2V500); |
whismanoid | 10:228a52f8107d | 4636 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4637 | } |
whismanoid | 0:3edb3708c8c5 | 4638 | break; |
whismanoid | 0:3edb3708c8c5 | 4639 | case '2': |
whismanoid | 0:3edb3708c8c5 | 4640 | { |
whismanoid | 0:3edb3708c8c5 | 4641 | // cmdLine.serial().printf("\r\n 72 -- REF_2V048"); |
whismanoid | 0:3edb3708c8c5 | 4642 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4643 | "MAX5715_REF(REF_2V048)"); |
whismanoid | 0:3edb3708c8c5 | 4644 | g_MAX5715_device.REF(MAX5715::REF_2V048); |
whismanoid | 10:228a52f8107d | 4645 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4646 | } |
whismanoid | 0:3edb3708c8c5 | 4647 | break; |
whismanoid | 0:3edb3708c8c5 | 4648 | case '3': |
whismanoid | 0:3edb3708c8c5 | 4649 | { |
whismanoid | 0:3edb3708c8c5 | 4650 | // cmdLine.serial().printf("\r\n 73 -- REF_4V096"); |
whismanoid | 0:3edb3708c8c5 | 4651 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4652 | "MAX5715_REF(REF_4V096)"); |
whismanoid | 0:3edb3708c8c5 | 4653 | g_MAX5715_device.REF(MAX5715::REF_4V096); |
whismanoid | 10:228a52f8107d | 4654 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4655 | } |
whismanoid | 0:3edb3708c8c5 | 4656 | break; |
whismanoid | 0:3edb3708c8c5 | 4657 | case '4': |
whismanoid | 0:3edb3708c8c5 | 4658 | { |
whismanoid | 0:3edb3708c8c5 | 4659 | // cmdLine.serial().printf("\r\n 74 -- REF_AlwaysOn_EXT"); |
whismanoid | 0:3edb3708c8c5 | 4660 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4661 | "MAX5715_REF(REF_AlwaysOn_EXT)"); |
whismanoid | 0:3edb3708c8c5 | 4662 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_EXT); |
whismanoid | 10:228a52f8107d | 4663 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4664 | } |
whismanoid | 0:3edb3708c8c5 | 4665 | break; |
whismanoid | 0:3edb3708c8c5 | 4666 | case '5': |
whismanoid | 0:3edb3708c8c5 | 4667 | { |
whismanoid | 0:3edb3708c8c5 | 4668 | // cmdLine.serial().printf("\r\n 75 -- REF_AlwaysOn_2V500"); |
whismanoid | 0:3edb3708c8c5 | 4669 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4670 | "MAX5715_REF(REF_AlwaysOn_2V500)"); |
whismanoid | 0:3edb3708c8c5 | 4671 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); |
whismanoid | 10:228a52f8107d | 4672 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4673 | } |
whismanoid | 0:3edb3708c8c5 | 4674 | break; |
whismanoid | 0:3edb3708c8c5 | 4675 | case '6': |
whismanoid | 0:3edb3708c8c5 | 4676 | { |
whismanoid | 0:3edb3708c8c5 | 4677 | // cmdLine.serial().printf("\r\n 76 -- REF_AlwaysOn_2V048"); |
whismanoid | 0:3edb3708c8c5 | 4678 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4679 | "MAX5715_REF(REF_AlwaysOn_2V048)"); |
whismanoid | 0:3edb3708c8c5 | 4680 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048); |
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 '7': |
whismanoid | 0:3edb3708c8c5 | 4685 | { |
whismanoid | 0:3edb3708c8c5 | 4686 | // cmdLine.serial().printf("\r\n 77 -- REF_AlwaysOn_4V096"); |
whismanoid | 0:3edb3708c8c5 | 4687 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4688 | "MAX5715_REF(REF_AlwaysOn_4V096)"); |
whismanoid | 0:3edb3708c8c5 | 4689 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_4V096); |
whismanoid | 10:228a52f8107d | 4690 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4691 | } |
whismanoid | 0:3edb3708c8c5 | 4692 | break; |
whismanoid | 0:3edb3708c8c5 | 4693 | } |
whismanoid | 0:3edb3708c8c5 | 4694 | } |
whismanoid | 0:3edb3708c8c5 | 4695 | break; |
whismanoid | 0:3edb3708c8c5 | 4696 | case '8': |
whismanoid | 0:3edb3708c8c5 | 4697 | { |
whismanoid | 0:3edb3708c8c5 | 4698 | // recommended for hex command codes 80..8F |
whismanoid | 0:3edb3708c8c5 | 4699 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 4700 | { |
whismanoid | 0:3edb3708c8c5 | 4701 | case '0': |
whismanoid | 0:3edb3708c8c5 | 4702 | { |
whismanoid | 0:3edb3708c8c5 | 4703 | // TODO: cmdLine.serial().printf("\r\n 80 code=? -- CODEall"); |
whismanoid | 0:3edb3708c8c5 | 4704 | // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 4705 | g_MAX5715_device.channels_bitmask_DCBA = 0xFF; // store g_MAX5715_device.CODE[allChannels] |
whismanoid | 0:3edb3708c8c5 | 4706 | uint16_t code = g_MAX5715_device.CODE[0]; |
whismanoid | 0:3edb3708c8c5 | 4707 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 4708 | { |
whismanoid | 0:3edb3708c8c5 | 4709 | } |
whismanoid | 0:3edb3708c8c5 | 4710 | cmdLine.serial().printf("CODEall code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 4711 | g_MAX5715_device.CODEall(code); |
whismanoid | 10:228a52f8107d | 4712 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4713 | } |
whismanoid | 0:3edb3708c8c5 | 4714 | break; |
whismanoid | 0:3edb3708c8c5 | 4715 | case '1': |
whismanoid | 0:3edb3708c8c5 | 4716 | { |
whismanoid | 0:3edb3708c8c5 | 4717 | // TODO: cmdLine.serial().printf("\r\n 81 -- LOADall"); |
whismanoid | 0:3edb3708c8c5 | 4718 | cmdLine.serial().printf("LOADall"); |
whismanoid | 0:3edb3708c8c5 | 4719 | g_MAX5715_device.LOADall(); |
whismanoid | 10:228a52f8107d | 4720 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4721 | } |
whismanoid | 0:3edb3708c8c5 | 4722 | break; |
whismanoid | 0:3edb3708c8c5 | 4723 | case '2': |
whismanoid | 0:3edb3708c8c5 | 4724 | { |
whismanoid | 0:3edb3708c8c5 | 4725 | // TODO: cmdLine.serial().printf("\r\n 82 code=? -- CODEallLOADall"); |
whismanoid | 0:3edb3708c8c5 | 4726 | uint16_t code = g_MAX5715_device.CODE[0]; |
whismanoid | 0:3edb3708c8c5 | 4727 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 4728 | { |
whismanoid | 0:3edb3708c8c5 | 4729 | } |
whismanoid | 0:3edb3708c8c5 | 4730 | cmdLine.serial().printf("CODEallLOADall code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 4731 | g_MAX5715_device.CODEallLOADall(code); |
whismanoid | 10:228a52f8107d | 4732 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4733 | } |
whismanoid | 0:3edb3708c8c5 | 4734 | break; |
whismanoid | 0:3edb3708c8c5 | 4735 | } |
whismanoid | 0:3edb3708c8c5 | 4736 | } |
whismanoid | 0:3edb3708c8c5 | 4737 | break; |
whismanoid | 0:3edb3708c8c5 | 4738 | case '9': |
whismanoid | 0:3edb3708c8c5 | 4739 | { |
whismanoid | 0:3edb3708c8c5 | 4740 | // recommended for hex command codes 90..9F |
whismanoid | 0:3edb3708c8c5 | 4741 | } |
whismanoid | 0:3edb3708c8c5 | 4742 | break; |
whismanoid | 0:3edb3708c8c5 | 4743 | case 'a': case 'A': |
whismanoid | 0:3edb3708c8c5 | 4744 | { |
whismanoid | 0:3edb3708c8c5 | 4745 | // recommended for hex command codes A0..AF |
whismanoid | 0:3edb3708c8c5 | 4746 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 4747 | { |
whismanoid | 0:3edb3708c8c5 | 4748 | case 't': case 'T': |
whismanoid | 0:3edb3708c8c5 | 4749 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 4750 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 4751 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 4752 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 4753 | // AT command: skip the prompt to avoid confusing modem detector |
whismanoid | 10:228a52f8107d | 4754 | return false; // command not handled |
whismanoid | 0:3edb3708c8c5 | 4755 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 4756 | } |
whismanoid | 0:3edb3708c8c5 | 4757 | } |
whismanoid | 0:3edb3708c8c5 | 4758 | break; |
whismanoid | 0:3edb3708c8c5 | 4759 | case 'b': case 'B': |
whismanoid | 0:3edb3708c8c5 | 4760 | { |
whismanoid | 0:3edb3708c8c5 | 4761 | // recommended for hex command codes B0..BF |
whismanoid | 0:3edb3708c8c5 | 4762 | } |
whismanoid | 0:3edb3708c8c5 | 4763 | break; |
whismanoid | 0:3edb3708c8c5 | 4764 | case 'c': case 'C': |
whismanoid | 0:3edb3708c8c5 | 4765 | { |
whismanoid | 0:3edb3708c8c5 | 4766 | // recommended for hex command codes C0..CF |
whismanoid | 0:3edb3708c8c5 | 4767 | // // MAX5717 menu function to drive MAX5717_CLRb_Pin CLR# |
whismanoid | 0:3edb3708c8c5 | 4768 | // cmdLine.serial().printf("\r\n C -- CLR# pulse CH high CL low"); |
whismanoid | 0:3edb3708c8c5 | 4769 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 4770 | { |
whismanoid | 0:3edb3708c8c5 | 4771 | default: |
whismanoid | 0:3edb3708c8c5 | 4772 | // g_MAX5715_device.CLRboutputPulseLow(); |
whismanoid | 0:3edb3708c8c5 | 4773 | g_MAX5715_device.CLRboutputValue(1); |
whismanoid | 0:3edb3708c8c5 | 4774 | g_MAX5715_device.CLRboutputValue(0); |
whismanoid | 0:3edb3708c8c5 | 4775 | g_MAX5715_device.CLRboutputValue(1); |
whismanoid | 0:3edb3708c8c5 | 4776 | break; |
whismanoid | 0:3edb3708c8c5 | 4777 | case 'H': case 'h': case '1': |
whismanoid | 0:3edb3708c8c5 | 4778 | g_MAX5715_device.CLRboutputValue(1); // GPIOoutputCLRb(int isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 4779 | break; |
whismanoid | 0:3edb3708c8c5 | 4780 | case 'L': case 'l': case '0': |
whismanoid | 0:3edb3708c8c5 | 4781 | g_MAX5715_device.CLRboutputValue(0); // GPIOoutputCLRb(int isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 4782 | break; |
whismanoid | 0:3edb3708c8c5 | 4783 | } |
whismanoid | 10:228a52f8107d | 4784 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4785 | } |
whismanoid | 0:3edb3708c8c5 | 4786 | break; |
whismanoid | 0:3edb3708c8c5 | 4787 | case 'd': case 'D': |
whismanoid | 0:3edb3708c8c5 | 4788 | { |
whismanoid | 0:3edb3708c8c5 | 4789 | // recommended for hex command codes D0..DF |
whismanoid | 0:3edb3708c8c5 | 4790 | } |
whismanoid | 0:3edb3708c8c5 | 4791 | break; |
whismanoid | 0:3edb3708c8c5 | 4792 | case 'e': case 'E': |
whismanoid | 0:3edb3708c8c5 | 4793 | { |
whismanoid | 0:3edb3708c8c5 | 4794 | // recommended for hex command codes E0..EF |
whismanoid | 0:3edb3708c8c5 | 4795 | } |
whismanoid | 0:3edb3708c8c5 | 4796 | break; |
whismanoid | 0:3edb3708c8c5 | 4797 | case 'f': case 'F': |
whismanoid | 0:3edb3708c8c5 | 4798 | { |
whismanoid | 0:3edb3708c8c5 | 4799 | // recommended for hex command codes F0..FF |
whismanoid | 0:3edb3708c8c5 | 4800 | } |
whismanoid | 0:3edb3708c8c5 | 4801 | break; |
whismanoid | 0:3edb3708c8c5 | 4802 | case 'l': case 'L': |
whismanoid | 0:3edb3708c8c5 | 4803 | { |
whismanoid | 0:3edb3708c8c5 | 4804 | // // MAX5717 menu function to drive MAX5717_LDACb_Pin LDAC# |
whismanoid | 0:3edb3708c8c5 | 4805 | // cmdLine.serial().printf("\r\n L -- LDAC# pulse LH high LL low"); |
whismanoid | 0:3edb3708c8c5 | 4806 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 4807 | { |
whismanoid | 0:3edb3708c8c5 | 4808 | default: |
whismanoid | 0:3edb3708c8c5 | 4809 | // g_MAX5715_device.LDACboutputPulseLow(); |
whismanoid | 0:3edb3708c8c5 | 4810 | g_MAX5715_device.LDACboutputValue(1); |
whismanoid | 0:3edb3708c8c5 | 4811 | g_MAX5715_device.LDACboutputValue(0); |
whismanoid | 0:3edb3708c8c5 | 4812 | g_MAX5715_device.LDACboutputValue(1); |
whismanoid | 0:3edb3708c8c5 | 4813 | break; |
whismanoid | 0:3edb3708c8c5 | 4814 | case 'H': case 'h': case '1': |
whismanoid | 0:3edb3708c8c5 | 4815 | g_MAX5715_device.LDACboutputValue(1); // GPIOoutputLDACb(int isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 4816 | break; |
whismanoid | 0:3edb3708c8c5 | 4817 | case 'L': case 'l': case '0': |
whismanoid | 0:3edb3708c8c5 | 4818 | g_MAX5715_device.LDACboutputValue(0); // GPIOoutputLDACb(int isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 4819 | break; |
whismanoid | 0:3edb3708c8c5 | 4820 | } |
whismanoid | 10:228a52f8107d | 4821 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4822 | } |
whismanoid | 0:3edb3708c8c5 | 4823 | break; |
whismanoid | 0:3edb3708c8c5 | 4824 | case 'x': case 'X': |
whismanoid | 0:3edb3708c8c5 | 4825 | { |
whismanoid | 0:3edb3708c8c5 | 4826 | } |
whismanoid | 0:3edb3708c8c5 | 4827 | break; |
whismanoid | 0:3edb3708c8c5 | 4828 | case 'y': case 'Y': |
whismanoid | 0:3edb3708c8c5 | 4829 | { |
whismanoid | 0:3edb3708c8c5 | 4830 | } |
whismanoid | 0:3edb3708c8c5 | 4831 | break; |
whismanoid | 0:3edb3708c8c5 | 4832 | case 'z': case 'Z': |
whismanoid | 0:3edb3708c8c5 | 4833 | { |
whismanoid | 0:3edb3708c8c5 | 4834 | } |
whismanoid | 0:3edb3708c8c5 | 4835 | break; |
whismanoid | 0:3edb3708c8c5 | 4836 | case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command |
whismanoid | 0:3edb3708c8c5 | 4837 | { |
whismanoid | 0:3edb3708c8c5 | 4838 | // TODO: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 4839 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 4840 | { |
whismanoid | 0:3edb3708c8c5 | 4841 | default: |
whismanoid | 0:3edb3708c8c5 | 4842 | { |
whismanoid | 0:3edb3708c8c5 | 4843 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 4844 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 4845 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", |
whismanoid | 0:3edb3708c8c5 | 4846 | cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 4847 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 4848 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 4849 | } |
whismanoid | 0:3edb3708c8c5 | 4850 | } |
whismanoid | 0:3edb3708c8c5 | 4851 | } |
whismanoid | 0:3edb3708c8c5 | 4852 | break; |
whismanoid | 0:3edb3708c8c5 | 4853 | case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command |
whismanoid | 0:3edb3708c8c5 | 4854 | { |
whismanoid | 0:3edb3708c8c5 | 4855 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 4856 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 4857 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 4858 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 4859 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 4860 | } |
whismanoid | 0:3edb3708c8c5 | 4861 | break; |
whismanoid | 0:3edb3708c8c5 | 4862 | case '@': |
whismanoid | 0:3edb3708c8c5 | 4863 | { |
whismanoid | 0:3edb3708c8c5 | 4864 | // // |
whismanoid | 0:3edb3708c8c5 | 4865 | // // Menu @ -- print device configuration |
whismanoid | 0:3edb3708c8c5 | 4866 | // TODO: cmdLine.serial().printf("\r\n @ -- print MAX5715 configuration"); |
whismanoid | 0:3edb3708c8c5 | 4867 | // // |
whismanoid | 0:3edb3708c8c5 | 4868 | // print shadow register configuration |
whismanoid | 0:3edb3708c8c5 | 4869 | // |
whismanoid | 0:3edb3708c8c5 | 4870 | // shadow of write-only register CODE dddd_dddd_dddd_0000 |
whismanoid | 0:3edb3708c8c5 | 4871 | //~ int16_t CMD_1000_CODE; |
whismanoid | 0:3edb3708c8c5 | 4872 | int index = 0; |
whismanoid | 0:3edb3708c8c5 | 4873 | for (index = 0; index < 4; index++) |
whismanoid | 0:3edb3708c8c5 | 4874 | { |
whismanoid | 0:3edb3708c8c5 | 4875 | cmdLine.serial().printf("CODE %c=0x%4.4x MAX5715_VoltageOfCode(%d)=%5.3fV\r\n", |
whismanoid | 0:3edb3708c8c5 | 4876 | (char)('A' + index), |
whismanoid | 0:3edb3708c8c5 | 4877 | (g_MAX5715_device.Shadow_0010_nnnn_CODE[index] & 0xFFFF), |
whismanoid | 0:3edb3708c8c5 | 4878 | g_MAX5715_device.CODE[index], |
whismanoid | 0:3edb3708c8c5 | 4879 | g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[index]) |
whismanoid | 0:3edb3708c8c5 | 4880 | ); |
whismanoid | 0:3edb3708c8c5 | 4881 | } |
whismanoid | 0:3edb3708c8c5 | 4882 | // |
whismanoid | 0:3edb3708c8c5 | 4883 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4884 | // |
whismanoid | 0:3edb3708c8c5 | 4885 | // |
whismanoid | 0:3edb3708c8c5 | 4886 | // Menu @) print MAX5715 configuration AND g_MAX5715_device globals |
whismanoid | 0:3edb3708c8c5 | 4887 | // |
whismanoid | 0:3edb3708c8c5 | 4888 | #if 1 // SUPPORT_CHANNELS |
whismanoid | 0:3edb3708c8c5 | 4889 | cmdLine.serial().printf("channelNumber_0_3=%d channels_bitmask_DCBA=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 4890 | (g_MAX5715_device.channelNumber_0_3 & 0xFFFF), |
whismanoid | 0:3edb3708c8c5 | 4891 | (g_MAX5715_device.channels_bitmask_DCBA & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 4892 | #endif // SUPPORT_CHANNELS |
whismanoid | 0:3edb3708c8c5 | 4893 | // |
whismanoid | 0:3edb3708c8c5 | 4894 | cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX5715_device.VRef); |
whismanoid | 0:3edb3708c8c5 | 4895 | // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB |
whismanoid | 10:228a52f8107d | 4896 | return true; // command was handled by MAX5715 |
whismanoid | 0:3edb3708c8c5 | 4897 | } |
whismanoid | 0:3edb3708c8c5 | 4898 | break; |
whismanoid | 10:228a52f8107d | 4899 | } // end switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 4900 | return false; // command not handled by MAX5715 |
whismanoid | 10:228a52f8107d | 4901 | } // end bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 4902 | #endif |
whismanoid | 0:3edb3708c8c5 | 4903 | |
whismanoid | 10:228a52f8107d | 4904 | //-------------------------------------------------- |
whismanoid | 10:228a52f8107d | 4905 | #if 0 // APPLICATION_MAX11131 // MAX11131_menu_onEOLcommandParser moved to Test_Menu_MAX11131.cpp |
whismanoid | 10:228a52f8107d | 4906 | bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 4907 | { |
whismanoid | 10:228a52f8107d | 4908 | switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 4909 | { |
whismanoid | 0:3edb3708c8c5 | 4910 | case '0': |
whismanoid | 0:3edb3708c8c5 | 4911 | { |
whismanoid | 0:3edb3708c8c5 | 4912 | // recommended for hex command codes 00..0F |
whismanoid | 0:3edb3708c8c5 | 4913 | // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void); |
whismanoid | 0:3edb3708c8c5 | 4914 | // TODO: cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead"); |
whismanoid | 0:3edb3708c8c5 | 4915 | if (cmdLine.parse_uint16_dec("n", g_MAX11131_device.NumWords)) |
whismanoid | 0:3edb3708c8c5 | 4916 | { |
whismanoid | 0:3edb3708c8c5 | 4917 | } |
whismanoid | 0:3edb3708c8c5 | 4918 | cmdLine.serial().printf("ScanRead NumWords=%d", g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4919 | if (g_MAX11131_device.isExternalClock) |
whismanoid | 0:3edb3708c8c5 | 4920 | { |
whismanoid | 0:3edb3708c8c5 | 4921 | cmdLine.serial().printf(" External Clock"); |
whismanoid | 0:3edb3708c8c5 | 4922 | // |
whismanoid | 0:3edb3708c8c5 | 4923 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 4924 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 4925 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 4926 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 4927 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 4928 | // |
whismanoid | 0:3edb3708c8c5 | 4929 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4930 | } |
whismanoid | 0:3edb3708c8c5 | 4931 | else |
whismanoid | 0:3edb3708c8c5 | 4932 | { |
whismanoid | 0:3edb3708c8c5 | 4933 | cmdLine.serial().printf(" Internal Clock"); |
whismanoid | 0:3edb3708c8c5 | 4934 | // |
whismanoid | 0:3edb3708c8c5 | 4935 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 4936 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 4937 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 4938 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 4939 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 4940 | // |
whismanoid | 0:3edb3708c8c5 | 4941 | AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4942 | } |
whismanoid | 10:228a52f8107d | 4943 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 4944 | } |
whismanoid | 0:3edb3708c8c5 | 4945 | break; |
whismanoid | 0:3edb3708c8c5 | 4946 | case '1': |
whismanoid | 0:3edb3708c8c5 | 4947 | { |
whismanoid | 0:3edb3708c8c5 | 4948 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 4949 | // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 4950 | // TODO: cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual"); |
whismanoid | 0:3edb3708c8c5 | 4951 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 4952 | { |
whismanoid | 0:3edb3708c8c5 | 4953 | } |
whismanoid | 0:3edb3708c8c5 | 4954 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 4955 | { |
whismanoid | 0:3edb3708c8c5 | 4956 | } |
whismanoid | 0:3edb3708c8c5 | 4957 | if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) |
whismanoid | 0:3edb3708c8c5 | 4958 | { |
whismanoid | 0:3edb3708c8c5 | 4959 | } |
whismanoid | 0:3edb3708c8c5 | 4960 | cmdLine.serial().printf("ScanManual ch=%d pm=%d id=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 4961 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 4962 | g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 4963 | g_MAX11131_device.chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 4964 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 4965 | // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 4966 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 4967 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); |
whismanoid | 0:3edb3708c8c5 | 4968 | // |
whismanoid | 0:3edb3708c8c5 | 4969 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 4970 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 4971 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 4972 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 4973 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 4974 | // |
whismanoid | 0:3edb3708c8c5 | 4975 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 10:228a52f8107d | 4976 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 4977 | } |
whismanoid | 0:3edb3708c8c5 | 4978 | break; |
whismanoid | 0:3edb3708c8c5 | 4979 | case '2': |
whismanoid | 0:3edb3708c8c5 | 4980 | { |
whismanoid | 0:3edb3708c8c5 | 4981 | // recommended for hex command codes 20..2F |
whismanoid | 0:3edb3708c8c5 | 4982 | // 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 | 4983 | // TODO: cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat"); |
whismanoid | 0:3edb3708c8c5 | 4984 | // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 4985 | // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 4986 | // VERIFY: update value of g_MAX11131_device.nscan_4_8_12_16 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 4987 | // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 4988 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 4989 | // VERIFY: parse strCommandArgs for additional arguments including key=value pairs |
whismanoid | 0:3edb3708c8c5 | 4990 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 4991 | { |
whismanoid | 0:3edb3708c8c5 | 4992 | } |
whismanoid | 0:3edb3708c8c5 | 4993 | if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) |
whismanoid | 0:3edb3708c8c5 | 4994 | { |
whismanoid | 0:3edb3708c8c5 | 4995 | } |
whismanoid | 0:3edb3708c8c5 | 4996 | if (cmdLine.parse_byte_dec("n", g_MAX11131_device.nscan_4_8_12_16)) |
whismanoid | 0:3edb3708c8c5 | 4997 | { |
whismanoid | 0:3edb3708c8c5 | 4998 | } |
whismanoid | 0:3edb3708c8c5 | 4999 | if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) |
whismanoid | 0:3edb3708c8c5 | 5000 | { |
whismanoid | 0:3edb3708c8c5 | 5001 | } |
whismanoid | 0:3edb3708c8c5 | 5002 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 5003 | { |
whismanoid | 0:3edb3708c8c5 | 5004 | } |
whismanoid | 0:3edb3708c8c5 | 5005 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 5006 | "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 | 5007 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 5008 | g_MAX11131_device.average_0_4_8_16_32, |
whismanoid | 0:3edb3708c8c5 | 5009 | g_MAX11131_device.nscan_4_8_12_16, |
whismanoid | 0:3edb3708c8c5 | 5010 | g_MAX11131_device.swcnv_0_1, |
whismanoid | 0:3edb3708c8c5 | 5011 | g_MAX11131_device.PowerManagement_0_2); |
whismanoid | 0:3edb3708c8c5 | 5012 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 5013 | // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 |
whismanoid | 0:3edb3708c8c5 | 5014 | // VERIFY: replace argument with driver global; g_MAX11131_device.nscan_4_8_12_16 replaces nscan_4_8_12_16 |
whismanoid | 0:3edb3708c8c5 | 5015 | // 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 | 5016 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 5017 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanRepeat(); |
whismanoid | 0:3edb3708c8c5 | 5018 | // |
whismanoid | 0:3edb3708c8c5 | 5019 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 5020 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 5021 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 5022 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 5023 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 5024 | // |
whismanoid | 0:3edb3708c8c5 | 5025 | AINcode_print_value_chanID_mean(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 10:228a52f8107d | 5026 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5027 | } |
whismanoid | 0:3edb3708c8c5 | 5028 | break; |
whismanoid | 0:3edb3708c8c5 | 5029 | case '3': |
whismanoid | 0:3edb3708c8c5 | 5030 | { |
whismanoid | 0:3edb3708c8c5 | 5031 | // recommended for hex command codes 30..3F |
whismanoid | 0:3edb3708c8c5 | 5032 | // 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 | 5033 | // TODO: cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock"); |
whismanoid | 0:3edb3708c8c5 | 5034 | // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5035 | // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5036 | // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5037 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5038 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 5039 | { |
whismanoid | 0:3edb3708c8c5 | 5040 | } |
whismanoid | 0:3edb3708c8c5 | 5041 | if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) |
whismanoid | 0:3edb3708c8c5 | 5042 | { |
whismanoid | 0:3edb3708c8c5 | 5043 | } |
whismanoid | 0:3edb3708c8c5 | 5044 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 5045 | { |
whismanoid | 0:3edb3708c8c5 | 5046 | } |
whismanoid | 0:3edb3708c8c5 | 5047 | if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) |
whismanoid | 0:3edb3708c8c5 | 5048 | { |
whismanoid | 0:3edb3708c8c5 | 5049 | } |
whismanoid | 0:3edb3708c8c5 | 5050 | cmdLine.serial().printf("ScanStandardInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 5051 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 5052 | g_MAX11131_device.average_0_4_8_16_32, |
whismanoid | 0:3edb3708c8c5 | 5053 | g_MAX11131_device.swcnv_0_1, |
whismanoid | 0:3edb3708c8c5 | 5054 | g_MAX11131_device.PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 5055 | ); |
whismanoid | 0:3edb3708c8c5 | 5056 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 5057 | // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 |
whismanoid | 0:3edb3708c8c5 | 5058 | // 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 | 5059 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 5060 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardInternalClock(); |
whismanoid | 0:3edb3708c8c5 | 5061 | // |
whismanoid | 0:3edb3708c8c5 | 5062 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 5063 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 5064 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 5065 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 5066 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 5067 | // |
whismanoid | 0:3edb3708c8c5 | 5068 | AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 10:228a52f8107d | 5069 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5070 | } |
whismanoid | 0:3edb3708c8c5 | 5071 | break; |
whismanoid | 0:3edb3708c8c5 | 5072 | case '4': |
whismanoid | 0:3edb3708c8c5 | 5073 | { |
whismanoid | 0:3edb3708c8c5 | 5074 | // recommended for hex command codes 40..4F |
whismanoid | 0:3edb3708c8c5 | 5075 | // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 5076 | // TODO: cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock"); |
whismanoid | 0:3edb3708c8c5 | 5077 | // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5078 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5079 | // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5080 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 5081 | { |
whismanoid | 0:3edb3708c8c5 | 5082 | } |
whismanoid | 0:3edb3708c8c5 | 5083 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 5084 | { |
whismanoid | 0:3edb3708c8c5 | 5085 | } |
whismanoid | 0:3edb3708c8c5 | 5086 | if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) |
whismanoid | 0:3edb3708c8c5 | 5087 | { |
whismanoid | 0:3edb3708c8c5 | 5088 | } |
whismanoid | 0:3edb3708c8c5 | 5089 | cmdLine.serial().printf("ScanStandardExternalClock ch=%d pm=%d id=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 5090 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 5091 | g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 5092 | g_MAX11131_device.chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 5093 | ); |
whismanoid | 0:3edb3708c8c5 | 5094 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 5095 | // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 5096 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 5097 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 5098 | // |
whismanoid | 0:3edb3708c8c5 | 5099 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 5100 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 5101 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 5102 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 5103 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 5104 | // |
whismanoid | 0:3edb3708c8c5 | 5105 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 10:228a52f8107d | 5106 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5107 | } |
whismanoid | 0:3edb3708c8c5 | 5108 | break; |
whismanoid | 0:3edb3708c8c5 | 5109 | case '5': |
whismanoid | 0:3edb3708c8c5 | 5110 | { |
whismanoid | 0:3edb3708c8c5 | 5111 | // recommended for hex command codes 50..5F |
whismanoid | 0:3edb3708c8c5 | 5112 | // 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 | 5113 | // TODO: cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock"); |
whismanoid | 0:3edb3708c8c5 | 5114 | // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5115 | // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5116 | // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5117 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5118 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 5119 | { |
whismanoid | 0:3edb3708c8c5 | 5120 | } |
whismanoid | 0:3edb3708c8c5 | 5121 | if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) |
whismanoid | 0:3edb3708c8c5 | 5122 | { |
whismanoid | 0:3edb3708c8c5 | 5123 | } |
whismanoid | 0:3edb3708c8c5 | 5124 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 5125 | { |
whismanoid | 0:3edb3708c8c5 | 5126 | } |
whismanoid | 0:3edb3708c8c5 | 5127 | if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) |
whismanoid | 0:3edb3708c8c5 | 5128 | { |
whismanoid | 0:3edb3708c8c5 | 5129 | } |
whismanoid | 0:3edb3708c8c5 | 5130 | cmdLine.serial().printf("ScanUpperInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 5131 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 5132 | g_MAX11131_device.average_0_4_8_16_32, |
whismanoid | 0:3edb3708c8c5 | 5133 | g_MAX11131_device.swcnv_0_1, |
whismanoid | 0:3edb3708c8c5 | 5134 | g_MAX11131_device.PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 5135 | ); |
whismanoid | 0:3edb3708c8c5 | 5136 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 5137 | // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 |
whismanoid | 0:3edb3708c8c5 | 5138 | // 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 | 5139 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 5140 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperInternalClock(); |
whismanoid | 0:3edb3708c8c5 | 5141 | // |
whismanoid | 0:3edb3708c8c5 | 5142 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 5143 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 5144 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 5145 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 5146 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 5147 | // |
whismanoid | 0:3edb3708c8c5 | 5148 | AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 10:228a52f8107d | 5149 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5150 | } |
whismanoid | 0:3edb3708c8c5 | 5151 | break; |
whismanoid | 0:3edb3708c8c5 | 5152 | case '6': |
whismanoid | 0:3edb3708c8c5 | 5153 | { |
whismanoid | 0:3edb3708c8c5 | 5154 | // recommended for hex command codes 60..6F |
whismanoid | 0:3edb3708c8c5 | 5155 | // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 5156 | // TODO: cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock"); |
whismanoid | 0:3edb3708c8c5 | 5157 | // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5158 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5159 | // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5160 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 5161 | { |
whismanoid | 0:3edb3708c8c5 | 5162 | } |
whismanoid | 0:3edb3708c8c5 | 5163 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 5164 | { |
whismanoid | 0:3edb3708c8c5 | 5165 | } |
whismanoid | 0:3edb3708c8c5 | 5166 | if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) |
whismanoid | 0:3edb3708c8c5 | 5167 | { |
whismanoid | 0:3edb3708c8c5 | 5168 | } |
whismanoid | 0:3edb3708c8c5 | 5169 | cmdLine.serial().printf("ScanUpperExternalClock ch=%d pm=%d id=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 5170 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 5171 | g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 5172 | g_MAX11131_device.chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 5173 | ); |
whismanoid | 0:3edb3708c8c5 | 5174 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 5175 | // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 5176 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 5177 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 5178 | // |
whismanoid | 0:3edb3708c8c5 | 5179 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 5180 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 5181 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 5182 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 5183 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 5184 | // |
whismanoid | 0:3edb3708c8c5 | 5185 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 10:228a52f8107d | 5186 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5187 | } |
whismanoid | 0:3edb3708c8c5 | 5188 | break; |
whismanoid | 0:3edb3708c8c5 | 5189 | case '7': |
whismanoid | 0:3edb3708c8c5 | 5190 | { |
whismanoid | 0:3edb3708c8c5 | 5191 | // recommended for hex command codes 70..7F |
whismanoid | 0:3edb3708c8c5 | 5192 | // 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 | 5193 | // TODO: cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock"); |
whismanoid | 0:3edb3708c8c5 | 5194 | // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5195 | // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5196 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5197 | if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask)) |
whismanoid | 0:3edb3708c8c5 | 5198 | { |
whismanoid | 0:3edb3708c8c5 | 5199 | // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5200 | } |
whismanoid | 0:3edb3708c8c5 | 5201 | if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) |
whismanoid | 0:3edb3708c8c5 | 5202 | { |
whismanoid | 0:3edb3708c8c5 | 5203 | } |
whismanoid | 0:3edb3708c8c5 | 5204 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 5205 | { |
whismanoid | 0:3edb3708c8c5 | 5206 | } |
whismanoid | 0:3edb3708c8c5 | 5207 | if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) |
whismanoid | 0:3edb3708c8c5 | 5208 | { |
whismanoid | 0:3edb3708c8c5 | 5209 | } |
whismanoid | 0:3edb3708c8c5 | 5210 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 5211 | "ScanCustomInternalClock enabledChannelsMask:0x%4.4x average_0_4_8_16_32:%d pm=%d swcnv=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 5212 | (g_MAX11131_device.enabledChannelsMask & 0xFFFF), |
whismanoid | 0:3edb3708c8c5 | 5213 | g_MAX11131_device.average_0_4_8_16_32, |
whismanoid | 0:3edb3708c8c5 | 5214 | g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 5215 | g_MAX11131_device.swcnv_0_1 |
whismanoid | 0:3edb3708c8c5 | 5216 | ); |
whismanoid | 0:3edb3708c8c5 | 5217 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 5218 | // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 |
whismanoid | 0:3edb3708c8c5 | 5219 | // 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 | 5220 | // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask |
whismanoid | 0:3edb3708c8c5 | 5221 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomInternalClock(); |
whismanoid | 0:3edb3708c8c5 | 5222 | // |
whismanoid | 0:3edb3708c8c5 | 5223 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 5224 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 5225 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 5226 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 5227 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 5228 | // |
whismanoid | 0:3edb3708c8c5 | 5229 | AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 10:228a52f8107d | 5230 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5231 | } |
whismanoid | 0:3edb3708c8c5 | 5232 | break; |
whismanoid | 0:3edb3708c8c5 | 5233 | case '8': |
whismanoid | 0:3edb3708c8c5 | 5234 | { |
whismanoid | 0:3edb3708c8c5 | 5235 | // recommended for hex command codes 80..8F |
whismanoid | 0:3edb3708c8c5 | 5236 | // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 5237 | // TODO: cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock"); |
whismanoid | 0:3edb3708c8c5 | 5238 | if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask)) |
whismanoid | 0:3edb3708c8c5 | 5239 | { |
whismanoid | 0:3edb3708c8c5 | 5240 | // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 5241 | } |
whismanoid | 0:3edb3708c8c5 | 5242 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 5243 | { |
whismanoid | 0:3edb3708c8c5 | 5244 | } |
whismanoid | 0:3edb3708c8c5 | 5245 | if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) |
whismanoid | 0:3edb3708c8c5 | 5246 | { |
whismanoid | 0:3edb3708c8c5 | 5247 | } |
whismanoid | 0:3edb3708c8c5 | 5248 | cmdLine.serial().printf("ScanCustomExternalClock enabledChannelsMask:0x%4.4x pm=%d id=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 5249 | (g_MAX11131_device.enabledChannelsMask & 0xFFFF), |
whismanoid | 0:3edb3708c8c5 | 5250 | g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 5251 | g_MAX11131_device.chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 5252 | ); |
whismanoid | 0:3edb3708c8c5 | 5253 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 5254 | // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 5255 | // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask |
whismanoid | 0:3edb3708c8c5 | 5256 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 5257 | // |
whismanoid | 0:3edb3708c8c5 | 5258 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 5259 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 5260 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 5261 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 5262 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 5263 | // |
whismanoid | 0:3edb3708c8c5 | 5264 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 10:228a52f8107d | 5265 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5266 | } |
whismanoid | 0:3edb3708c8c5 | 5267 | break; |
whismanoid | 0:3edb3708c8c5 | 5268 | case '9': |
whismanoid | 0:3edb3708c8c5 | 5269 | { |
whismanoid | 0:3edb3708c8c5 | 5270 | // recommended for hex command codes 90..9F |
whismanoid | 0:3edb3708c8c5 | 5271 | // 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 | 5272 | // TODO: cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock"); |
whismanoid | 0:3edb3708c8c5 | 5273 | // |
whismanoid | 0:3edb3708c8c5 | 5274 | // get MAX11131 Sampleset channel selection pattern parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 5275 | // cmdLine.parse_byteCount_byteList_dec(byteCount, mosiData, MAX_SPI_BYTE_COUNT) |
whismanoid | 0:3edb3708c8c5 | 5276 | // into g_MAX11131_device.enabledChannelsPatternLength_1_256 |
whismanoid | 0:3edb3708c8c5 | 5277 | // into g_MAX11131_device.enabledChannelsPattern[0..255] |
whismanoid | 0:3edb3708c8c5 | 5278 | size_t numValues; |
whismanoid | 0:3edb3708c8c5 | 5279 | char valueList[256]; |
whismanoid | 0:3edb3708c8c5 | 5280 | if (cmdLine.parse_byteCount_byteList_dec( numValues, valueList, 256)) |
whismanoid | 0:3edb3708c8c5 | 5281 | { |
whismanoid | 0:3edb3708c8c5 | 5282 | // first value is the "9" command itself |
whismanoid | 0:3edb3708c8c5 | 5283 | g_MAX11131_device.enabledChannelsPatternLength_1_256 = numValues - 1; |
whismanoid | 0:3edb3708c8c5 | 5284 | // copy valueList[1, ...] into g_MAX11131_device.enabledChannelsPattern[0, ...] |
whismanoid | 0:3edb3708c8c5 | 5285 | for (size_t index = 0; index < (numValues - 1); index++) |
whismanoid | 0:3edb3708c8c5 | 5286 | { |
whismanoid | 0:3edb3708c8c5 | 5287 | g_MAX11131_device.enabledChannelsPattern[index] = valueList[1 + index]; |
whismanoid | 0:3edb3708c8c5 | 5288 | } |
whismanoid | 0:3edb3708c8c5 | 5289 | } |
whismanoid | 0:3edb3708c8c5 | 5290 | // |
whismanoid | 0:3edb3708c8c5 | 5291 | cmdLine.serial().printf("ScanSampleSetExternalClock enabledChannelsPattern:{ "); |
whismanoid | 0:3edb3708c8c5 | 5292 | int index; |
whismanoid | 0:3edb3708c8c5 | 5293 | for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++) |
whismanoid | 0:3edb3708c8c5 | 5294 | { |
whismanoid | 0:3edb3708c8c5 | 5295 | //~ Serial.print( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC); |
whismanoid | 0:3edb3708c8c5 | 5296 | //~ Serial.print(" "); |
whismanoid | 0:3edb3708c8c5 | 5297 | cmdLine.serial().printf("AIN%d ", ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F)); |
whismanoid | 0:3edb3708c8c5 | 5298 | } |
whismanoid | 0:3edb3708c8c5 | 5299 | cmdLine.serial().printf("}"); |
whismanoid | 0:3edb3708c8c5 | 5300 | cmdLine.serial().printf(" pm=%d id=%d\r\n", g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 5301 | g_MAX11131_device.chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 5302 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 5303 | // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 5304 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanSampleSetExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 5305 | // |
whismanoid | 0:3edb3708c8c5 | 5306 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 5307 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 5308 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 5309 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 5310 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 5311 | // |
whismanoid | 0:3edb3708c8c5 | 5312 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 10:228a52f8107d | 5313 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5314 | } |
whismanoid | 0:3edb3708c8c5 | 5315 | break; |
whismanoid | 0:3edb3708c8c5 | 5316 | case 'a': case 'A': |
whismanoid | 0:3edb3708c8c5 | 5317 | { |
whismanoid | 0:3edb3708c8c5 | 5318 | // recommended for hex command codes A0..AF |
whismanoid | 0:3edb3708c8c5 | 5319 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 5320 | { |
whismanoid | 0:3edb3708c8c5 | 5321 | case 't': case 'T': |
whismanoid | 0:3edb3708c8c5 | 5322 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5323 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5324 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5325 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5326 | // AT command: skip the prompt to avoid confusing modem detector |
whismanoid | 10:228a52f8107d | 5327 | return false; // command not handled |
whismanoid | 0:3edb3708c8c5 | 5328 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5329 | } |
whismanoid | 0:3edb3708c8c5 | 5330 | } |
whismanoid | 0:3edb3708c8c5 | 5331 | break; |
whismanoid | 0:3edb3708c8c5 | 5332 | case 'b': case 'B': |
whismanoid | 0:3edb3708c8c5 | 5333 | { |
whismanoid | 0:3edb3708c8c5 | 5334 | // recommended for hex command codes B0..BF |
whismanoid | 0:3edb3708c8c5 | 5335 | } |
whismanoid | 0:3edb3708c8c5 | 5336 | break; |
whismanoid | 0:3edb3708c8c5 | 5337 | case 'c': case 'C': |
whismanoid | 0:3edb3708c8c5 | 5338 | { |
whismanoid | 0:3edb3708c8c5 | 5339 | // recommended for hex command codes C0..CF |
whismanoid | 0:3edb3708c8c5 | 5340 | } |
whismanoid | 0:3edb3708c8c5 | 5341 | break; |
whismanoid | 0:3edb3708c8c5 | 5342 | case 'd': case 'D': |
whismanoid | 0:3edb3708c8c5 | 5343 | { |
whismanoid | 0:3edb3708c8c5 | 5344 | // recommended for hex command codes D0..DF |
whismanoid | 0:3edb3708c8c5 | 5345 | } |
whismanoid | 0:3edb3708c8c5 | 5346 | break; |
whismanoid | 0:3edb3708c8c5 | 5347 | case 'e': case 'E': |
whismanoid | 0:3edb3708c8c5 | 5348 | { |
whismanoid | 0:3edb3708c8c5 | 5349 | // recommended for hex command codes E0..EF |
whismanoid | 0:3edb3708c8c5 | 5350 | } |
whismanoid | 0:3edb3708c8c5 | 5351 | break; |
whismanoid | 0:3edb3708c8c5 | 5352 | case 'f': case 'F': |
whismanoid | 0:3edb3708c8c5 | 5353 | { |
whismanoid | 0:3edb3708c8c5 | 5354 | // recommended for hex command codes F0..FF |
whismanoid | 0:3edb3708c8c5 | 5355 | } |
whismanoid | 0:3edb3708c8c5 | 5356 | break; |
whismanoid | 0:3edb3708c8c5 | 5357 | case 'x': case 'X': |
whismanoid | 0:3edb3708c8c5 | 5358 | { |
whismanoid | 0:3edb3708c8c5 | 5359 | } |
whismanoid | 0:3edb3708c8c5 | 5360 | break; |
whismanoid | 0:3edb3708c8c5 | 5361 | case 'y': case 'Y': |
whismanoid | 0:3edb3708c8c5 | 5362 | { |
whismanoid | 0:3edb3708c8c5 | 5363 | } |
whismanoid | 0:3edb3708c8c5 | 5364 | break; |
whismanoid | 0:3edb3708c8c5 | 5365 | case 'i': case 'I': |
whismanoid | 0:3edb3708c8c5 | 5366 | { |
whismanoid | 0:3edb3708c8c5 | 5367 | // TODO: cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range"); |
whismanoid | 0:3edb3708c8c5 | 5368 | char strChannelId[3]; |
whismanoid | 0:3edb3708c8c5 | 5369 | strChannelId[0] = cmdLine[2]; |
whismanoid | 0:3edb3708c8c5 | 5370 | strChannelId[1] = cmdLine[3]; |
whismanoid | 0:3edb3708c8c5 | 5371 | strChannelId[2] = '\0'; |
whismanoid | 0:3edb3708c8c5 | 5372 | int channelId_0_15 = strtoul(strChannelId, NULL, 10); // strtol(str, NULL, 10): get decimal value |
whismanoid | 0:3edb3708c8c5 | 5373 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 5374 | { |
whismanoid | 0:3edb3708c8c5 | 5375 | case 's': case 'S': |
whismanoid | 0:3edb3708c8c5 | 5376 | g_MAX11131_device.Reconfigure_SingleEnded(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 5377 | break; |
whismanoid | 0:3edb3708c8c5 | 5378 | case 'u': case 'U': |
whismanoid | 0:3edb3708c8c5 | 5379 | g_MAX11131_device.Reconfigure_DifferentialUnipolar(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 5380 | break; |
whismanoid | 0:3edb3708c8c5 | 5381 | case 'b': case 'B': |
whismanoid | 0:3edb3708c8c5 | 5382 | g_MAX11131_device.Reconfigure_DifferentialBipolarFSVref(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 5383 | break; |
whismanoid | 0:3edb3708c8c5 | 5384 | case 'r': case 'R': |
whismanoid | 0:3edb3708c8c5 | 5385 | g_MAX11131_device.Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 5386 | break; |
whismanoid | 0:3edb3708c8c5 | 5387 | } |
whismanoid | 0:3edb3708c8c5 | 5388 | // char cmd1 = strCommandArgs[0]; |
whismanoid | 0:3edb3708c8c5 | 5389 | // strCommandArgs.remove(0, 1); // unsigned int index, unsigned int count |
whismanoid | 0:3edb3708c8c5 | 5390 | // // get argument int channelId_0_15 |
whismanoid | 0:3edb3708c8c5 | 5391 | // // parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 5392 | // int channelId_0_15 = strtoul(strCommandArgs.c_str(), NULL, 10); // strtol(str, NULL, 10): get decimal value |
whismanoid | 0:3edb3708c8c5 | 5393 | // if (cmd1 == 'S') { |
whismanoid | 0:3edb3708c8c5 | 5394 | // MAX11131_Reconfigure_SingleEnded(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 5395 | // } |
whismanoid | 0:3edb3708c8c5 | 5396 | // else if (cmd1 == 'U') { |
whismanoid | 0:3edb3708c8c5 | 5397 | // MAX11131_Reconfigure_DifferentialUnipolar(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 5398 | // } |
whismanoid | 0:3edb3708c8c5 | 5399 | // else if (cmd1 == 'B') { |
whismanoid | 0:3edb3708c8c5 | 5400 | // MAX11131_Reconfigure_DifferentialBipolarFSVref(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 5401 | // } |
whismanoid | 0:3edb3708c8c5 | 5402 | // else if (cmd1 == 'R') { |
whismanoid | 0:3edb3708c8c5 | 5403 | // MAX11131_Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 5404 | // } |
whismanoid | 10:228a52f8107d | 5405 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5406 | } |
whismanoid | 0:3edb3708c8c5 | 5407 | break; |
whismanoid | 0:3edb3708c8c5 | 5408 | case '@': |
whismanoid | 0:3edb3708c8c5 | 5409 | { |
whismanoid | 0:3edb3708c8c5 | 5410 | // TODO: cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration"); |
whismanoid | 0:3edb3708c8c5 | 5411 | // print shadow register configuration |
whismanoid | 0:3edb3708c8c5 | 5412 | // |
whismanoid | 0:3edb3708c8c5 | 5413 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_MODE_CONTROL & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5414 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_MODE_CONTROL); |
whismanoid | 0:3edb3708c8c5 | 5415 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_CONFIGURATION & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5416 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_CONFIGURATION); |
whismanoid | 0:3edb3708c8c5 | 5417 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.UNIPOLAR & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5418 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.UNIPOLAR); |
whismanoid | 0:3edb3708c8c5 | 5419 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.BIPOLAR & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5420 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.BIPOLAR); |
whismanoid | 0:3edb3708c8c5 | 5421 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.RANGE & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5422 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.RANGE); |
whismanoid | 0:3edb3708c8c5 | 5423 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN0 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5424 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN0); |
whismanoid | 0:3edb3708c8c5 | 5425 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN1 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5426 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN1); |
whismanoid | 0:3edb3708c8c5 | 5427 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.SAMPLESET & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5428 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.SAMPLESET); |
whismanoid | 0:3edb3708c8c5 | 5429 | // |
whismanoid | 0:3edb3708c8c5 | 5430 | // VERIFY: print shadow SAMPLESET pattern entry |
whismanoid | 0:3edb3708c8c5 | 5431 | int entryIndex; |
whismanoid | 0:3edb3708c8c5 | 5432 | for (entryIndex = 0; entryIndex < g_MAX11131_device.enabledChannelsPatternLength_1_256; |
whismanoid | 0:3edb3708c8c5 | 5433 | entryIndex += 4) |
whismanoid | 0:3edb3708c8c5 | 5434 | { |
whismanoid | 0:3edb3708c8c5 | 5435 | uint16_t pack4channels = 0; |
whismanoid | 0:3edb3708c8c5 | 5436 | pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 0]) & 0x0F) << 12); |
whismanoid | 0:3edb3708c8c5 | 5437 | if ((entryIndex + 1) < g_MAX11131_device.enabledChannelsPatternLength_1_256) { |
whismanoid | 0:3edb3708c8c5 | 5438 | pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 1]) & 0x0F) << 8); |
whismanoid | 0:3edb3708c8c5 | 5439 | } |
whismanoid | 0:3edb3708c8c5 | 5440 | if ((entryIndex + 2) < g_MAX11131_device.enabledChannelsPatternLength_1_256) { |
whismanoid | 0:3edb3708c8c5 | 5441 | pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 2]) & 0x0F) << 4); |
whismanoid | 0:3edb3708c8c5 | 5442 | } |
whismanoid | 0:3edb3708c8c5 | 5443 | if ((entryIndex + 3) < g_MAX11131_device.enabledChannelsPatternLength_1_256) { |
whismanoid | 0:3edb3708c8c5 | 5444 | pack4channels |= ((g_MAX11131_device.enabledChannelsPattern[entryIndex + 3]) & 0x0F); |
whismanoid | 0:3edb3708c8c5 | 5445 | } |
whismanoid | 0:3edb3708c8c5 | 5446 | //~ SPIwrite16bits(pack4channels); |
whismanoid | 0:3edb3708c8c5 | 5447 | cmdLine.serial().printf(" 0x%4.4x", (pack4channels & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5448 | // decode SAMPLESET channel select pattern |
whismanoid | 0:3edb3708c8c5 | 5449 | cmdLine.serial().printf(" SampleSet Entry: AIN%d AIN%d AIN%d AIN%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 5450 | ((pack4channels >> 12) & 0x000F), |
whismanoid | 0:3edb3708c8c5 | 5451 | ((pack4channels >> 8) & 0x000F), |
whismanoid | 0:3edb3708c8c5 | 5452 | ((pack4channels >> 4) & 0x000F), |
whismanoid | 0:3edb3708c8c5 | 5453 | ((pack4channels ) & 0x000F) |
whismanoid | 0:3edb3708c8c5 | 5454 | ); |
whismanoid | 0:3edb3708c8c5 | 5455 | } |
whismanoid | 0:3edb3708c8c5 | 5456 | //cmdLine.serial().printf(" SAMPLESET enabledChannelsPattern:{ "); |
whismanoid | 0:3edb3708c8c5 | 5457 | //int index; |
whismanoid | 0:3edb3708c8c5 | 5458 | //for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++) |
whismanoid | 0:3edb3708c8c5 | 5459 | //{ |
whismanoid | 0:3edb3708c8c5 | 5460 | // //~ cmdLine.serial().printf( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC); |
whismanoid | 0:3edb3708c8c5 | 5461 | // //~ cmdLine.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 5462 | // cmdLine.serial().printf("AIN"); |
whismanoid | 0:3edb3708c8c5 | 5463 | // cmdLine.serial().printf( ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F), DEC); |
whismanoid | 0:3edb3708c8c5 | 5464 | // cmdLine.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 5465 | //} |
whismanoid | 0:3edb3708c8c5 | 5466 | //cmdLine.serial().printf("}"); |
whismanoid | 0:3edb3708c8c5 | 5467 | // |
whismanoid | 0:3edb3708c8c5 | 5468 | // Menu @) print MAX11131 configuration AND g_MAX11131_device globals |
whismanoid | 0:3edb3708c8c5 | 5469 | // |
whismanoid | 0:3edb3708c8c5 | 5470 | cmdLine.serial().printf("SPI_MOSI_Semantic=%d\r\n", (g_MAX11131_device.SPI_MOSI_Semantic & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5471 | cmdLine.serial().printf("NumWords=%d\r\n", (g_MAX11131_device.NumWords & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5472 | cmdLine.serial().printf("isExternalClock=%d\r\n", (g_MAX11131_device.isExternalClock & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5473 | cmdLine.serial().printf("ScanMode=%d\r\n", (g_MAX11131_device.ScanMode & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5474 | cmdLine.serial().printf("channelNumber_0_15=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 5475 | (g_MAX11131_device.channelNumber_0_15 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5476 | cmdLine.serial().printf("PowerManagement_0_2=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 5477 | (g_MAX11131_device.PowerManagement_0_2 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5478 | cmdLine.serial().printf("chan_id_0_1=%d\r\n", (g_MAX11131_device.chan_id_0_1 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5479 | cmdLine.serial().printf("average_0_4_8_16_32=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 5480 | (g_MAX11131_device.average_0_4_8_16_32 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5481 | cmdLine.serial().printf("nscan_4_8_12_16=%d\r\n", (g_MAX11131_device.nscan_4_8_12_16 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5482 | cmdLine.serial().printf("swcnv_0_1=%d\r\n", (g_MAX11131_device.swcnv_0_1 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5483 | cmdLine.serial().printf("enabledChannelsMask=0x%4.4x\r\n", |
whismanoid | 0:3edb3708c8c5 | 5484 | (g_MAX11131_device.enabledChannelsMask & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 5485 | // |
whismanoid | 0:3edb3708c8c5 | 5486 | cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX11131_device.VRef); |
whismanoid | 0:3edb3708c8c5 | 5487 | // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB |
whismanoid | 0:3edb3708c8c5 | 5488 | // |
whismanoid | 10:228a52f8107d | 5489 | return true; // command was handled by MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5490 | } |
whismanoid | 0:3edb3708c8c5 | 5491 | //case '&': |
whismanoid | 0:3edb3708c8c5 | 5492 | //{ |
whismanoid | 0:3edb3708c8c5 | 5493 | // // TODO: cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual"); |
whismanoid | 0:3edb3708c8c5 | 5494 | //} |
whismanoid | 0:3edb3708c8c5 | 5495 | break; |
whismanoid | 0:3edb3708c8c5 | 5496 | case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command |
whismanoid | 0:3edb3708c8c5 | 5497 | { |
whismanoid | 0:3edb3708c8c5 | 5498 | // TODO: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 5499 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5500 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5501 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5502 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5503 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5504 | } |
whismanoid | 0:3edb3708c8c5 | 5505 | break; |
whismanoid | 0:3edb3708c8c5 | 5506 | case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command |
whismanoid | 0:3edb3708c8c5 | 5507 | { |
whismanoid | 0:3edb3708c8c5 | 5508 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5509 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5510 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5511 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5512 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5513 | } |
whismanoid | 0:3edb3708c8c5 | 5514 | break; |
whismanoid | 10:228a52f8107d | 5515 | } // end switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 5516 | return false; // command not handled |
whismanoid | 10:228a52f8107d | 5517 | } // end bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 5518 | #endif |
whismanoid | 0:3edb3708c8c5 | 5519 | |
whismanoid | 10:228a52f8107d | 5520 | //-------------------------------------------------- |
whismanoid | 10:228a52f8107d | 5521 | #if 0 // APPLICATION_MAX5171 // MAX5171_menu_onEOLcommandParser moved to Test_Menu_MAX5171.cpp |
whismanoid | 10:228a52f8107d | 5522 | bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 5523 | { |
whismanoid | 10:228a52f8107d | 5524 | switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 5525 | { |
whismanoid | 0:3edb3708c8c5 | 5526 | case '0': |
whismanoid | 0:3edb3708c8c5 | 5527 | { |
whismanoid | 0:3edb3708c8c5 | 5528 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5529 | //~ cmdLine.serial().printf("\r\n 0 code=? -- CODE"); |
whismanoid | 0:3edb3708c8c5 | 5530 | uint16_t code; |
whismanoid | 0:3edb3708c8c5 | 5531 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 5532 | { |
whismanoid | 0:3edb3708c8c5 | 5533 | } |
whismanoid | 0:3edb3708c8c5 | 5534 | cmdLine.serial().printf("CODE code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 5535 | g_MAX5171_device.CODE(code); |
whismanoid | 10:228a52f8107d | 5536 | return true; // command was handled by MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5537 | } |
whismanoid | 0:3edb3708c8c5 | 5538 | break; |
whismanoid | 0:3edb3708c8c5 | 5539 | case '4': |
whismanoid | 0:3edb3708c8c5 | 5540 | { |
whismanoid | 0:3edb3708c8c5 | 5541 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5542 | //~ cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD"); |
whismanoid | 0:3edb3708c8c5 | 5543 | uint16_t code; |
whismanoid | 0:3edb3708c8c5 | 5544 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 5545 | { |
whismanoid | 0:3edb3708c8c5 | 5546 | } |
whismanoid | 0:3edb3708c8c5 | 5547 | cmdLine.serial().printf("CODE_LOAD code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 5548 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 10:228a52f8107d | 5549 | return true; // command was handled by MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5550 | } |
whismanoid | 0:3edb3708c8c5 | 5551 | break; |
whismanoid | 0:3edb3708c8c5 | 5552 | case '8': |
whismanoid | 0:3edb3708c8c5 | 5553 | { |
whismanoid | 0:3edb3708c8c5 | 5554 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5555 | //~ cmdLine.serial().printf("\r\n 8 -- LOAD"); |
whismanoid | 0:3edb3708c8c5 | 5556 | cmdLine.serial().printf("LOAD"); |
whismanoid | 0:3edb3708c8c5 | 5557 | g_MAX5171_device.LOAD(); |
whismanoid | 10:228a52f8107d | 5558 | return true; // command was handled by MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5559 | } |
whismanoid | 0:3edb3708c8c5 | 5560 | break; |
whismanoid | 0:3edb3708c8c5 | 5561 | case 'c': case 'C': |
whismanoid | 0:3edb3708c8c5 | 5562 | { |
whismanoid | 0:3edb3708c8c5 | 5563 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5564 | //~ cmdLine.serial().printf("\r\n c -- NOP"); |
whismanoid | 0:3edb3708c8c5 | 5565 | cmdLine.serial().printf("NOP"); |
whismanoid | 0:3edb3708c8c5 | 5566 | g_MAX5171_device.NOP(); |
whismanoid | 10:228a52f8107d | 5567 | return true; // command was handled by MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5568 | } |
whismanoid | 0:3edb3708c8c5 | 5569 | break; |
whismanoid | 0:3edb3708c8c5 | 5570 | case 'd': case 'D': |
whismanoid | 0:3edb3708c8c5 | 5571 | { |
whismanoid | 0:3edb3708c8c5 | 5572 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5573 | //~ cmdLine.serial().printf("\r\n d -- SHUTDOWN"); |
whismanoid | 0:3edb3708c8c5 | 5574 | cmdLine.serial().printf("SHUTDOWN"); |
whismanoid | 0:3edb3708c8c5 | 5575 | g_MAX5171_device.SHUTDOWN(); |
whismanoid | 10:228a52f8107d | 5576 | return true; // command was handled by MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5577 | } |
whismanoid | 0:3edb3708c8c5 | 5578 | break; |
whismanoid | 0:3edb3708c8c5 | 5579 | case 'e': case 'E': |
whismanoid | 0:3edb3708c8c5 | 5580 | { |
whismanoid | 0:3edb3708c8c5 | 5581 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 5582 | { |
whismanoid | 0:3edb3708c8c5 | 5583 | case '0': |
whismanoid | 0:3edb3708c8c5 | 5584 | { |
whismanoid | 0:3edb3708c8c5 | 5585 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5586 | //~ cmdLine.serial().printf("\r\n e0 -- UPO_LOW"); |
whismanoid | 0:3edb3708c8c5 | 5587 | cmdLine.serial().printf("UPO_LOW"); |
whismanoid | 0:3edb3708c8c5 | 5588 | g_MAX5171_device.UPO_LOW(); |
whismanoid | 10:228a52f8107d | 5589 | return true; // command was handled by MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5590 | } |
whismanoid | 0:3edb3708c8c5 | 5591 | break; |
whismanoid | 0:3edb3708c8c5 | 5592 | case '8': |
whismanoid | 0:3edb3708c8c5 | 5593 | { |
whismanoid | 0:3edb3708c8c5 | 5594 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5595 | //~ cmdLine.serial().printf("\r\n e8 -- UPO_HIGH"); |
whismanoid | 0:3edb3708c8c5 | 5596 | cmdLine.serial().printf("UPO_HIGH"); |
whismanoid | 0:3edb3708c8c5 | 5597 | g_MAX5171_device.UPO_HIGH(); |
whismanoid | 10:228a52f8107d | 5598 | return true; // command was handled by MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5599 | } |
whismanoid | 0:3edb3708c8c5 | 5600 | break; |
whismanoid | 0:3edb3708c8c5 | 5601 | } |
whismanoid | 0:3edb3708c8c5 | 5602 | } |
whismanoid | 0:3edb3708c8c5 | 5603 | break; |
whismanoid | 0:3edb3708c8c5 | 5604 | case 'f': case 'F': |
whismanoid | 0:3edb3708c8c5 | 5605 | { |
whismanoid | 0:3edb3708c8c5 | 5606 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 5607 | { |
whismanoid | 0:3edb3708c8c5 | 5608 | case '0': |
whismanoid | 0:3edb3708c8c5 | 5609 | { |
whismanoid | 0:3edb3708c8c5 | 5610 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5611 | //~ cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 5612 | cmdLine.serial().printf("MODE1_DOUT_SCLK_RISING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 5613 | g_MAX5171_device.MODE1_DOUT_SCLK_RISING_EDGE(); |
whismanoid | 10:228a52f8107d | 5614 | return true; // command was handled by MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5615 | } |
whismanoid | 0:3edb3708c8c5 | 5616 | break; |
whismanoid | 0:3edb3708c8c5 | 5617 | case '8': |
whismanoid | 0:3edb3708c8c5 | 5618 | { |
whismanoid | 0:3edb3708c8c5 | 5619 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5620 | //~ cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 5621 | cmdLine.serial().printf("MODE0_DOUT_SCLK_FALLING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 5622 | g_MAX5171_device.MODE0_DOUT_SCLK_FALLING_EDGE(); |
whismanoid | 10:228a52f8107d | 5623 | return true; // command was handled by MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5624 | } |
whismanoid | 0:3edb3708c8c5 | 5625 | break; |
whismanoid | 0:3edb3708c8c5 | 5626 | } |
whismanoid | 0:3edb3708c8c5 | 5627 | } |
whismanoid | 0:3edb3708c8c5 | 5628 | break; |
whismanoid | 0:3edb3708c8c5 | 5629 | case 'a': case 'A': |
whismanoid | 0:3edb3708c8c5 | 5630 | { |
whismanoid | 0:3edb3708c8c5 | 5631 | // recommended for hex command codes A0..AF |
whismanoid | 0:3edb3708c8c5 | 5632 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 5633 | { |
whismanoid | 0:3edb3708c8c5 | 5634 | case 't': case 'T': |
whismanoid | 0:3edb3708c8c5 | 5635 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5636 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5637 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5638 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5639 | // AT command: skip the prompt to avoid confusing modem detector |
whismanoid | 0:3edb3708c8c5 | 5640 | return; |
whismanoid | 0:3edb3708c8c5 | 5641 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5642 | } |
whismanoid | 0:3edb3708c8c5 | 5643 | } |
whismanoid | 0:3edb3708c8c5 | 5644 | break; |
whismanoid | 0:3edb3708c8c5 | 5645 | case 'x': case 'X': |
whismanoid | 0:3edb3708c8c5 | 5646 | { |
whismanoid | 0:3edb3708c8c5 | 5647 | } |
whismanoid | 0:3edb3708c8c5 | 5648 | break; |
whismanoid | 0:3edb3708c8c5 | 5649 | case 'y': case 'Y': |
whismanoid | 0:3edb3708c8c5 | 5650 | { |
whismanoid | 0:3edb3708c8c5 | 5651 | } |
whismanoid | 0:3edb3708c8c5 | 5652 | break; |
whismanoid | 0:3edb3708c8c5 | 5653 | case 'z': case 'Z': |
whismanoid | 0:3edb3708c8c5 | 5654 | { |
whismanoid | 0:3edb3708c8c5 | 5655 | } |
whismanoid | 0:3edb3708c8c5 | 5656 | break; |
whismanoid | 0:3edb3708c8c5 | 5657 | case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command |
whismanoid | 0:3edb3708c8c5 | 5658 | { |
whismanoid | 0:3edb3708c8c5 | 5659 | // TODO: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 5660 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5661 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5662 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5663 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5664 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5665 | } |
whismanoid | 0:3edb3708c8c5 | 5666 | break; |
whismanoid | 0:3edb3708c8c5 | 5667 | case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command |
whismanoid | 0:3edb3708c8c5 | 5668 | { |
whismanoid | 0:3edb3708c8c5 | 5669 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5670 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5671 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5672 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5673 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5674 | } |
whismanoid | 0:3edb3708c8c5 | 5675 | break; |
whismanoid | 10:228a52f8107d | 5676 | } // end switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 5677 | return false; // command not handled |
whismanoid | 10:228a52f8107d | 5678 | } // end bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 5679 | #endif |
whismanoid | 0:3edb3708c8c5 | 5680 | |
whismanoid | 10:228a52f8107d | 5681 | //-------------------------------------------------- |
whismanoid | 10:228a52f8107d | 5682 | #if 0 // APPLICATION_MAX11410 // MAX11410_menu_onEOLcommandParser moved to Test_Menu_MAX11410.cpp |
whismanoid | 10:228a52f8107d | 5683 | bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 5684 | { |
whismanoid | 10:228a52f8107d | 5685 | switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 5686 | { |
whismanoid | 0:3edb3708c8c5 | 5687 | // TODO1: MAX11410 main_menu_onEOLcommandParser |
whismanoid | 0:3edb3708c8c5 | 5688 | case '0': |
whismanoid | 0:3edb3708c8c5 | 5689 | { |
whismanoid | 0:3edb3708c8c5 | 5690 | // recommended for hex command codes 00..0F |
whismanoid | 0:3edb3708c8c5 | 5691 | // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); |
whismanoid | 0:3edb3708c8c5 | 5692 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 5693 | uint16_t code; |
whismanoid | 0:3edb3708c8c5 | 5694 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 5695 | { |
whismanoid | 0:3edb3708c8c5 | 5696 | } |
whismanoid | 0:3edb3708c8c5 | 5697 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 5698 | { |
whismanoid | 0:3edb3708c8c5 | 5699 | } |
whismanoid | 0:3edb3708c8c5 | 5700 | if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG)) |
whismanoid | 0:3edb3708c8c5 | 5701 | { |
whismanoid | 0:3edb3708c8c5 | 5702 | isUpdatedSPIConfig = true; |
whismanoid | 0:3edb3708c8c5 | 5703 | } |
whismanoid | 0:3edb3708c8c5 | 5704 | cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 5705 | MAX5715_CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 5706 | cmdLine.serial().printf("\r\n placeholder"); |
whismanoid | 10:228a52f8107d | 5707 | return true; // command was handled by MAX11410 |
whismanoid | 0:3edb3708c8c5 | 5708 | } |
whismanoid | 0:3edb3708c8c5 | 5709 | break; |
whismanoid | 0:3edb3708c8c5 | 5710 | case '1': |
whismanoid | 0:3edb3708c8c5 | 5711 | { |
whismanoid | 0:3edb3708c8c5 | 5712 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5713 | } |
whismanoid | 0:3edb3708c8c5 | 5714 | break; |
whismanoid | 0:3edb3708c8c5 | 5715 | case '2': |
whismanoid | 0:3edb3708c8c5 | 5716 | { |
whismanoid | 0:3edb3708c8c5 | 5717 | // recommended for hex command codes 20..2F |
whismanoid | 0:3edb3708c8c5 | 5718 | } |
whismanoid | 0:3edb3708c8c5 | 5719 | break; |
whismanoid | 0:3edb3708c8c5 | 5720 | case '3': |
whismanoid | 0:3edb3708c8c5 | 5721 | { |
whismanoid | 0:3edb3708c8c5 | 5722 | // recommended for hex command codes 30..3F |
whismanoid | 0:3edb3708c8c5 | 5723 | } |
whismanoid | 0:3edb3708c8c5 | 5724 | break; |
whismanoid | 0:3edb3708c8c5 | 5725 | case '4': |
whismanoid | 0:3edb3708c8c5 | 5726 | { |
whismanoid | 0:3edb3708c8c5 | 5727 | // recommended for hex command codes 40..4F |
whismanoid | 0:3edb3708c8c5 | 5728 | } |
whismanoid | 0:3edb3708c8c5 | 5729 | break; |
whismanoid | 0:3edb3708c8c5 | 5730 | case '5': |
whismanoid | 0:3edb3708c8c5 | 5731 | { |
whismanoid | 0:3edb3708c8c5 | 5732 | // recommended for hex command codes 50..5F |
whismanoid | 0:3edb3708c8c5 | 5733 | } |
whismanoid | 0:3edb3708c8c5 | 5734 | break; |
whismanoid | 0:3edb3708c8c5 | 5735 | case '6': |
whismanoid | 0:3edb3708c8c5 | 5736 | { |
whismanoid | 0:3edb3708c8c5 | 5737 | // recommended for hex command codes 60..6F |
whismanoid | 0:3edb3708c8c5 | 5738 | } |
whismanoid | 0:3edb3708c8c5 | 5739 | break; |
whismanoid | 0:3edb3708c8c5 | 5740 | case '7': |
whismanoid | 0:3edb3708c8c5 | 5741 | { |
whismanoid | 0:3edb3708c8c5 | 5742 | // recommended for hex command codes 70..7F |
whismanoid | 0:3edb3708c8c5 | 5743 | } |
whismanoid | 0:3edb3708c8c5 | 5744 | break; |
whismanoid | 0:3edb3708c8c5 | 5745 | case '8': |
whismanoid | 0:3edb3708c8c5 | 5746 | { |
whismanoid | 0:3edb3708c8c5 | 5747 | // recommended for hex command codes 80..8F |
whismanoid | 0:3edb3708c8c5 | 5748 | } |
whismanoid | 0:3edb3708c8c5 | 5749 | break; |
whismanoid | 0:3edb3708c8c5 | 5750 | case '9': |
whismanoid | 0:3edb3708c8c5 | 5751 | { |
whismanoid | 0:3edb3708c8c5 | 5752 | // recommended for hex command codes 90..9F |
whismanoid | 0:3edb3708c8c5 | 5753 | } |
whismanoid | 0:3edb3708c8c5 | 5754 | break; |
whismanoid | 0:3edb3708c8c5 | 5755 | case 'a': case 'A': |
whismanoid | 0:3edb3708c8c5 | 5756 | { |
whismanoid | 0:3edb3708c8c5 | 5757 | // recommended for hex command codes A0..AF |
whismanoid | 0:3edb3708c8c5 | 5758 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 5759 | { |
whismanoid | 0:3edb3708c8c5 | 5760 | case 't': case 'T': |
whismanoid | 0:3edb3708c8c5 | 5761 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5762 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5763 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5764 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5765 | // AT command: skip the prompt to avoid confusing modem detector |
whismanoid | 0:3edb3708c8c5 | 5766 | return; |
whismanoid | 0:3edb3708c8c5 | 5767 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5768 | } |
whismanoid | 0:3edb3708c8c5 | 5769 | } |
whismanoid | 0:3edb3708c8c5 | 5770 | break; |
whismanoid | 0:3edb3708c8c5 | 5771 | case 'b': case 'B': |
whismanoid | 0:3edb3708c8c5 | 5772 | { |
whismanoid | 0:3edb3708c8c5 | 5773 | // recommended for hex command codes B0..BF |
whismanoid | 0:3edb3708c8c5 | 5774 | } |
whismanoid | 0:3edb3708c8c5 | 5775 | break; |
whismanoid | 0:3edb3708c8c5 | 5776 | case 'c': case 'C': |
whismanoid | 0:3edb3708c8c5 | 5777 | { |
whismanoid | 0:3edb3708c8c5 | 5778 | // recommended for hex command codes C0..CF |
whismanoid | 0:3edb3708c8c5 | 5779 | } |
whismanoid | 0:3edb3708c8c5 | 5780 | break; |
whismanoid | 0:3edb3708c8c5 | 5781 | case 'd': case 'D': |
whismanoid | 0:3edb3708c8c5 | 5782 | { |
whismanoid | 0:3edb3708c8c5 | 5783 | // recommended for hex command codes D0..DF |
whismanoid | 0:3edb3708c8c5 | 5784 | } |
whismanoid | 0:3edb3708c8c5 | 5785 | break; |
whismanoid | 0:3edb3708c8c5 | 5786 | case 'e': case 'E': |
whismanoid | 0:3edb3708c8c5 | 5787 | { |
whismanoid | 0:3edb3708c8c5 | 5788 | // recommended for hex command codes E0..EF |
whismanoid | 0:3edb3708c8c5 | 5789 | } |
whismanoid | 0:3edb3708c8c5 | 5790 | break; |
whismanoid | 0:3edb3708c8c5 | 5791 | case 'f': case 'F': |
whismanoid | 0:3edb3708c8c5 | 5792 | { |
whismanoid | 0:3edb3708c8c5 | 5793 | // recommended for hex command codes F0..FF |
whismanoid | 0:3edb3708c8c5 | 5794 | } |
whismanoid | 0:3edb3708c8c5 | 5795 | break; |
whismanoid | 0:3edb3708c8c5 | 5796 | case 'x': case 'X': |
whismanoid | 0:3edb3708c8c5 | 5797 | { |
whismanoid | 0:3edb3708c8c5 | 5798 | } |
whismanoid | 0:3edb3708c8c5 | 5799 | break; |
whismanoid | 0:3edb3708c8c5 | 5800 | case 'y': case 'Y': |
whismanoid | 0:3edb3708c8c5 | 5801 | { |
whismanoid | 0:3edb3708c8c5 | 5802 | } |
whismanoid | 0:3edb3708c8c5 | 5803 | break; |
whismanoid | 0:3edb3708c8c5 | 5804 | case 'z': case 'Z': |
whismanoid | 0:3edb3708c8c5 | 5805 | { |
whismanoid | 0:3edb3708c8c5 | 5806 | } |
whismanoid | 0:3edb3708c8c5 | 5807 | break; |
whismanoid | 0:3edb3708c8c5 | 5808 | case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command |
whismanoid | 0:3edb3708c8c5 | 5809 | { |
whismanoid | 0:3edb3708c8c5 | 5810 | // TODO: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 5811 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5812 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5813 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5814 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5815 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5816 | } |
whismanoid | 0:3edb3708c8c5 | 5817 | break; |
whismanoid | 0:3edb3708c8c5 | 5818 | case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command |
whismanoid | 0:3edb3708c8c5 | 5819 | { |
whismanoid | 0:3edb3708c8c5 | 5820 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5821 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5822 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5823 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5824 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5825 | } |
whismanoid | 0:3edb3708c8c5 | 5826 | break; |
whismanoid | 10:228a52f8107d | 5827 | } // end switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 5828 | return false; // command not handled |
whismanoid | 10:228a52f8107d | 5829 | } // end bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 5830 | #endif |
whismanoid | 0:3edb3708c8c5 | 5831 | |
whismanoid | 0:3edb3708c8c5 | 5832 | |
whismanoid | 10:228a52f8107d | 5833 | //-------------------------------------------------- |
whismanoid | 10:228a52f8107d | 5834 | #if APPLICATION_MAX12345 // MAX12345_menu_onEOLcommandParser |
whismanoid | 10:228a52f8107d | 5835 | bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 5836 | { |
whismanoid | 10:228a52f8107d | 5837 | switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 5838 | { |
whismanoid | 10:228a52f8107d | 5839 | // TODO1: MAX12345 main_menu_onEOLcommandParser |
whismanoid | 0:3edb3708c8c5 | 5840 | case '0': |
whismanoid | 0:3edb3708c8c5 | 5841 | { |
whismanoid | 0:3edb3708c8c5 | 5842 | // recommended for hex command codes 00..0F |
whismanoid | 0:3edb3708c8c5 | 5843 | // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); |
whismanoid | 0:3edb3708c8c5 | 5844 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 5845 | uint16_t code; |
whismanoid | 0:3edb3708c8c5 | 5846 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 5847 | { |
whismanoid | 0:3edb3708c8c5 | 5848 | } |
whismanoid | 0:3edb3708c8c5 | 5849 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 5850 | { |
whismanoid | 0:3edb3708c8c5 | 5851 | } |
whismanoid | 0:3edb3708c8c5 | 5852 | if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG)) |
whismanoid | 0:3edb3708c8c5 | 5853 | { |
whismanoid | 0:3edb3708c8c5 | 5854 | isUpdatedSPIConfig = true; |
whismanoid | 0:3edb3708c8c5 | 5855 | } |
whismanoid | 0:3edb3708c8c5 | 5856 | cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 5857 | MAX5715_CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 5858 | cmdLine.serial().printf("\r\n placeholder"); |
whismanoid | 10:228a52f8107d | 5859 | return true; // command was handled by MAX12345 |
whismanoid | 0:3edb3708c8c5 | 5860 | } |
whismanoid | 0:3edb3708c8c5 | 5861 | break; |
whismanoid | 0:3edb3708c8c5 | 5862 | case '1': |
whismanoid | 0:3edb3708c8c5 | 5863 | { |
whismanoid | 0:3edb3708c8c5 | 5864 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5865 | } |
whismanoid | 0:3edb3708c8c5 | 5866 | break; |
whismanoid | 0:3edb3708c8c5 | 5867 | case '2': |
whismanoid | 0:3edb3708c8c5 | 5868 | { |
whismanoid | 0:3edb3708c8c5 | 5869 | // recommended for hex command codes 20..2F |
whismanoid | 0:3edb3708c8c5 | 5870 | } |
whismanoid | 0:3edb3708c8c5 | 5871 | break; |
whismanoid | 0:3edb3708c8c5 | 5872 | case '3': |
whismanoid | 0:3edb3708c8c5 | 5873 | { |
whismanoid | 0:3edb3708c8c5 | 5874 | // recommended for hex command codes 30..3F |
whismanoid | 0:3edb3708c8c5 | 5875 | } |
whismanoid | 0:3edb3708c8c5 | 5876 | break; |
whismanoid | 0:3edb3708c8c5 | 5877 | case '4': |
whismanoid | 0:3edb3708c8c5 | 5878 | { |
whismanoid | 0:3edb3708c8c5 | 5879 | // recommended for hex command codes 40..4F |
whismanoid | 0:3edb3708c8c5 | 5880 | } |
whismanoid | 0:3edb3708c8c5 | 5881 | break; |
whismanoid | 0:3edb3708c8c5 | 5882 | case '5': |
whismanoid | 0:3edb3708c8c5 | 5883 | { |
whismanoid | 0:3edb3708c8c5 | 5884 | // recommended for hex command codes 50..5F |
whismanoid | 0:3edb3708c8c5 | 5885 | } |
whismanoid | 0:3edb3708c8c5 | 5886 | break; |
whismanoid | 0:3edb3708c8c5 | 5887 | case '6': |
whismanoid | 0:3edb3708c8c5 | 5888 | { |
whismanoid | 0:3edb3708c8c5 | 5889 | // recommended for hex command codes 60..6F |
whismanoid | 0:3edb3708c8c5 | 5890 | } |
whismanoid | 0:3edb3708c8c5 | 5891 | break; |
whismanoid | 0:3edb3708c8c5 | 5892 | case '7': |
whismanoid | 0:3edb3708c8c5 | 5893 | { |
whismanoid | 0:3edb3708c8c5 | 5894 | // recommended for hex command codes 70..7F |
whismanoid | 0:3edb3708c8c5 | 5895 | } |
whismanoid | 0:3edb3708c8c5 | 5896 | break; |
whismanoid | 0:3edb3708c8c5 | 5897 | case '8': |
whismanoid | 0:3edb3708c8c5 | 5898 | { |
whismanoid | 0:3edb3708c8c5 | 5899 | // recommended for hex command codes 80..8F |
whismanoid | 0:3edb3708c8c5 | 5900 | } |
whismanoid | 0:3edb3708c8c5 | 5901 | break; |
whismanoid | 0:3edb3708c8c5 | 5902 | case '9': |
whismanoid | 0:3edb3708c8c5 | 5903 | { |
whismanoid | 0:3edb3708c8c5 | 5904 | // recommended for hex command codes 90..9F |
whismanoid | 0:3edb3708c8c5 | 5905 | } |
whismanoid | 0:3edb3708c8c5 | 5906 | break; |
whismanoid | 0:3edb3708c8c5 | 5907 | case 'a': case 'A': |
whismanoid | 0:3edb3708c8c5 | 5908 | { |
whismanoid | 0:3edb3708c8c5 | 5909 | // recommended for hex command codes A0..AF |
whismanoid | 0:3edb3708c8c5 | 5910 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 5911 | { |
whismanoid | 0:3edb3708c8c5 | 5912 | case 't': case 'T': |
whismanoid | 0:3edb3708c8c5 | 5913 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5914 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5915 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5916 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5917 | // AT command: skip the prompt to avoid confusing modem detector |
whismanoid | 0:3edb3708c8c5 | 5918 | return; |
whismanoid | 0:3edb3708c8c5 | 5919 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5920 | } |
whismanoid | 0:3edb3708c8c5 | 5921 | } |
whismanoid | 0:3edb3708c8c5 | 5922 | break; |
whismanoid | 0:3edb3708c8c5 | 5923 | case 'b': case 'B': |
whismanoid | 0:3edb3708c8c5 | 5924 | { |
whismanoid | 0:3edb3708c8c5 | 5925 | // recommended for hex command codes B0..BF |
whismanoid | 0:3edb3708c8c5 | 5926 | } |
whismanoid | 0:3edb3708c8c5 | 5927 | break; |
whismanoid | 0:3edb3708c8c5 | 5928 | case 'c': case 'C': |
whismanoid | 0:3edb3708c8c5 | 5929 | { |
whismanoid | 0:3edb3708c8c5 | 5930 | // recommended for hex command codes C0..CF |
whismanoid | 0:3edb3708c8c5 | 5931 | } |
whismanoid | 0:3edb3708c8c5 | 5932 | break; |
whismanoid | 0:3edb3708c8c5 | 5933 | case 'd': case 'D': |
whismanoid | 0:3edb3708c8c5 | 5934 | { |
whismanoid | 0:3edb3708c8c5 | 5935 | // recommended for hex command codes D0..DF |
whismanoid | 0:3edb3708c8c5 | 5936 | } |
whismanoid | 0:3edb3708c8c5 | 5937 | break; |
whismanoid | 0:3edb3708c8c5 | 5938 | case 'e': case 'E': |
whismanoid | 0:3edb3708c8c5 | 5939 | { |
whismanoid | 0:3edb3708c8c5 | 5940 | // recommended for hex command codes E0..EF |
whismanoid | 0:3edb3708c8c5 | 5941 | } |
whismanoid | 0:3edb3708c8c5 | 5942 | break; |
whismanoid | 0:3edb3708c8c5 | 5943 | case 'f': case 'F': |
whismanoid | 0:3edb3708c8c5 | 5944 | { |
whismanoid | 0:3edb3708c8c5 | 5945 | // recommended for hex command codes F0..FF |
whismanoid | 0:3edb3708c8c5 | 5946 | } |
whismanoid | 0:3edb3708c8c5 | 5947 | break; |
whismanoid | 0:3edb3708c8c5 | 5948 | case 'x': case 'X': |
whismanoid | 0:3edb3708c8c5 | 5949 | { |
whismanoid | 0:3edb3708c8c5 | 5950 | } |
whismanoid | 0:3edb3708c8c5 | 5951 | break; |
whismanoid | 0:3edb3708c8c5 | 5952 | case 'y': case 'Y': |
whismanoid | 0:3edb3708c8c5 | 5953 | { |
whismanoid | 0:3edb3708c8c5 | 5954 | } |
whismanoid | 0:3edb3708c8c5 | 5955 | break; |
whismanoid | 0:3edb3708c8c5 | 5956 | case 'z': case 'Z': |
whismanoid | 0:3edb3708c8c5 | 5957 | { |
whismanoid | 0:3edb3708c8c5 | 5958 | } |
whismanoid | 0:3edb3708c8c5 | 5959 | break; |
whismanoid | 0:3edb3708c8c5 | 5960 | case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command |
whismanoid | 0:3edb3708c8c5 | 5961 | { |
whismanoid | 0:3edb3708c8c5 | 5962 | // TODO: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 5963 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5964 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5965 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5966 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5967 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5968 | } |
whismanoid | 0:3edb3708c8c5 | 5969 | break; |
whismanoid | 0:3edb3708c8c5 | 5970 | case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command |
whismanoid | 0:3edb3708c8c5 | 5971 | { |
whismanoid | 0:3edb3708c8c5 | 5972 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5973 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5974 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5975 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 5976 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 5977 | } |
whismanoid | 0:3edb3708c8c5 | 5978 | break; |
whismanoid | 10:228a52f8107d | 5979 | } // end switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 5980 | return false; // command not handled |
whismanoid | 10:228a52f8107d | 5981 | } // end bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 5982 | #endif |
whismanoid | 10:228a52f8107d | 5983 | |
whismanoid | 10:228a52f8107d | 5984 | |
whismanoid | 10:228a52f8107d | 5985 | //-------------------------------------------------- |
whismanoid | 10:228a52f8107d | 5986 | // main menu command-line parser |
whismanoid | 10:228a52f8107d | 5987 | // invoked by CmdLine::append(char ch) or CmdLine::idleAppendIfReadable() |
whismanoid | 10:228a52f8107d | 5988 | void main_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 10:228a52f8107d | 5989 | { |
whismanoid | 10:228a52f8107d | 5990 | // DIAGNOSTIC: print line buffer |
whismanoid | 10:228a52f8107d | 5991 | //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str()); |
whismanoid | 10:228a52f8107d | 5992 | // |
whismanoid | 10:228a52f8107d | 5993 | switch (cmdLine[0]) |
whismanoid | 10:228a52f8107d | 5994 | { |
whismanoid | 10:228a52f8107d | 5995 | case '?': |
whismanoid | 10:228a52f8107d | 5996 | main_menu_status(cmdLine); |
whismanoid | 10:228a52f8107d | 5997 | main_menu_help(cmdLine); |
whismanoid | 10:228a52f8107d | 5998 | // print command prompt |
whismanoid | 10:228a52f8107d | 5999 | //cmdLine.serial().printf("\r\n>"); |
whismanoid | 10:228a52f8107d | 6000 | break; |
whismanoid | 10:228a52f8107d | 6001 | case '\r': case '\n': // ignore blank line |
whismanoid | 10:228a52f8107d | 6002 | case '\0': // ignore empty line |
whismanoid | 10:228a52f8107d | 6003 | case '#': // ignore comment line |
whismanoid | 10:228a52f8107d | 6004 | // # -- lines beginning with # are comments |
whismanoid | 10:228a52f8107d | 6005 | main_menu_status(cmdLine); |
whismanoid | 10:228a52f8107d | 6006 | //~ main_menu_help(cmdLine); |
whismanoid | 10:228a52f8107d | 6007 | // print command prompt |
whismanoid | 10:228a52f8107d | 6008 | //cmdLine.serial().printf("\r\n>"); |
whismanoid | 10:228a52f8107d | 6009 | break; |
whismanoid | 10:228a52f8107d | 6010 | #if ECHO_EOF_ON_EOL |
whismanoid | 10:228a52f8107d | 6011 | case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file |
whismanoid | 10:228a52f8107d | 6012 | cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting |
whismanoid | 10:228a52f8107d | 6013 | diagnostic_led_EOF(); |
whismanoid | 10:228a52f8107d | 6014 | break; |
whismanoid | 10:228a52f8107d | 6015 | case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file |
whismanoid | 10:228a52f8107d | 6016 | cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting |
whismanoid | 10:228a52f8107d | 6017 | diagnostic_led_EOF(); |
whismanoid | 10:228a52f8107d | 6018 | break; |
whismanoid | 10:228a52f8107d | 6019 | #endif |
whismanoid | 10:228a52f8107d | 6020 | #if APPLICATION_ArduinoPinsMonitor |
whismanoid | 10:228a52f8107d | 6021 | case '.': |
whismanoid | 10:228a52f8107d | 6022 | { |
whismanoid | 10:228a52f8107d | 6023 | // . -- SelfTest |
whismanoid | 10:228a52f8107d | 6024 | cmdLine.serial().printf("SelfTest()"); |
whismanoid | 10:228a52f8107d | 6025 | SelfTest(cmdLine); |
whismanoid | 10:228a52f8107d | 6026 | } |
whismanoid | 10:228a52f8107d | 6027 | break; |
whismanoid | 10:228a52f8107d | 6028 | case '%': |
whismanoid | 10:228a52f8107d | 6029 | { |
whismanoid | 10:228a52f8107d | 6030 | pinsMonitor_submenu_onEOLcommandParser(cmdLine); |
whismanoid | 10:228a52f8107d | 6031 | } |
whismanoid | 10:228a52f8107d | 6032 | break; // case '%' |
whismanoid | 10:228a52f8107d | 6033 | #endif // APPLICATION_ArduinoPinsMonitor |
whismanoid | 10:228a52f8107d | 6034 | // |
whismanoid | 10:228a52f8107d | 6035 | // Application-specific commands here |
whismanoid | 10:228a52f8107d | 6036 | // alphanumeric command codes A-Z,a-z,0-9 reserved for application use |
whismanoid | 10:228a52f8107d | 6037 | // |
whismanoid | 10:228a52f8107d | 6038 | #if APPLICATION_ArduinoPinsMonitor |
whismanoid | 10:228a52f8107d | 6039 | #endif // APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 6040 | |
whismanoid | 0:3edb3708c8c5 | 6041 | // |
whismanoid | 0:3edb3708c8c5 | 6042 | // TODO1: add new commands here |
whismanoid | 0:3edb3708c8c5 | 6043 | // |
whismanoid | 0:3edb3708c8c5 | 6044 | default: |
whismanoid | 10:228a52f8107d | 6045 | #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 10:228a52f8107d | 6046 | extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp |
whismanoid | 10:228a52f8107d | 6047 | if (!MAX5715_menu_onEOLcommandParser(cmdLine)) |
whismanoid | 10:228a52f8107d | 6048 | #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 10:228a52f8107d | 6049 | extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp |
whismanoid | 10:228a52f8107d | 6050 | if (!MAX11131_menu_onEOLcommandParser(cmdLine)) |
whismanoid | 10:228a52f8107d | 6051 | #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 10:228a52f8107d | 6052 | extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp |
whismanoid | 10:228a52f8107d | 6053 | if (!MAX5171_menu_onEOLcommandParser(cmdLine)) |
whismanoid | 10:228a52f8107d | 6054 | #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 10:228a52f8107d | 6055 | extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp |
whismanoid | 10:228a52f8107d | 6056 | if (!MAX11410_menu_onEOLcommandParser(cmdLine)) |
whismanoid | 10:228a52f8107d | 6057 | #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 10:228a52f8107d | 6058 | extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp |
whismanoid | 10:228a52f8107d | 6059 | if (!MAX12345_menu_onEOLcommandParser(cmdLine)) |
whismanoid | 10:228a52f8107d | 6060 | #else |
whismanoid | 10:228a52f8107d | 6061 | if (0) // not_handled_by_device_submenu |
whismanoid | 10:228a52f8107d | 6062 | #endif |
whismanoid | 10:228a52f8107d | 6063 | { |
whismanoid | 10:228a52f8107d | 6064 | cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 6065 | # if HAS_DAPLINK_SERIAL |
whismanoid | 10:228a52f8107d | 6066 | cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", |
whismanoid | 10:228a52f8107d | 6067 | cmdLine.str()[0], cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 6068 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 10:228a52f8107d | 6069 | } |
whismanoid | 0:3edb3708c8c5 | 6070 | } // switch (cmdLine[0]) |
whismanoid | 0:3edb3708c8c5 | 6071 | // |
whismanoid | 0:3edb3708c8c5 | 6072 | // print command prompt |
whismanoid | 0:3edb3708c8c5 | 6073 | #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 0:3edb3708c8c5 | 6074 | cmdLine.serial().printf("\r\nMAX5715 > "); |
whismanoid | 0:3edb3708c8c5 | 6075 | #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 0:3edb3708c8c5 | 6076 | cmdLine.serial().printf("\r\nMAX11131 > "); |
whismanoid | 0:3edb3708c8c5 | 6077 | #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 0:3edb3708c8c5 | 6078 | cmdLine.serial().printf("\r\nMAX5171 > "); |
whismanoid | 0:3edb3708c8c5 | 6079 | #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 0:3edb3708c8c5 | 6080 | cmdLine.serial().printf("\r\nMAX11410 > "); |
whismanoid | 0:3edb3708c8c5 | 6081 | #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 0:3edb3708c8c5 | 6082 | cmdLine.serial().printf("\r\nMAX12345 > "); |
whismanoid | 0:3edb3708c8c5 | 6083 | #else |
whismanoid | 0:3edb3708c8c5 | 6084 | cmdLine.serial().printf("\r\n> "); |
whismanoid | 0:3edb3708c8c5 | 6085 | #endif |
whismanoid | 10:228a52f8107d | 6086 | } // end void main_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 6087 | |
whismanoid | 0:3edb3708c8c5 | 6088 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 6089 | void InitializeConfiguration() |
whismanoid | 0:3edb3708c8c5 | 6090 | { |
whismanoid | 0:3edb3708c8c5 | 6091 | |
whismanoid | 0:3edb3708c8c5 | 6092 | #if APPLICATION_MAX5715 // InitializeConfiguration |
whismanoid | 0:3edb3708c8c5 | 6093 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6094 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX5715_Init()"); |
whismanoid | 0:3edb3708c8c5 | 6095 | # endif |
whismanoid | 7:bf501f8cb637 | 6096 | cmdLine_serial.serial().printf("\r\nMAX5715_Init()"); |
whismanoid | 0:3edb3708c8c5 | 6097 | int initResult = g_MAX5715_device.Init(); // defined in #include MAX5715.h |
whismanoid | 0:3edb3708c8c5 | 6098 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6099 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX5715_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 6100 | # endif |
whismanoid | 7:bf501f8cb637 | 6101 | cmdLine_serial.serial().printf("\r\nMAX5715_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 6102 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 6103 | |
whismanoid | 0:3edb3708c8c5 | 6104 | #if APPLICATION_MAX11131 // InitializeConfiguration |
whismanoid | 0:3edb3708c8c5 | 6105 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6106 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX11131_Init()"); |
whismanoid | 0:3edb3708c8c5 | 6107 | # endif |
whismanoid | 7:bf501f8cb637 | 6108 | cmdLine_serial.serial().printf("\r\nMAX11131_Init()"); |
whismanoid | 0:3edb3708c8c5 | 6109 | g_MAX11131_device.Init(); // defined in #include MAX11131.h |
whismanoid | 0:3edb3708c8c5 | 6110 | #endif // APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 6111 | |
whismanoid | 0:3edb3708c8c5 | 6112 | #if APPLICATION_MAX5171 // InitializeConfiguration |
whismanoid | 0:3edb3708c8c5 | 6113 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6114 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX5171_Init()"); |
whismanoid | 0:3edb3708c8c5 | 6115 | # endif |
whismanoid | 7:bf501f8cb637 | 6116 | cmdLine_serial.serial().printf("\r\nMAX5171_Init()"); |
whismanoid | 0:3edb3708c8c5 | 6117 | int initResult = g_MAX5171_device.Init(); // defined in #include MAX5171.h |
whismanoid | 0:3edb3708c8c5 | 6118 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6119 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX5171_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 6120 | # endif |
whismanoid | 7:bf501f8cb637 | 6121 | cmdLine_serial.serial().printf("\r\nMAX5171_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 6122 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 6123 | |
whismanoid | 0:3edb3708c8c5 | 6124 | #if APPLICATION_MAX11410 // InitializeConfiguration |
whismanoid | 0:3edb3708c8c5 | 6125 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6126 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX11410_Init()"); |
whismanoid | 0:3edb3708c8c5 | 6127 | # endif |
whismanoid | 7:bf501f8cb637 | 6128 | cmdLine_serial.serial().printf("\r\nMAX11410_Init()"); |
whismanoid | 0:3edb3708c8c5 | 6129 | int initResult = g_MAX11410_device.Init(); // defined in #include MAX11410.h |
whismanoid | 0:3edb3708c8c5 | 6130 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6131 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX11410_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 6132 | # endif |
whismanoid | 7:bf501f8cb637 | 6133 | cmdLine_serial.serial().printf("\r\nMAX11410_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 6134 | #endif // APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 6135 | |
whismanoid | 0:3edb3708c8c5 | 6136 | #if APPLICATION_MAX12345 // InitializeConfiguration |
whismanoid | 0:3edb3708c8c5 | 6137 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6138 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX12345_Init()"); |
whismanoid | 0:3edb3708c8c5 | 6139 | # endif |
whismanoid | 7:bf501f8cb637 | 6140 | cmdLine_serial.serial().printf("\r\nMAX12345_Init()"); |
whismanoid | 0:3edb3708c8c5 | 6141 | int initResult = MAX12345_Init(); // defined in #include MAX12345.h |
whismanoid | 0:3edb3708c8c5 | 6142 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6143 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX12345_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 6144 | # endif |
whismanoid | 7:bf501f8cb637 | 6145 | cmdLine_serial.serial().printf("\r\nMAX12345_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 6146 | #endif // APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 6147 | |
whismanoid | 0:3edb3708c8c5 | 6148 | } |
whismanoid | 0:3edb3708c8c5 | 6149 | |
whismanoid | 0:3edb3708c8c5 | 6150 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 6151 | // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 6152 | void diagnostic_led_EOF() |
whismanoid | 0:3edb3708c8c5 | 6153 | { |
whismanoid | 0:3edb3708c8c5 | 6154 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 6155 | led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 6156 | // 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 | 6157 | ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 6158 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 6159 | ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 6160 | led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 6161 | ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 6162 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 6163 | ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 6164 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 6165 | } |
whismanoid | 0:3edb3708c8c5 | 6166 | |
whismanoid | 0:3edb3708c8c5 | 6167 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 6168 | // Support commands that get handled immediately w/o waiting for EOL |
whismanoid | 0:3edb3708c8c5 | 6169 | // handled as immediate command, do not append to buffer |
whismanoid | 0:3edb3708c8c5 | 6170 | void on_immediate_0x21() // Unicode (U+0021) ! EXCLAMATION MARK |
whismanoid | 0:3edb3708c8c5 | 6171 | { |
whismanoid | 0:3edb3708c8c5 | 6172 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 6173 | led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 6174 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 6175 | InitializeConfiguration(); |
whismanoid | 0:3edb3708c8c5 | 6176 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6177 | } |
whismanoid | 0:3edb3708c8c5 | 6178 | |
whismanoid | 0:3edb3708c8c5 | 6179 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 6180 | // Support commands that get handled immediately w/o waiting for EOL |
whismanoid | 0:3edb3708c8c5 | 6181 | // handled as immediate command, do not append to buffer |
whismanoid | 0:3edb3708c8c5 | 6182 | void on_immediate_0x7b() // Unicode (U+007B) { LEFT CURLY BRACKET |
whismanoid | 0:3edb3708c8c5 | 6183 | { |
whismanoid | 0:3edb3708c8c5 | 6184 | #if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 6185 | onButton2FallingEdge(); |
whismanoid | 0:3edb3708c8c5 | 6186 | #endif |
whismanoid | 0:3edb3708c8c5 | 6187 | } |
whismanoid | 0:3edb3708c8c5 | 6188 | |
whismanoid | 0:3edb3708c8c5 | 6189 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 6190 | // Support commands that get handled immediately w/o waiting for EOL |
whismanoid | 0:3edb3708c8c5 | 6191 | // handled as immediate command, do not append to buffer |
whismanoid | 0:3edb3708c8c5 | 6192 | void on_immediate_0x7d() // Unicode (U+007D) } RIGHT CURLY BRACKET |
whismanoid | 0:3edb3708c8c5 | 6193 | { |
whismanoid | 0:3edb3708c8c5 | 6194 | #if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 6195 | onButton1FallingEdge(); |
whismanoid | 0:3edb3708c8c5 | 6196 | #endif |
whismanoid | 0:3edb3708c8c5 | 6197 | } |
whismanoid | 0:3edb3708c8c5 | 6198 | |
whismanoid | 0:3edb3708c8c5 | 6199 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 6200 | // based on example code: https://os.mbed.com/docs/v5.7/reference/pwmout.html |
whismanoid | 0:3edb3708c8c5 | 6201 | int main() |
whismanoid | 0:3edb3708c8c5 | 6202 | { |
whismanoid | 0:3edb3708c8c5 | 6203 | // Configure serial ports |
whismanoid | 0:3edb3708c8c5 | 6204 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 6205 | // Note: DAPLINKserial interferes with the timer tick interrupt. Try faster baud rate? |
whismanoid | 0:3edb3708c8c5 | 6206 | DAPLINKserial.baud(115200); // default 9600 baud |
whismanoid | 7:bf501f8cb637 | 6207 | //serial.baud(9600); // class USBSerial has no baud function |
whismanoid | 0:3edb3708c8c5 | 6208 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6209 | DAPLINKserial.printf("\r\n\r\nDAPLINK_SERIAL: main() startup\r\n"); |
whismanoid | 0:3edb3708c8c5 | 6210 | # endif |
whismanoid | 0:3edb3708c8c5 | 6211 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 6212 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 6213 | // MAX32625MBED crash if DAPLINKserial.baud(anything other than 9600 baud) |
whismanoid | 0:3edb3708c8c5 | 6214 | // xxx DAPLINKserial.baud(115200); // default 9600 baud |
whismanoid | 7:bf501f8cb637 | 6215 | //serial.baud(9600); // class USBSerial has no baud function |
whismanoid | 0:3edb3708c8c5 | 6216 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6217 | DAPLINKserial.printf("\r\n\r\nDAPLINK_SERIAL: main() startup\r\n"); |
whismanoid | 0:3edb3708c8c5 | 6218 | # endif |
whismanoid | 0:3edb3708c8c5 | 6219 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 6220 | #elif defined(TARGET_LPC1768) |
whismanoid | 7:bf501f8cb637 | 6221 | serial.baud(115200); // default 9600 baud |
whismanoid | 0:3edb3708c8c5 | 6222 | #else |
whismanoid | 0:3edb3708c8c5 | 6223 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 6224 | #endif |
whismanoid | 7:bf501f8cb637 | 6225 | cmdLine_serial.clear(); |
whismanoid | 7:bf501f8cb637 | 6226 | //~ cmdLine_serial.serial().printf("\r\n cmdLine_serial.serial().printf test\r\n"); |
whismanoid | 7:bf501f8cb637 | 6227 | cmdLine_serial.onEOLcommandParser = main_menu_onEOLcommandParser; |
whismanoid | 0:3edb3708c8c5 | 6228 | /// @todo CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21); |
whismanoid | 7:bf501f8cb637 | 6229 | cmdLine_serial.on_immediate_0x21 = on_immediate_0x21; |
whismanoid | 7:bf501f8cb637 | 6230 | cmdLine_serial.on_immediate_0x7b = on_immediate_0x7b; |
whismanoid | 7:bf501f8cb637 | 6231 | cmdLine_serial.on_immediate_0x7d = on_immediate_0x7d; |
whismanoid | 0:3edb3708c8c5 | 6232 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6233 | cmdLine_DAPLINKserial.clear(); |
whismanoid | 0:3edb3708c8c5 | 6234 | //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n"); |
whismanoid | 0:3edb3708c8c5 | 6235 | cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser; |
whismanoid | 0:3edb3708c8c5 | 6236 | /// @todo CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21); |
whismanoid | 0:3edb3708c8c5 | 6237 | cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21; |
whismanoid | 0:3edb3708c8c5 | 6238 | cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b; |
whismanoid | 0:3edb3708c8c5 | 6239 | cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d; |
whismanoid | 0:3edb3708c8c5 | 6240 | # endif |
whismanoid | 0:3edb3708c8c5 | 6241 | |
whismanoid | 0:3edb3708c8c5 | 6242 | |
whismanoid | 0:3edb3708c8c5 | 6243 | print_banner(); |
whismanoid | 0:3edb3708c8c5 | 6244 | |
whismanoid | 0:3edb3708c8c5 | 6245 | //#ifdef SCOPE_TRIG_PIN |
whismanoid | 0:3edb3708c8c5 | 6246 | // scopePinP12 = 0; |
whismanoid | 0:3edb3708c8c5 | 6247 | // scopePinP12 = 1; |
whismanoid | 0:3edb3708c8c5 | 6248 | //#endif // SCOPE_TRIG_PIN |
whismanoid | 0:3edb3708c8c5 | 6249 | |
whismanoid | 0:3edb3708c8c5 | 6250 | #if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 6251 | # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 6252 | # else |
whismanoid | 0:3edb3708c8c5 | 6253 | button1.fall(&onButton1FallingEdge); |
whismanoid | 0:3edb3708c8c5 | 6254 | # endif |
whismanoid | 0:3edb3708c8c5 | 6255 | #endif // HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 6256 | #if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 6257 | # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 6258 | # else |
whismanoid | 0:3edb3708c8c5 | 6259 | button2.fall(&onButton2FallingEdge); |
whismanoid | 0:3edb3708c8c5 | 6260 | # endif |
whismanoid | 0:3edb3708c8c5 | 6261 | #endif // HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 6262 | |
whismanoid | 0:3edb3708c8c5 | 6263 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 6264 | // spi init |
whismanoid | 0:3edb3708c8c5 | 6265 | // mode | POL PHA |
whismanoid | 0:3edb3708c8c5 | 6266 | // -----+-------- |
whismanoid | 0:3edb3708c8c5 | 6267 | // 0 | 0 0 |
whismanoid | 0:3edb3708c8c5 | 6268 | // 1 | 0 1 |
whismanoid | 0:3edb3708c8c5 | 6269 | // 2 | 1 0 |
whismanoid | 0:3edb3708c8c5 | 6270 | // 3 | 1 1 |
whismanoid | 0:3edb3708c8c5 | 6271 | //~ spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 6272 | //~ spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 6273 | //~ spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 6274 | //~ spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 6275 | // |
whismanoid | 0:3edb3708c8c5 | 6276 | //~ spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default) |
whismanoid | 0:3edb3708c8c5 | 6277 | //~ spi.frequency(9600000); // int SCLK_Hz=9600000 = 9.6MHz = 96MHz/10 |
whismanoid | 0:3edb3708c8c5 | 6278 | //~ spi.frequency(10666666); // int SCLK_Hz=10666666 = 10.6MHz = 96MHz/9 |
whismanoid | 0:3edb3708c8c5 | 6279 | //~ spi.frequency(12000000); // int SCLK_Hz=12000000 = 12MHz = 96MHz/8 |
whismanoid | 0:3edb3708c8c5 | 6280 | //~ spi.frequency(13714286); // int SCLK_Hz=13714286 = 13.7MHz = 96MHz/7 |
whismanoid | 0:3edb3708c8c5 | 6281 | //~ spi.frequency(16000000); // int SCLK_Hz=16000000 = 16MHz = 96MHz/6 |
whismanoid | 0:3edb3708c8c5 | 6282 | //~ spi.frequency(19200000); // int SCLK_Hz=19200000 = 19.2MHz = 96MHz/5 |
whismanoid | 0:3edb3708c8c5 | 6283 | //~ spi.frequency(24000000); // int SCLK_Hz=24000000 = 24MHz = 96MHz/4 |
whismanoid | 0:3edb3708c8c5 | 6284 | //~ spi.frequency(32000000); // int SCLK_Hz=32000000 = 32MHz = 96MHz/3 |
whismanoid | 0:3edb3708c8c5 | 6285 | //~ spi.frequency(48000000); // int SCLK_Hz=48000000 = 48MHz = 96MHz/2 |
whismanoid | 0:3edb3708c8c5 | 6286 | // unspecified SPI device |
whismanoid | 0:3edb3708c8c5 | 6287 | 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 | 6288 | spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default) |
whismanoid | 0:3edb3708c8c5 | 6289 | spi_cs = 1; |
whismanoid | 0:3edb3708c8c5 | 6290 | #endif |
whismanoid | 0:3edb3708c8c5 | 6291 | |
whismanoid | 0:3edb3708c8c5 | 6292 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 6293 | // i2c init |
whismanoid | 0:3edb3708c8c5 | 6294 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 0:3edb3708c8c5 | 6295 | // i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 6296 | #else |
whismanoid | 0:3edb3708c8c5 | 6297 | // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 |
whismanoid | 0:3edb3708c8c5 | 6298 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 6299 | // DigitalInOut digitalInOut14(P1_6, PIN_INPUT, PullUp, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 6300 | digitalInOut14.input(); |
whismanoid | 0:3edb3708c8c5 | 6301 | #endif |
whismanoid | 0:3edb3708c8c5 | 6302 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 6303 | // DigitalInOut digitalInOut15(P1_7, PIN_INPUT, PullUp, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 6304 | digitalInOut15.input(); |
whismanoid | 0:3edb3708c8c5 | 6305 | #endif |
whismanoid | 0:3edb3708c8c5 | 6306 | #if HAS_digitalInOut16 |
whismanoid | 0:3edb3708c8c5 | 6307 | // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain |
whismanoid | 0:3edb3708c8c5 | 6308 | // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V |
whismanoid | 0:3edb3708c8c5 | 6309 | //DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 6310 | digitalInOut16.input(); |
whismanoid | 0:3edb3708c8c5 | 6311 | #endif |
whismanoid | 0:3edb3708c8c5 | 6312 | #if HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 6313 | //DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 6314 | digitalInOut17.input(); |
whismanoid | 0:3edb3708c8c5 | 6315 | #endif |
whismanoid | 0:3edb3708c8c5 | 6316 | #endif |
whismanoid | 0:3edb3708c8c5 | 6317 | |
whismanoid | 0:3edb3708c8c5 | 6318 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 6319 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 6320 | led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 6321 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6322 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 6323 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6324 | led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 6325 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6326 | led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 6327 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6328 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 6329 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6330 | led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 6331 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6332 | led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 6333 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6334 | led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 6335 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6336 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 6337 | led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 6338 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6339 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 6340 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6341 | led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 6342 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6343 | led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 6344 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6345 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 6346 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6347 | led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 6348 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6349 | led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 6350 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6351 | led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 6352 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 6353 | #else // not defined(TARGET_LPC1768 etc.) |
whismanoid | 0:3edb3708c8c5 | 6354 | led1 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 6355 | led2 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 6356 | led3 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 6357 | led4 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 6358 | ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); |
whismanoid | 0:3edb3708c8c5 | 6359 | //led1 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 6360 | led2 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 6361 | ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); |
whismanoid | 0:3edb3708c8c5 | 6362 | led1 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 6363 | //led2 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 6364 | led3 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 6365 | ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); |
whismanoid | 0:3edb3708c8c5 | 6366 | led2 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 6367 | //led3 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 6368 | led4 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 6369 | ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); |
whismanoid | 0:3edb3708c8c5 | 6370 | led3 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 6371 | led4 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 6372 | // |
whismanoid | 0:3edb3708c8c5 | 6373 | #endif // target definition |
whismanoid | 0:3edb3708c8c5 | 6374 | #endif |
whismanoid | 0:3edb3708c8c5 | 6375 | |
whismanoid | 0:3edb3708c8c5 | 6376 | // cmd_TE(); |
whismanoid | 0:3edb3708c8c5 | 6377 | |
whismanoid | 0:3edb3708c8c5 | 6378 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 6379 | rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 6380 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 6381 | InitializeConfiguration(); |
whismanoid | 0:3edb3708c8c5 | 6382 | |
whismanoid | 0:3edb3708c8c5 | 6383 | while (1) { |
whismanoid | 0:3edb3708c8c5 | 6384 | #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 6385 | // avoid runtime error on button1 press [mbed-os-5.11] |
whismanoid | 0:3edb3708c8c5 | 6386 | // instead of using InterruptIn, use DigitalIn and poll in main while(1) |
whismanoid | 0:3edb3708c8c5 | 6387 | # if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 6388 | static int button1_value_prev = 1; |
whismanoid | 0:3edb3708c8c5 | 6389 | static int button1_value_now = 1; |
whismanoid | 0:3edb3708c8c5 | 6390 | button1_value_prev = button1_value_now; |
whismanoid | 0:3edb3708c8c5 | 6391 | button1_value_now = button1.read(); |
whismanoid | 0:3edb3708c8c5 | 6392 | if ((button1_value_prev - button1_value_now) == 1) |
whismanoid | 0:3edb3708c8c5 | 6393 | { |
whismanoid | 0:3edb3708c8c5 | 6394 | // on button1 falling edge (button1 press) |
whismanoid | 0:3edb3708c8c5 | 6395 | onButton1FallingEdge(); |
whismanoid | 0:3edb3708c8c5 | 6396 | } |
whismanoid | 0:3edb3708c8c5 | 6397 | # endif // HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 6398 | # if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 6399 | static int button2_value_prev = 1; |
whismanoid | 0:3edb3708c8c5 | 6400 | static int button2_value_now = 1; |
whismanoid | 0:3edb3708c8c5 | 6401 | button2_value_prev = button2_value_now; |
whismanoid | 0:3edb3708c8c5 | 6402 | button2_value_now = button2.read(); |
whismanoid | 0:3edb3708c8c5 | 6403 | if ((button2_value_prev - button2_value_now) == 1) |
whismanoid | 0:3edb3708c8c5 | 6404 | { |
whismanoid | 0:3edb3708c8c5 | 6405 | // on button2 falling edge (button2 press) |
whismanoid | 0:3edb3708c8c5 | 6406 | onButton2FallingEdge(); |
whismanoid | 0:3edb3708c8c5 | 6407 | } |
whismanoid | 0:3edb3708c8c5 | 6408 | # endif // HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 6409 | #endif |
whismanoid | 0:3edb3708c8c5 | 6410 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6411 | if (DAPLINKserial.readable()) { |
whismanoid | 0:3edb3708c8c5 | 6412 | cmdLine_DAPLINKserial.append(DAPLINKserial.getc()); |
whismanoid | 0:3edb3708c8c5 | 6413 | } |
whismanoid | 0:3edb3708c8c5 | 6414 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 7:bf501f8cb637 | 6415 | if (serial.readable()) { |
whismanoid | 7:bf501f8cb637 | 6416 | int c = serial.getc(); |
whismanoid | 7:bf501f8cb637 | 6417 | cmdLine_serial.append(c); |
whismanoid | 0:3edb3708c8c5 | 6418 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6419 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6420 | cmdLine_DAPLINKserial.serial().printf("%c", c); |
whismanoid | 0:3edb3708c8c5 | 6421 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6422 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6423 | // |
whismanoid | 0:3edb3708c8c5 | 6424 | } |
whismanoid | 0:3edb3708c8c5 | 6425 | } // while(1) |
whismanoid | 0:3edb3708c8c5 | 6426 | } |