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@0:3edb3708c8c5, 2019-06-10 (annotated)
- Committer:
- whismanoid
- Date:
- Mon Jun 10 07:53:42 2019 +0000
- Revision:
- 0:3edb3708c8c5
- Child:
- 1:40369075c365
based on sandbox monster, need remove unrelated products; does online ide not support c++11 lambda expressions?
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 | #include "mbed.h" |
whismanoid | 0:3edb3708c8c5 | 35 | #include "USBSerial.h" |
whismanoid | 0:3edb3708c8c5 | 36 | |
whismanoid | 0:3edb3708c8c5 | 37 | #include "CmdLine.h" |
whismanoid | 0:3edb3708c8c5 | 38 | #include "MaximTinyTester.h" |
whismanoid | 0:3edb3708c8c5 | 39 | |
whismanoid | 0:3edb3708c8c5 | 40 | #include "MAX5715.h" |
whismanoid | 0:3edb3708c8c5 | 41 | |
whismanoid | 0:3edb3708c8c5 | 42 | // TODO: trim cruft |
whismanoid | 0:3edb3708c8c5 | 43 | |
whismanoid | 0:3edb3708c8c5 | 44 | |
whismanoid | 0:3edb3708c8c5 | 45 | |
whismanoid | 0:3edb3708c8c5 | 46 | //---------------------------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 47 | // mbed-os compatability tests... |
whismanoid | 0:3edb3708c8c5 | 48 | //---------------------------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 49 | // mbed-os-5.12: buildable; warnings |
whismanoid | 0:3edb3708c8c5 | 50 | // |
whismanoid | 0:3edb3708c8c5 | 51 | // Not supported by MAX32625MBED... better stick with mbed-os-5.11 for now. |
whismanoid | 0:3edb3708c8c5 | 52 | // Watch out for conflict with USBDevice library. |
whismanoid | 0:3edb3708c8c5 | 53 | // Now that USBSerial is part of the official mbed-os-5.12 API, |
whismanoid | 0:3edb3708c8c5 | 54 | // remove the external USBDevice library if present: |
whismanoid | 0:3edb3708c8c5 | 55 | // mbed remove USBDevice |
whismanoid | 0:3edb3708c8c5 | 56 | // |
whismanoid | 0:3edb3708c8c5 | 57 | // cd mbed-os ; mbed update mbed-os-5.12 ; cd ..; mbed remove USBDevice |
whismanoid | 0:3edb3708c8c5 | 58 | //---------------------------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 59 | // mbed-os-5.11: buildable; warnings |
whismanoid | 0:3edb3708c8c5 | 60 | // |
whismanoid | 0:3edb3708c8c5 | 61 | // fixed: format '%d' expects argument of type 'int', but argument _ has type 'uint32_t {aka long unsigned int}' [-Wformat=] |
whismanoid | 0:3edb3708c8c5 | 62 | // fixed: '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 | 63 | // |
whismanoid | 0:3edb3708c8c5 | 64 | // prior to mbed-os-5.12, USBSerial required an external library: |
whismanoid | 0:3edb3708c8c5 | 65 | // mbed add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ |
whismanoid | 0:3edb3708c8c5 | 66 | // |
whismanoid | 0:3edb3708c8c5 | 67 | // cd mbed-os ; mbed update mbed-os-5.11 |
whismanoid | 0:3edb3708c8c5 | 68 | // cd .. ; mbed sync |
whismanoid | 0:3edb3708c8c5 | 69 | //---------------------------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 70 | // mbed-os-5.10 buildable; warning about wait function |
whismanoid | 0:3edb3708c8c5 | 71 | // '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 | 72 | // |
whismanoid | 0:3edb3708c8c5 | 73 | // prior to mbed-os-5.12, USBSerial required an external library: |
whismanoid | 0:3edb3708c8c5 | 74 | // mbed add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ |
whismanoid | 0:3edb3708c8c5 | 75 | // |
whismanoid | 0:3edb3708c8c5 | 76 | // cd mbed-os ; mbed update mbed-os-5.10 |
whismanoid | 0:3edb3708c8c5 | 77 | // cd .. ; mbed sync |
whismanoid | 0:3edb3708c8c5 | 78 | //---------------------------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 79 | // mbed-os-5.9 buildable |
whismanoid | 0:3edb3708c8c5 | 80 | // |
whismanoid | 0:3edb3708c8c5 | 81 | // prior to mbed-os-5.12, USBSerial required an external library: |
whismanoid | 0:3edb3708c8c5 | 82 | // mbed add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ |
whismanoid | 0:3edb3708c8c5 | 83 | // |
whismanoid | 0:3edb3708c8c5 | 84 | // cd mbed-os ; mbed update mbed-os-5.9 |
whismanoid | 0:3edb3708c8c5 | 85 | // cd .. ; mbed sync |
whismanoid | 0:3edb3708c8c5 | 86 | //---------------------------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 87 | // mbed-os-5.8 buildable |
whismanoid | 0:3edb3708c8c5 | 88 | // |
whismanoid | 0:3edb3708c8c5 | 89 | // prior to mbed-os-5.12, USBSerial required an external library: |
whismanoid | 0:3edb3708c8c5 | 90 | // mbed add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ |
whismanoid | 0:3edb3708c8c5 | 91 | // |
whismanoid | 0:3edb3708c8c5 | 92 | // cd mbed-os ; mbed update mbed-os-5.8 |
whismanoid | 0:3edb3708c8c5 | 93 | // cd .. ; mbed sync |
whismanoid | 0:3edb3708c8c5 | 94 | //--------------------------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 95 | // mbed-os-5.7 buildable |
whismanoid | 0:3edb3708c8c5 | 96 | // |
whismanoid | 0:3edb3708c8c5 | 97 | // prior to mbed-os-5.12, USBSerial required an external library: |
whismanoid | 0:3edb3708c8c5 | 98 | // mbed add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ |
whismanoid | 0:3edb3708c8c5 | 99 | // |
whismanoid | 0:3edb3708c8c5 | 100 | // cd mbed-os ; mbed update mbed-os-5.7 |
whismanoid | 0:3edb3708c8c5 | 101 | // cd .. ; mbed sync |
whismanoid | 0:3edb3708c8c5 | 102 | //---------------------------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 103 | // mbed-os-5.6 pass |
whismanoid | 0:3edb3708c8c5 | 104 | // [Warning] USBSerial.h@59,203: 'mbed::FunctionPointerArg1<R, void>::FunctionPointerArg1(R (*)()) [with R = void]' is deprecated: FunctionPointer has been replaced by Callback<void()> [since mbed-os-5.1] [-Wdeprecated-declarations] |
whismanoid | 0:3edb3708c8c5 | 105 | // [Warning] USBSerial.h@134,27: 'void mbed::Callback<R()>::attach(R (*)()) [with R = void]' is deprecated: Replaced by simple assignment 'Callback cb = func [since mbed-os-5.4] [-Wdeprecated-declarations] |
whismanoid | 0:3edb3708c8c5 | 106 | // |
whismanoid | 0:3edb3708c8c5 | 107 | // prior to mbed-os-5.12, USBSerial required an external library: |
whismanoid | 0:3edb3708c8c5 | 108 | // mbed add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ |
whismanoid | 0:3edb3708c8c5 | 109 | // |
whismanoid | 0:3edb3708c8c5 | 110 | // cd mbed-os ; mbed update mbed-os-5.6 |
whismanoid | 0:3edb3708c8c5 | 111 | // cd .. ; mbed sync |
whismanoid | 0:3edb3708c8c5 | 112 | //---------------------------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 113 | |
whismanoid | 0:3edb3708c8c5 | 114 | // Test fixture and application menu for breakout boards: |
whismanoid | 0:3edb3708c8c5 | 115 | // - MAX5715BOB |
whismanoid | 0:3edb3708c8c5 | 116 | // - MAX11131BOB |
whismanoid | 0:3edb3708c8c5 | 117 | // - MAX5171BOB |
whismanoid | 0:3edb3708c8c5 | 118 | // Platforms: |
whismanoid | 0:3edb3708c8c5 | 119 | // - MAX32625MBED |
whismanoid | 0:3edb3708c8c5 | 120 | // - NUCLEO_F446RE |
whismanoid | 0:3edb3708c8c5 | 121 | // - NUCLEO_F401RE |
whismanoid | 0:3edb3708c8c5 | 122 | |
whismanoid | 0:3edb3708c8c5 | 123 | #include "mbed.h" |
whismanoid | 0:3edb3708c8c5 | 124 | #if defined(TARGET) |
whismanoid | 0:3edb3708c8c5 | 125 | // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h |
whismanoid | 0:3edb3708c8c5 | 126 | // Create a string definition for the TARGET |
whismanoid | 0:3edb3708c8c5 | 127 | #define STRING_ARG(arg) #arg |
whismanoid | 0:3edb3708c8c5 | 128 | #define STRING_NAME(name) STRING_ARG(name) |
whismanoid | 0:3edb3708c8c5 | 129 | #define TARGET_NAME STRING_NAME(TARGET) |
whismanoid | 0:3edb3708c8c5 | 130 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 131 | #define TARGET_NAME "LPC1768" |
whismanoid | 0:3edb3708c8c5 | 132 | #elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 133 | #define TARGET_NAME "NUCLEO_F446RE" |
whismanoid | 0:3edb3708c8c5 | 134 | #elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 135 | #define TARGET_NAME "NUCLEO_F401RE" |
whismanoid | 0:3edb3708c8c5 | 136 | #else |
whismanoid | 0:3edb3708c8c5 | 137 | #error TARGET NOT DEFINED |
whismanoid | 0:3edb3708c8c5 | 138 | #endif |
whismanoid | 0:3edb3708c8c5 | 139 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 140 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 141 | // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM |
whismanoid | 0:3edb3708c8c5 | 142 | // +-------------[microUSB]-------------+ |
whismanoid | 0:3edb3708c8c5 | 143 | // | J1 MAX32630FTHR J2 | |
whismanoid | 0:3edb3708c8c5 | 144 | // ______ | [ ] RST GND [ ] | |
whismanoid | 0:3edb3708c8c5 | 145 | // ______ | [ ] 3V3 BAT+[ ] | |
whismanoid | 0:3edb3708c8c5 | 146 | // ______ | [ ] 1V8 reset SW1 | |
whismanoid | 0:3edb3708c8c5 | 147 | // ______ | [ ] GND J4 J3 | |
whismanoid | 0:3edb3708c8c5 | 148 | // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+ |
whismanoid | 0:3edb3708c8c5 | 149 | // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn |
whismanoid | 0:3edb3708c8c5 | 150 | // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power |
whismanoid | 0:3edb3708c8c5 | 151 | // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | dig9 |
whismanoid | 0:3edb3708c8c5 | 152 | // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | dig8 |
whismanoid | 0:3edb3708c8c5 | 153 | // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | dig7 |
whismanoid | 0:3edb3708c8c5 | 154 | // (SPI.SCLK) | [s] P5_0 SCLK SDIO2 P5_4 [d] | dig6 |
whismanoid | 0:3edb3708c8c5 | 155 | // (SPI.MOSI) | [s] P5_1 MOSI SSEL P5_3 [d] | dig5 |
whismanoid | 0:3edb3708c8c5 | 156 | // (SPI.MISO) | [s] P5_2 MISO RTS P3_3 [d] | dig4 |
whismanoid | 0:3edb3708c8c5 | 157 | // (SPI.CS ) | [s] P3_0 RX CTS P3_2 [d] | dig3 |
whismanoid | 0:3edb3708c8c5 | 158 | // dig0 | [d] P3_1 TX SCL P3_5 [d] | dig2 |
whismanoid | 0:3edb3708c8c5 | 159 | // ______ | [ ] GND SDA P3_4 [d] | dig1 |
whismanoid | 0:3edb3708c8c5 | 160 | // | | |
whismanoid | 0:3edb3708c8c5 | 161 | // | XIP Flash MAX14690N | |
whismanoid | 0:3edb3708c8c5 | 162 | // | XIP_SCLK P1_0 SDA2 P5_7 | |
whismanoid | 0:3edb3708c8c5 | 163 | // | XIP_MOSI P1_1 SCL2 P6_0 | |
whismanoid | 0:3edb3708c8c5 | 164 | // | XIP_MISO P1_2 PMIC_INIT P3_7 | |
whismanoid | 0:3edb3708c8c5 | 165 | // | XIP_SSEL P1_3 MPC P2_7 | |
whismanoid | 0:3edb3708c8c5 | 166 | // | XIP_DIO2 P1_4 MON AIN_0 | |
whismanoid | 0:3edb3708c8c5 | 167 | // | XIP_DIO3 P1_5 | |
whismanoid | 0:3edb3708c8c5 | 168 | // | | |
whismanoid | 0:3edb3708c8c5 | 169 | // | PAN1326B MicroSD LED | |
whismanoid | 0:3edb3708c8c5 | 170 | // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 | |
whismanoid | 0:3edb3708c8c5 | 171 | // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 | |
whismanoid | 0:3edb3708c8c5 | 172 | // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 | |
whismanoid | 0:3edb3708c8c5 | 173 | // | BT_RTS P0_3 SD_SSEL P0_7 | |
whismanoid | 0:3edb3708c8c5 | 174 | // | BT_RST P1_6 DETECT P2_2 | |
whismanoid | 0:3edb3708c8c5 | 175 | // | BT_CLK P1_7 SW2 P2_3 | |
whismanoid | 0:3edb3708c8c5 | 176 | // +------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 177 | // 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 | 178 | // 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 | 179 | // AIN_0 = AIN0 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 180 | // AIN_1 = AIN1 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 181 | // AIN_2 = AIN2 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 182 | // AIN_3 = AIN3 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 183 | // AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 184 | // AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 185 | // AIN_6 = VDDB / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 186 | // AIN_7 = VDD18 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 187 | // AIN_8 = VDD12 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 188 | // AIN_9 = VRTC / 2.0 fullscale is 2.4V |
whismanoid | 0:3edb3708c8c5 | 189 | // AIN_10 = x undefined? |
whismanoid | 0:3edb3708c8c5 | 190 | // AIN_11 = VDDIO / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 191 | // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 192 | // |
whismanoid | 0:3edb3708c8c5 | 193 | #include "max32630fthr.h" |
whismanoid | 0:3edb3708c8c5 | 194 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
whismanoid | 0:3edb3708c8c5 | 195 | #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 196 | // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15 |
whismanoid | 0:3edb3708c8c5 | 197 | const float ADC_FULL_SCALE_VOLTAGE = 1.200; |
whismanoid | 0:3edb3708c8c5 | 198 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 199 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 200 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 201 | // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 202 | // +-------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 203 | // | MAX32625MBED Arduino UNO header | |
whismanoid | 0:3edb3708c8c5 | 204 | // | | |
whismanoid | 0:3edb3708c8c5 | 205 | // | A5/SCL[ ] | P1_7 dig15 |
whismanoid | 0:3edb3708c8c5 | 206 | // | A4/SDA[ ] | P1_6 dig14 |
whismanoid | 0:3edb3708c8c5 | 207 | // | AREF=N/C[ ] | |
whismanoid | 0:3edb3708c8c5 | 208 | // | GND[ ] | |
whismanoid | 0:3edb3708c8c5 | 209 | // | [ ]N/C SCK/13[ ] | P1_0 dig13 |
whismanoid | 0:3edb3708c8c5 | 210 | // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12 |
whismanoid | 0:3edb3708c8c5 | 211 | // | [ ]RST MOSI/11[ ]~| P1_1 dig11 |
whismanoid | 0:3edb3708c8c5 | 212 | // | [ ]3V3 CS/10[ ]~| P1_3 dig10 |
whismanoid | 0:3edb3708c8c5 | 213 | // | [ ]5V0 9[ ]~| P1_5 dig9 |
whismanoid | 0:3edb3708c8c5 | 214 | // | [ ]GND 8[ ] | P1_4 dig8 |
whismanoid | 0:3edb3708c8c5 | 215 | // | [ ]GND | |
whismanoid | 0:3edb3708c8c5 | 216 | // | [ ]Vin 7[ ] | P0_7 dig7 |
whismanoid | 0:3edb3708c8c5 | 217 | // | 6[ ]~| P0_6 dig6 |
whismanoid | 0:3edb3708c8c5 | 218 | // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5 |
whismanoid | 0:3edb3708c8c5 | 219 | // AIN_1 | [ ]A1 4[ ] | P0_4 dig4 |
whismanoid | 0:3edb3708c8c5 | 220 | // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3 |
whismanoid | 0:3edb3708c8c5 | 221 | // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2 |
whismanoid | 0:3edb3708c8c5 | 222 | // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1 |
whismanoid | 0:3edb3708c8c5 | 223 | // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0 |
whismanoid | 0:3edb3708c8c5 | 224 | // | [ ] [ ] [ ] | |
whismanoid | 0:3edb3708c8c5 | 225 | // | UNO_R3 GND MOSI 5V ____________/ |
whismanoid | 0:3edb3708c8c5 | 226 | // \_______________________/ |
whismanoid | 0:3edb3708c8c5 | 227 | // |
whismanoid | 0:3edb3708c8c5 | 228 | // +------------------------+ |
whismanoid | 0:3edb3708c8c5 | 229 | // | | |
whismanoid | 0:3edb3708c8c5 | 230 | // | MicroSD LED | |
whismanoid | 0:3edb3708c8c5 | 231 | // | SD_SCLK P2_4 r P3_0 | |
whismanoid | 0:3edb3708c8c5 | 232 | // | SD_MOSI P2_5 g P3_1 | |
whismanoid | 0:3edb3708c8c5 | 233 | // | SD_MISO P2_6 b P3_2 | |
whismanoid | 0:3edb3708c8c5 | 234 | // | SD_SSEL P2_7 y P3_3 | |
whismanoid | 0:3edb3708c8c5 | 235 | // | | |
whismanoid | 0:3edb3708c8c5 | 236 | // | DAPLINK BUTTONS | |
whismanoid | 0:3edb3708c8c5 | 237 | // | TX P2_1 SW3 P2_3 | |
whismanoid | 0:3edb3708c8c5 | 238 | // | RX P2_0 SW2 P2_2 | |
whismanoid | 0:3edb3708c8c5 | 239 | // +------------------------+ |
whismanoid | 0:3edb3708c8c5 | 240 | // |
whismanoid | 0:3edb3708c8c5 | 241 | // AIN_0 = AIN0 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 242 | // AIN_1 = AIN1 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 243 | // AIN_2 = AIN2 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 244 | // AIN_3 = AIN3 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 245 | // AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 246 | // AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 247 | // AIN_6 = VDDB / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 248 | // AIN_7 = VDD18 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 249 | // AIN_8 = VDD12 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 250 | // AIN_9 = VRTC / 2.0 fullscale is 2.4V |
whismanoid | 0:3edb3708c8c5 | 251 | // AIN_10 = x undefined? |
whismanoid | 0:3edb3708c8c5 | 252 | // AIN_11 = VDDIO / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 253 | // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 254 | // |
whismanoid | 0:3edb3708c8c5 | 255 | //#include "max32625mbed.h" // ? |
whismanoid | 0:3edb3708c8c5 | 256 | //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ? |
whismanoid | 0:3edb3708c8c5 | 257 | #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 258 | // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15 |
whismanoid | 0:3edb3708c8c5 | 259 | const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico? |
whismanoid | 0:3edb3708c8c5 | 260 | // Arduino connector |
whismanoid | 0:3edb3708c8c5 | 261 | #ifndef A0 |
whismanoid | 0:3edb3708c8c5 | 262 | #define A0 AIN_0 |
whismanoid | 0:3edb3708c8c5 | 263 | #endif |
whismanoid | 0:3edb3708c8c5 | 264 | #ifndef A1 |
whismanoid | 0:3edb3708c8c5 | 265 | #define A1 AIN_1 |
whismanoid | 0:3edb3708c8c5 | 266 | #endif |
whismanoid | 0:3edb3708c8c5 | 267 | #ifndef A2 |
whismanoid | 0:3edb3708c8c5 | 268 | #define A2 AIN_2 |
whismanoid | 0:3edb3708c8c5 | 269 | #endif |
whismanoid | 0:3edb3708c8c5 | 270 | #ifndef A3 |
whismanoid | 0:3edb3708c8c5 | 271 | #define A3 AIN_3 |
whismanoid | 0:3edb3708c8c5 | 272 | #endif |
whismanoid | 0:3edb3708c8c5 | 273 | #ifndef D0 |
whismanoid | 0:3edb3708c8c5 | 274 | #define D0 P0_0 |
whismanoid | 0:3edb3708c8c5 | 275 | #endif |
whismanoid | 0:3edb3708c8c5 | 276 | #ifndef D1 |
whismanoid | 0:3edb3708c8c5 | 277 | #define D1 P0_1 |
whismanoid | 0:3edb3708c8c5 | 278 | #endif |
whismanoid | 0:3edb3708c8c5 | 279 | #ifndef D2 |
whismanoid | 0:3edb3708c8c5 | 280 | #define D2 P0_2 |
whismanoid | 0:3edb3708c8c5 | 281 | #endif |
whismanoid | 0:3edb3708c8c5 | 282 | #ifndef D3 |
whismanoid | 0:3edb3708c8c5 | 283 | #define D3 P0_3 |
whismanoid | 0:3edb3708c8c5 | 284 | #endif |
whismanoid | 0:3edb3708c8c5 | 285 | #ifndef D4 |
whismanoid | 0:3edb3708c8c5 | 286 | #define D4 P0_4 |
whismanoid | 0:3edb3708c8c5 | 287 | #endif |
whismanoid | 0:3edb3708c8c5 | 288 | #ifndef D5 |
whismanoid | 0:3edb3708c8c5 | 289 | #define D5 P0_5 |
whismanoid | 0:3edb3708c8c5 | 290 | #endif |
whismanoid | 0:3edb3708c8c5 | 291 | #ifndef D6 |
whismanoid | 0:3edb3708c8c5 | 292 | #define D6 P0_6 |
whismanoid | 0:3edb3708c8c5 | 293 | #endif |
whismanoid | 0:3edb3708c8c5 | 294 | #ifndef D7 |
whismanoid | 0:3edb3708c8c5 | 295 | #define D7 P0_7 |
whismanoid | 0:3edb3708c8c5 | 296 | #endif |
whismanoid | 0:3edb3708c8c5 | 297 | #ifndef D8 |
whismanoid | 0:3edb3708c8c5 | 298 | #define D8 P1_4 |
whismanoid | 0:3edb3708c8c5 | 299 | #endif |
whismanoid | 0:3edb3708c8c5 | 300 | #ifndef D9 |
whismanoid | 0:3edb3708c8c5 | 301 | #define D9 P1_5 |
whismanoid | 0:3edb3708c8c5 | 302 | #endif |
whismanoid | 0:3edb3708c8c5 | 303 | #ifndef D10 |
whismanoid | 0:3edb3708c8c5 | 304 | #define D10 P1_3 |
whismanoid | 0:3edb3708c8c5 | 305 | #endif |
whismanoid | 0:3edb3708c8c5 | 306 | #ifndef D11 |
whismanoid | 0:3edb3708c8c5 | 307 | #define D11 P1_1 |
whismanoid | 0:3edb3708c8c5 | 308 | #endif |
whismanoid | 0:3edb3708c8c5 | 309 | #ifndef D12 |
whismanoid | 0:3edb3708c8c5 | 310 | #define D12 P1_2 |
whismanoid | 0:3edb3708c8c5 | 311 | #endif |
whismanoid | 0:3edb3708c8c5 | 312 | #ifndef D13 |
whismanoid | 0:3edb3708c8c5 | 313 | #define D13 P1_0 |
whismanoid | 0:3edb3708c8c5 | 314 | #endif |
whismanoid | 0:3edb3708c8c5 | 315 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 316 | #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 317 | // TODO1: target NUCLEO_F446RE |
whismanoid | 0:3edb3708c8c5 | 318 | // |
whismanoid | 0:3edb3708c8c5 | 319 | // USER_BUTTON PC13 |
whismanoid | 0:3edb3708c8c5 | 320 | // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1. |
whismanoid | 0:3edb3708c8c5 | 321 | #define USE_LEDS 0 |
whismanoid | 0:3edb3708c8c5 | 322 | // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); |
whismanoid | 0:3edb3708c8c5 | 323 | // Serial microUSBserial(SERIAL_TX, SERIAL_RX); |
whismanoid | 0:3edb3708c8c5 | 324 | #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 |
whismanoid | 0:3edb3708c8c5 | 325 | const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico? |
whismanoid | 0:3edb3708c8c5 | 326 | // |
whismanoid | 0:3edb3708c8c5 | 327 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 328 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 329 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 330 | // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM |
whismanoid | 0:3edb3708c8c5 | 331 | // +-------------[microUSB]-------------+ |
whismanoid | 0:3edb3708c8c5 | 332 | // ______ | [ ] GND +3.3V VOUT [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 333 | // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 334 | // ______ | [ ] VB USB.IF- [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 335 | // ______ | [ ] nR USB.IF+ [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 336 | // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 337 | // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 338 | // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 339 | // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 340 | // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 341 | // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______ |
whismanoid | 0:3edb3708c8c5 | 342 | // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 343 | // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 344 | // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 345 | // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 346 | // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1 |
whismanoid | 0:3edb3708c8c5 | 347 | // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2 |
whismanoid | 0:3edb3708c8c5 | 348 | // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3 |
whismanoid | 0:3edb3708c8c5 | 349 | // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4 |
whismanoid | 0:3edb3708c8c5 | 350 | // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5 |
whismanoid | 0:3edb3708c8c5 | 351 | // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 352 | // +------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 353 | // AIN6 = P0.3 = TGT_SBL_RXD? |
whismanoid | 0:3edb3708c8c5 | 354 | // AIN7 = P0.2 = TGT_SBL_TXD? |
whismanoid | 0:3edb3708c8c5 | 355 | // |
whismanoid | 0:3edb3708c8c5 | 356 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 357 | // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14 |
whismanoid | 0:3edb3708c8c5 | 358 | #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 |
whismanoid | 0:3edb3708c8c5 | 359 | const float ADC_FULL_SCALE_VOLTAGE = 3.300; |
whismanoid | 0:3edb3708c8c5 | 360 | #else // not defined(TARGET_LPC1768 etc.) |
whismanoid | 0:3edb3708c8c5 | 361 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 362 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 363 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 364 | #endif // target definition |
whismanoid | 0:3edb3708c8c5 | 365 | |
whismanoid | 0:3edb3708c8c5 | 366 | |
whismanoid | 0:3edb3708c8c5 | 367 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 368 | // alphanumeric command codes A-Z,a-z,0-9 reserved for application use |
whismanoid | 0:3edb3708c8c5 | 369 | #ifndef APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 370 | #define APPLICATION_ArduinoPinsMonitor 1 |
whismanoid | 0:3edb3708c8c5 | 371 | #endif // APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 372 | |
whismanoid | 0:3edb3708c8c5 | 373 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 374 | // Support MAX5715BOB Breakout Board |
whismanoid | 0:3edb3708c8c5 | 375 | #ifndef APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 376 | #define APPLICATION_MAX5715 1 |
whismanoid | 0:3edb3708c8c5 | 377 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 378 | #if APPLICATION_MAX5715 // header file |
whismanoid | 0:3edb3708c8c5 | 379 | #include "MAX5715.h" |
whismanoid | 0:3edb3708c8c5 | 380 | // suppress the I2C diagnostics, not relevant to this chip |
whismanoid | 0:3edb3708c8c5 | 381 | #define HAS_I2C 0 |
whismanoid | 0:3edb3708c8c5 | 382 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 383 | |
whismanoid | 0:3edb3708c8c5 | 384 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 385 | // Support MAX11131BOB Breakout Board |
whismanoid | 0:3edb3708c8c5 | 386 | #ifndef APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 387 | #define APPLICATION_MAX11131 0 |
whismanoid | 0:3edb3708c8c5 | 388 | #endif // APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 389 | #if APPLICATION_MAX11131 // header file |
whismanoid | 0:3edb3708c8c5 | 390 | #include "MAX11131.h" |
whismanoid | 0:3edb3708c8c5 | 391 | // suppress the I2C diagnostics, not relevant to this chip |
whismanoid | 0:3edb3708c8c5 | 392 | #define HAS_I2C 0 |
whismanoid | 0:3edb3708c8c5 | 393 | #endif // APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 394 | |
whismanoid | 0:3edb3708c8c5 | 395 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 396 | // Support MAX5171BOB Breakout Board |
whismanoid | 0:3edb3708c8c5 | 397 | #ifndef APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 398 | #define APPLICATION_MAX5171 0 |
whismanoid | 0:3edb3708c8c5 | 399 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 400 | #if APPLICATION_MAX5171 // header file |
whismanoid | 0:3edb3708c8c5 | 401 | #include "MAX5171.h" |
whismanoid | 0:3edb3708c8c5 | 402 | // suppress the I2C diagnostics, not relevant to this chip |
whismanoid | 0:3edb3708c8c5 | 403 | #define HAS_I2C 0 |
whismanoid | 0:3edb3708c8c5 | 404 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 405 | |
whismanoid | 0:3edb3708c8c5 | 406 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 407 | // Support MAX11410BOB Breakout Board (placeholder) |
whismanoid | 0:3edb3708c8c5 | 408 | #ifndef APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 409 | #define APPLICATION_MAX11410 0 |
whismanoid | 0:3edb3708c8c5 | 410 | #endif // APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 411 | #if APPLICATION_MAX11410 // header file |
whismanoid | 0:3edb3708c8c5 | 412 | #include "MAX11410.h" |
whismanoid | 0:3edb3708c8c5 | 413 | #endif // APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 414 | |
whismanoid | 0:3edb3708c8c5 | 415 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 416 | // Support MAX12345BOB Breakout Board (placeholder) |
whismanoid | 0:3edb3708c8c5 | 417 | #ifndef APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 418 | #define APPLICATION_MAX12345 0 |
whismanoid | 0:3edb3708c8c5 | 419 | #endif // APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 420 | #if APPLICATION_MAX12345 // header file |
whismanoid | 0:3edb3708c8c5 | 421 | #include "MAX12345.h" |
whismanoid | 0:3edb3708c8c5 | 422 | #endif // APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 423 | |
whismanoid | 0:3edb3708c8c5 | 424 | |
whismanoid | 0:3edb3708c8c5 | 425 | #include "MAX541.h" |
whismanoid | 0:3edb3708c8c5 | 426 | |
whismanoid | 0:3edb3708c8c5 | 427 | #ifndef USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 428 | #define USE_MAXIMTINYTESTER 1 |
whismanoid | 0:3edb3708c8c5 | 429 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 430 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 431 | #include "MaximTinyTester.h" |
whismanoid | 0:3edb3708c8c5 | 432 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 433 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 434 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 435 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 436 | |
whismanoid | 0:3edb3708c8c5 | 437 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 438 | // Option to dedicate SPI port pins |
whismanoid | 0:3edb3708c8c5 | 439 | // |
whismanoid | 0:3edb3708c8c5 | 440 | // SPI2_MOSI = P5_1 |
whismanoid | 0:3edb3708c8c5 | 441 | // SPI2_MISO = P5_2 |
whismanoid | 0:3edb3708c8c5 | 442 | // SPI2_SCK = P5_0 |
whismanoid | 0:3edb3708c8c5 | 443 | // On this board I'm using P3_0 as spi_cs |
whismanoid | 0:3edb3708c8c5 | 444 | // SPI2_SS = P5_3 |
whismanoid | 0:3edb3708c8c5 | 445 | // SPI2_SDIO2 = P5_4 |
whismanoid | 0:3edb3708c8c5 | 446 | // SPI2_SDIO3 = P5_5 |
whismanoid | 0:3edb3708c8c5 | 447 | // SPI2_SRN = P5_6 |
whismanoid | 0:3edb3708c8c5 | 448 | // |
whismanoid | 0:3edb3708c8c5 | 449 | #ifndef HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 450 | #define HAS_SPI 1 |
whismanoid | 0:3edb3708c8c5 | 451 | #endif |
whismanoid | 0:3edb3708c8c5 | 452 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 453 | #define SPI_MODE0 0 |
whismanoid | 0:3edb3708c8c5 | 454 | #define SPI_MODE1 1 |
whismanoid | 0:3edb3708c8c5 | 455 | #define SPI_MODE2 2 |
whismanoid | 0:3edb3708c8c5 | 456 | #define SPI_MODE3 3 |
whismanoid | 0:3edb3708c8c5 | 457 | // |
whismanoid | 0:3edb3708c8c5 | 458 | // Define application-specific default SPI_SCLK_Hz and SPI_dataMode |
whismanoid | 0:3edb3708c8c5 | 459 | #if APPLICATION_MAX5715 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 460 | // |
whismanoid | 0:3edb3708c8c5 | 461 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 462 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:3edb3708c8c5 | 463 | #define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:3edb3708c8c5 | 464 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 465 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 466 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 467 | #define SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 468 | // |
whismanoid | 0:3edb3708c8c5 | 469 | #elif APPLICATION_MAX11131 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 470 | // |
whismanoid | 0:3edb3708c8c5 | 471 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 472 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:3edb3708c8c5 | 473 | #define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:3edb3708c8c5 | 474 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 475 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 476 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 477 | #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 478 | // |
whismanoid | 0:3edb3708c8c5 | 479 | #elif APPLICATION_MAX5171 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 480 | // |
whismanoid | 0:3edb3708c8c5 | 481 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 482 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:3edb3708c8c5 | 483 | #define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:3edb3708c8c5 | 484 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 485 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 486 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 487 | #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 488 | // |
whismanoid | 0:3edb3708c8c5 | 489 | #elif APPLICATION_MAX11410 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 490 | // |
whismanoid | 0:3edb3708c8c5 | 491 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 492 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:3edb3708c8c5 | 493 | //#define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:3edb3708c8c5 | 494 | #define SPI_SCLK_Hz 8000000 // 8MHz |
whismanoid | 0:3edb3708c8c5 | 495 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 496 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 497 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 498 | #define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Falling Edge stable; SCLK idle Low |
whismanoid | 0:3edb3708c8c5 | 499 | // |
whismanoid | 0:3edb3708c8c5 | 500 | #elif APPLICATION_MAX12345 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 501 | // |
whismanoid | 0:3edb3708c8c5 | 502 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 503 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:3edb3708c8c5 | 504 | #define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:3edb3708c8c5 | 505 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 506 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 507 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 508 | #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 509 | // |
whismanoid | 0:3edb3708c8c5 | 510 | #else // APPLICATION_ArduinoPinsMonitor diagnostic |
whismanoid | 0:3edb3708c8c5 | 511 | // |
whismanoid | 0:3edb3708c8c5 | 512 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:3edb3708c8c5 | 513 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:3edb3708c8c5 | 514 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:3edb3708c8c5 | 515 | #define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:3edb3708c8c5 | 516 | //#define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low |
whismanoid | 0:3edb3708c8c5 | 517 | //#define SPI_dataMode SPI_MODE1 // CPOL=0,CPHA=1: Falling Edge stable; SCLK idle Low |
whismanoid | 0:3edb3708c8c5 | 518 | //#define SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 519 | #define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High |
whismanoid | 0:3edb3708c8c5 | 520 | // |
whismanoid | 0:3edb3708c8c5 | 521 | #endif |
whismanoid | 0:3edb3708c8c5 | 522 | // |
whismanoid | 0:3edb3708c8c5 | 523 | uint32_t g_SPI_SCLK_Hz = SPI_SCLK_Hz; |
whismanoid | 0:3edb3708c8c5 | 524 | // TODO1: validate g_SPI_SCLK_Hz against system clock frequency SystemCoreClock F_CPU |
whismanoid | 0:3edb3708c8c5 | 525 | #if defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 526 | // Nucleo SPI frequency isn't working quite as expected... |
whismanoid | 0:3edb3708c8c5 | 527 | // Looks like STMF4 has an spi clock prescaler (2,4,8,16,32,64,128,256) |
whismanoid | 0:3edb3708c8c5 | 528 | // so 180MHz->[90.0, 45.0, 22.5, 11.25, 5.625, 2.8125, 1.40625, 0.703125] |
whismanoid | 0:3edb3708c8c5 | 529 | // %SC SCLK=1MHz sets spi frequency 703.125kHz |
whismanoid | 0:3edb3708c8c5 | 530 | // %SC SCLK=2MHz sets spi frequency 1.40625MHz |
whismanoid | 0:3edb3708c8c5 | 531 | // %SC SCLK=3MHz sets spi frequency 2.8125MHz |
whismanoid | 0:3edb3708c8c5 | 532 | // %SC SCLK=6MHz sets spi frequency 5.625MHz |
whismanoid | 0:3edb3708c8c5 | 533 | // %SC SCLK=12MHz sets spi frequency 11.25MHz |
whismanoid | 0:3edb3708c8c5 | 534 | // %SC SCLK=23MHz sets spi frequency 22.5MHz |
whismanoid | 0:3edb3708c8c5 | 535 | // %SC SCLK=45MHz sets spi frequency 45.0MHz |
whismanoid | 0:3edb3708c8c5 | 536 | // Don't know why I can't reach spi frequency 90.0MHz, but ok whatever. |
whismanoid | 0:3edb3708c8c5 | 537 | const uint32_t limit_min_SPI_SCLK_divisor = 2; |
whismanoid | 0:3edb3708c8c5 | 538 | const uint32_t limit_max_SPI_SCLK_divisor = 256; |
whismanoid | 0:3edb3708c8c5 | 539 | // not really a divisor, just a powers-of-two prescaler with no intermediate divisors. |
whismanoid | 0:3edb3708c8c5 | 540 | #else |
whismanoid | 0:3edb3708c8c5 | 541 | const uint32_t limit_min_SPI_SCLK_divisor = 2; |
whismanoid | 0:3edb3708c8c5 | 542 | const uint32_t limit_max_SPI_SCLK_divisor = 8191; |
whismanoid | 0:3edb3708c8c5 | 543 | #endif |
whismanoid | 0:3edb3708c8c5 | 544 | const uint32_t limit_max_SPI_SCLK_Hz = (SystemCoreClock / limit_min_SPI_SCLK_divisor); // F_CPU / 2; // 8MHz / 2 = 4MHz |
whismanoid | 0:3edb3708c8c5 | 545 | const uint32_t limit_min_SPI_SCLK_Hz = (SystemCoreClock / limit_max_SPI_SCLK_divisor); // F_CPU / 128; // 8MHz / 128 = 62.5kHz |
whismanoid | 0:3edb3708c8c5 | 546 | // |
whismanoid | 0:3edb3708c8c5 | 547 | uint8_t g_SPI_dataMode = SPI_dataMode; |
whismanoid | 0:3edb3708c8c5 | 548 | uint8_t g_SPI_cs_state = 1; |
whismanoid | 0:3edb3708c8c5 | 549 | // |
whismanoid | 0:3edb3708c8c5 | 550 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 551 | // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 552 | // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) |
whismanoid | 0:3edb3708c8c5 | 553 | //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 | 554 | //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 | 555 | //SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 |
whismanoid | 0:3edb3708c8c5 | 556 | SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 |
whismanoid | 0:3edb3708c8c5 | 557 | // |
whismanoid | 0:3edb3708c8c5 | 558 | DigitalOut spi_cs(P3_0); |
whismanoid | 0:3edb3708c8c5 | 559 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 560 | // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 561 | // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) |
whismanoid | 0:3edb3708c8c5 | 562 | //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 | 563 | //DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32635MBED: P0_7 Arduino 8-pin header D4 |
whismanoid | 0:3edb3708c8c5 | 564 | 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 | 565 | DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32635MBED: P1_3 Arduino 10-pin header D10 |
whismanoid | 0:3edb3708c8c5 | 566 | 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 | 567 | DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header |
whismanoid | 0:3edb3708c8c5 | 568 | #define HAS_SPI2_MAX541 1 |
whismanoid | 0:3edb3708c8c5 | 569 | // |
whismanoid | 0:3edb3708c8c5 | 570 | #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 571 | // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 572 | // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) |
whismanoid | 0:3edb3708c8c5 | 573 | // |
whismanoid | 0:3edb3708c8c5 | 574 | // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses. |
whismanoid | 0:3edb3708c8c5 | 575 | 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 | 576 | DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10 |
whismanoid | 0:3edb3708c8c5 | 577 | // |
whismanoid | 0:3edb3708c8c5 | 578 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 579 | // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 580 | // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) |
whismanoid | 0:3edb3708c8c5 | 581 | //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 | 582 | //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 | 583 | //SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 |
whismanoid | 0:3edb3708c8c5 | 584 | SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 |
whismanoid | 0:3edb3708c8c5 | 585 | // |
whismanoid | 0:3edb3708c8c5 | 586 | DigitalOut spi_cs(P3_0); |
whismanoid | 0:3edb3708c8c5 | 587 | #else |
whismanoid | 0:3edb3708c8c5 | 588 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 589 | #endif |
whismanoid | 0:3edb3708c8c5 | 590 | #endif |
whismanoid | 0:3edb3708c8c5 | 591 | |
whismanoid | 0:3edb3708c8c5 | 592 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 593 | // Device driver object |
whismanoid | 0:3edb3708c8c5 | 594 | #if APPLICATION_MAX5715 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 595 | DigitalOut LDACb_pin(D9); // Arduino 10-pin header D9 |
whismanoid | 0:3edb3708c8c5 | 596 | DigitalOut CLRb_pin(D8); // Arduino 10-pin header D8 |
whismanoid | 0:3edb3708c8c5 | 597 | //~ DigitalIn RDYb_pin(D12); // Arduino 10-pin header D12 (MISO) |
whismanoid | 0:3edb3708c8c5 | 598 | MAX5715 g_MAX5715_device(spi, spi_cs, |
whismanoid | 0:3edb3708c8c5 | 599 | LDACb_pin, |
whismanoid | 0:3edb3708c8c5 | 600 | CLRb_pin, |
whismanoid | 0:3edb3708c8c5 | 601 | ///* RDYb_pin */ digitalInOut12, |
whismanoid | 0:3edb3708c8c5 | 602 | MAX5715::MAX5715_IC); |
whismanoid | 0:3edb3708c8c5 | 603 | // |
whismanoid | 0:3edb3708c8c5 | 604 | #elif APPLICATION_MAX11131 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 605 | DigitalOut CNVSTb_pin(D9); // Arduino 10-pin header D9 |
whismanoid | 0:3edb3708c8c5 | 606 | //DigitalOut CLRb_pin(D8); // Arduino 10-pin header D8 |
whismanoid | 0:3edb3708c8c5 | 607 | DigitalIn EOCb_pin(D12); // Arduino 10-pin header D12 (MISO) |
whismanoid | 0:3edb3708c8c5 | 608 | MAX11131 g_MAX11131_device(spi, spi_cs, |
whismanoid | 0:3edb3708c8c5 | 609 | CNVSTb_pin, |
whismanoid | 0:3edb3708c8c5 | 610 | EOCb_pin, |
whismanoid | 0:3edb3708c8c5 | 611 | ///* RDYb_pin */ digitalInOut12, |
whismanoid | 0:3edb3708c8c5 | 612 | MAX11131::MAX11131_IC); |
whismanoid | 0:3edb3708c8c5 | 613 | // |
whismanoid | 0:3edb3708c8c5 | 614 | // |
whismanoid | 0:3edb3708c8c5 | 615 | #elif APPLICATION_MAX5171 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 616 | // AnalogOut FB_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 617 | DigitalOut RS_pin(D9); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 618 | DigitalOut PDLb_pin(D8); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 619 | DigitalOut CLRb_pin(D7); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 620 | DigitalOut SHDN_pin(D6); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 621 | // AnalogIn OUT_pin(A0); // Analog Output from MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 622 | DigitalIn UPO_pin(D2); // Digital General-Purpose Output from MAX5171 device |
whismanoid | 0:3edb3708c8c5 | 623 | MAX5171 g_MAX5171_device(spi, spi_cs, RS_pin, PDLb_pin, CLRb_pin, SHDN_pin, UPO_pin, MAX5171::MAX5171_IC); |
whismanoid | 0:3edb3708c8c5 | 624 | // |
whismanoid | 0:3edb3708c8c5 | 625 | #elif APPLICATION_MAX11410 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 626 | // |
whismanoid | 0:3edb3708c8c5 | 627 | MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC); |
whismanoid | 0:3edb3708c8c5 | 628 | // |
whismanoid | 0:3edb3708c8c5 | 629 | #elif APPLICATION_MAX12345 // SPI interface default settings |
whismanoid | 0:3edb3708c8c5 | 630 | // |
whismanoid | 0:3edb3708c8c5 | 631 | MAX12345 g_MAX12345_device(spi, spi_cs, ...); |
whismanoid | 0:3edb3708c8c5 | 632 | // |
whismanoid | 0:3edb3708c8c5 | 633 | #else // APPLICATION_ArduinoPinsMonitor diagnostic |
whismanoid | 0:3edb3708c8c5 | 634 | // |
whismanoid | 0:3edb3708c8c5 | 635 | #endif |
whismanoid | 0:3edb3708c8c5 | 636 | |
whismanoid | 0:3edb3708c8c5 | 637 | |
whismanoid | 0:3edb3708c8c5 | 638 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 639 | // Option to dedicate I2C port pins |
whismanoid | 0:3edb3708c8c5 | 640 | // |
whismanoid | 0:3edb3708c8c5 | 641 | #ifndef HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 642 | #define HAS_I2C 1 |
whismanoid | 0:3edb3708c8c5 | 643 | #endif |
whismanoid | 0:3edb3708c8c5 | 644 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 645 | //#include "I2C.h" |
whismanoid | 0:3edb3708c8c5 | 646 | //#include "I2CSlave.h" |
whismanoid | 0:3edb3708c8c5 | 647 | //#define I2C_SCL_Hz 400000 // 400kHz |
whismanoid | 0:3edb3708c8c5 | 648 | //#define I2C_SCL_Hz 200000 // 200kHz |
whismanoid | 0:3edb3708c8c5 | 649 | #define I2C_SCL_Hz 100000 // 100kHz |
whismanoid | 0:3edb3708c8c5 | 650 | // |
whismanoid | 0:3edb3708c8c5 | 651 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 652 | // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU |
whismanoid | 0:3edb3708c8c5 | 653 | const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz |
whismanoid | 0:3edb3708c8c5 | 654 | const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz |
whismanoid | 0:3edb3708c8c5 | 655 | // |
whismanoid | 0:3edb3708c8c5 | 656 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 657 | //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl MAX32630FTHR: NOT_CONNECTED |
whismanoid | 0:3edb3708c8c5 | 658 | //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl MAX32630FTHR: P3_4, P3_5 |
whismanoid | 0:3edb3708c8c5 | 659 | //I2C i2cMaster2(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0 |
whismanoid | 0:3edb3708c8c5 | 660 | //I2C i2cMaster(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0 |
whismanoid | 0:3edb3708c8c5 | 661 | // |
whismanoid | 0:3edb3708c8c5 | 662 | //I2CSlave i2cSlave0(I2C0_SDA, I2C0_SCL); // sda scl MAX32630FTHR: NOT_CONNECTED |
whismanoid | 0:3edb3708c8c5 | 663 | //I2CSlave i2cSlave1(I2C1_SDA, I2C1_SCL); // sda scl MAX32630FTHR: P3_4, P3_5 |
whismanoid | 0:3edb3708c8c5 | 664 | //I2CSlave i2cSlave2(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0 |
whismanoid | 0:3edb3708c8c5 | 665 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 666 | // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU |
whismanoid | 0:3edb3708c8c5 | 667 | const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz |
whismanoid | 0:3edb3708c8c5 | 668 | const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz |
whismanoid | 0:3edb3708c8c5 | 669 | // |
whismanoid | 0:3edb3708c8c5 | 670 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 671 | //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 672 | //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header |
whismanoid | 0:3edb3708c8c5 | 673 | // 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 | 674 | // |
whismanoid | 0:3edb3708c8c5 | 675 | #elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 676 | // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU |
whismanoid | 0:3edb3708c8c5 | 677 | const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz |
whismanoid | 0:3edb3708c8c5 | 678 | const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz |
whismanoid | 0:3edb3708c8c5 | 679 | // |
whismanoid | 0:3edb3708c8c5 | 680 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 681 | //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 682 | //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header |
whismanoid | 0:3edb3708c8c5 | 683 | // 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 | 684 | # ifndef I2C0_SDA |
whismanoid | 0:3edb3708c8c5 | 685 | # define I2C0_SDA I2C_SDA |
whismanoid | 0:3edb3708c8c5 | 686 | # define I2C0_SCL I2C_SCL |
whismanoid | 0:3edb3708c8c5 | 687 | # endif |
whismanoid | 0:3edb3708c8c5 | 688 | // |
whismanoid | 0:3edb3708c8c5 | 689 | #elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 690 | // TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU |
whismanoid | 0:3edb3708c8c5 | 691 | const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz |
whismanoid | 0:3edb3708c8c5 | 692 | const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz |
whismanoid | 0:3edb3708c8c5 | 693 | // |
whismanoid | 0:3edb3708c8c5 | 694 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 695 | //I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 696 | //I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header |
whismanoid | 0:3edb3708c8c5 | 697 | // 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 | 698 | # ifndef I2C0_SDA |
whismanoid | 0:3edb3708c8c5 | 699 | # define I2C0_SDA I2C_SDA |
whismanoid | 0:3edb3708c8c5 | 700 | # define I2C0_SCL I2C_SCL |
whismanoid | 0:3edb3708c8c5 | 701 | # endif |
whismanoid | 0:3edb3708c8c5 | 702 | // |
whismanoid | 0:3edb3708c8c5 | 703 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 704 | #else |
whismanoid | 0:3edb3708c8c5 | 705 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 706 | #endif |
whismanoid | 0:3edb3708c8c5 | 707 | // |
whismanoid | 0:3edb3708c8c5 | 708 | #endif |
whismanoid | 0:3edb3708c8c5 | 709 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 710 | uint32_t g_I2C_SCL_Hz = I2C_SCL_Hz; |
whismanoid | 0:3edb3708c8c5 | 711 | uint8_t g_I2C_status = 0; // g_I2C_status = Wire_Sr.endTransmission(); |
whismanoid | 0:3edb3708c8c5 | 712 | uint8_t g_I2C_deviceAddress7 = (0xA0 >> 1); // I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified. |
whismanoid | 0:3edb3708c8c5 | 713 | uint8_t g_I2C_read_count = 0; |
whismanoid | 0:3edb3708c8c5 | 714 | uint8_t g_I2C_write_count = 0; |
whismanoid | 0:3edb3708c8c5 | 715 | uint8_t g_I2C_write_data[256]; |
whismanoid | 0:3edb3708c8c5 | 716 | uint8_t g_I2C_command_regAddress; |
whismanoid | 0:3edb3708c8c5 | 717 | // |
whismanoid | 0:3edb3708c8c5 | 718 | // TODO: i2c init |
whismanoid | 0:3edb3708c8c5 | 719 | // i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 720 | #endif |
whismanoid | 0:3edb3708c8c5 | 721 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 722 | // TODO: i2c transfer |
whismanoid | 0:3edb3708c8c5 | 723 | //const int addr7bit = 0x48; // 7 bit I2C address |
whismanoid | 0:3edb3708c8c5 | 724 | //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 |
whismanoid | 0:3edb3708c8c5 | 725 | // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 726 | // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 727 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 728 | // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 729 | // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 730 | // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 731 | // /* 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 | 732 | // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... |
whismanoid | 0:3edb3708c8c5 | 733 | #endif |
whismanoid | 0:3edb3708c8c5 | 734 | |
whismanoid | 0:3edb3708c8c5 | 735 | |
whismanoid | 0:3edb3708c8c5 | 736 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 737 | // Declare the Serial driver |
whismanoid | 0:3edb3708c8c5 | 738 | // default baud rate settings are 9600 8N1 |
whismanoid | 0:3edb3708c8c5 | 739 | // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe |
whismanoid | 0:3edb3708c8c5 | 740 | // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/ |
whismanoid | 0:3edb3708c8c5 | 741 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 742 | #include "USBSerial.h" |
whismanoid | 0:3edb3708c8c5 | 743 | // Hardware serial port over DAPLink |
whismanoid | 0:3edb3708c8c5 | 744 | // The default baud rate for the DapLink UART is 9600 |
whismanoid | 0:3edb3708c8c5 | 745 | Serial DAPLINKserial(P2_1, P2_0); // tx, rx |
whismanoid | 0:3edb3708c8c5 | 746 | #define HAS_DAPLINK_SERIAL 1 |
whismanoid | 0:3edb3708c8c5 | 747 | // Virtual serial port over USB |
whismanoid | 0:3edb3708c8c5 | 748 | // The baud rate does not affect the virtual USBSerial UART. |
whismanoid | 0:3edb3708c8c5 | 749 | USBSerial microUSBserial; |
whismanoid | 0:3edb3708c8c5 | 750 | #define HAS_MICROUSBSERIAL 1 |
whismanoid | 0:3edb3708c8c5 | 751 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 752 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 753 | #include "USBSerial.h" |
whismanoid | 0:3edb3708c8c5 | 754 | // Hardware serial port over DAPLink |
whismanoid | 0:3edb3708c8c5 | 755 | // The default baud rate for the DapLink UART is 9600 |
whismanoid | 0:3edb3708c8c5 | 756 | Serial DAPLINKserial(P2_1, P2_0); // tx, rx |
whismanoid | 0:3edb3708c8c5 | 757 | #define HAS_DAPLINK_SERIAL 1 |
whismanoid | 0:3edb3708c8c5 | 758 | // Virtual serial port over USB |
whismanoid | 0:3edb3708c8c5 | 759 | // The baud rate does not affect the virtual USBSerial UART. |
whismanoid | 0:3edb3708c8c5 | 760 | USBSerial microUSBserial; |
whismanoid | 0:3edb3708c8c5 | 761 | #define HAS_MICROUSBSERIAL 1 |
whismanoid | 0:3edb3708c8c5 | 762 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 763 | #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 764 | Serial microUSBserial(SERIAL_TX, SERIAL_RX); // tx, rx |
whismanoid | 0:3edb3708c8c5 | 765 | #define HAS_MICROUSBSERIAL 1 |
whismanoid | 0:3edb3708c8c5 | 766 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 767 | // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 768 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 769 | Serial microUSBserial(USBTX, USBRX); // tx, rx |
whismanoid | 0:3edb3708c8c5 | 770 | #define HAS_MICROUSBSERIAL 1 |
whismanoid | 0:3edb3708c8c5 | 771 | #else |
whismanoid | 0:3edb3708c8c5 | 772 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 773 | #endif |
whismanoid | 0:3edb3708c8c5 | 774 | |
whismanoid | 0:3edb3708c8c5 | 775 | void on_immediate_0x21(); // Unicode (U+0021) ! EXCLAMATION MARK |
whismanoid | 0:3edb3708c8c5 | 776 | void on_immediate_0x7b(); // Unicode (U+007B) { LEFT CURLY BRACKET |
whismanoid | 0:3edb3708c8c5 | 777 | void on_immediate_0x7d(); // Unicode (U+007D) } RIGHT CURLY BRACKET |
whismanoid | 0:3edb3708c8c5 | 778 | |
whismanoid | 0:3edb3708c8c5 | 779 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 780 | // Option to process command buffer from microUSBserial or DAPLINKserial |
whismanoid | 0:3edb3708c8c5 | 781 | #ifndef USE_COMMAND_BUFFER |
whismanoid | 0:3edb3708c8c5 | 782 | #define USE_COMMAND_BUFFER 1 |
whismanoid | 0:3edb3708c8c5 | 783 | #endif |
whismanoid | 0:3edb3708c8c5 | 784 | #if USE_COMMAND_BUFFER |
whismanoid | 0:3edb3708c8c5 | 785 | #include "CmdLine.h" |
whismanoid | 0:3edb3708c8c5 | 786 | |
whismanoid | 0:3edb3708c8c5 | 787 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 788 | CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK"); |
whismanoid | 0:3edb3708c8c5 | 789 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 790 | // TODO1: diagnostic: define HAS_MICROUSBSERIAL 0 |
whismanoid | 0:3edb3708c8c5 | 791 | //~ #define HAS_MICROUSBSERIAL 0 |
whismanoid | 0:3edb3708c8c5 | 792 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 793 | CmdLine cmdLine_microUSBserial(microUSBserial, "microUSB"); |
whismanoid | 0:3edb3708c8c5 | 794 | # endif // HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 795 | |
whismanoid | 0:3edb3708c8c5 | 796 | #endif // USE_COMMAND_BUFFER |
whismanoid | 0:3edb3708c8c5 | 797 | |
whismanoid | 0:3edb3708c8c5 | 798 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 799 | // tolerate AT commands, which may be sent during probe, such as: |
whismanoid | 0:3edb3708c8c5 | 800 | // AT |
whismanoid | 0:3edb3708c8c5 | 801 | // AT+CGMI -- request manufacturer identification AT+CMGI=? |
whismanoid | 0:3edb3708c8c5 | 802 | // AT+CGMM -- request manufacturer model |
whismanoid | 0:3edb3708c8c5 | 803 | // AT%IPSYS? |
whismanoid | 0:3edb3708c8c5 | 804 | // ATE0 -- echo disable |
whismanoid | 0:3edb3708c8c5 | 805 | // ATV1 -- verbose result codes OK | ERROR | NO CARRIER |
whismanoid | 0:3edb3708c8c5 | 806 | // AT+CMEE=1 |
whismanoid | 0:3edb3708c8c5 | 807 | // ATX4 |
whismanoid | 0:3edb3708c8c5 | 808 | // AT&C1 |
whismanoid | 0:3edb3708c8c5 | 809 | // ATE0 |
whismanoid | 0:3edb3708c8c5 | 810 | // AT+CMEE=1 |
whismanoid | 0:3edb3708c8c5 | 811 | // AT+GCAP |
whismanoid | 0:3edb3708c8c5 | 812 | // ATI |
whismanoid | 0:3edb3708c8c5 | 813 | // AT+CPIN? |
whismanoid | 0:3edb3708c8c5 | 814 | // AT+CGMM |
whismanoid | 0:3edb3708c8c5 | 815 | #ifndef IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 816 | #define IGNORE_AT_COMMANDS 1 |
whismanoid | 0:3edb3708c8c5 | 817 | #endif |
whismanoid | 0:3edb3708c8c5 | 818 | |
whismanoid | 0:3edb3708c8c5 | 819 | |
whismanoid | 0:3edb3708c8c5 | 820 | // uncrustify-0.66.1 *INDENT-OFF* |
whismanoid | 0:3edb3708c8c5 | 821 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 822 | // Declare the DigitalInOut GPIO pins |
whismanoid | 0:3edb3708c8c5 | 823 | // Optional digitalInOut support. If there is only one it should be digitalInOut1. |
whismanoid | 0:3edb3708c8c5 | 824 | // D) Digital High/Low/Input Pin |
whismanoid | 0:3edb3708c8c5 | 825 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 826 | // +-------------[microUSB]-------------+ |
whismanoid | 0:3edb3708c8c5 | 827 | // | J1 MAX32630FTHR J2 | |
whismanoid | 0:3edb3708c8c5 | 828 | // | [ ] RST GND [ ] | |
whismanoid | 0:3edb3708c8c5 | 829 | // | [ ] 3V3 BAT+[ ] | |
whismanoid | 0:3edb3708c8c5 | 830 | // | [ ] 1V8 reset SW1 | |
whismanoid | 0:3edb3708c8c5 | 831 | // | [ ] GND J4 J3 | |
whismanoid | 0:3edb3708c8c5 | 832 | // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] | |
whismanoid | 0:3edb3708c8c5 | 833 | // | [ ] AIN_1 1.2Vfs PWR [ ] | |
whismanoid | 0:3edb3708c8c5 | 834 | // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] | |
whismanoid | 0:3edb3708c8c5 | 835 | // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9 |
whismanoid | 0:3edb3708c8c5 | 836 | // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8 |
whismanoid | 0:3edb3708c8c5 | 837 | // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7 |
whismanoid | 0:3edb3708c8c5 | 838 | // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6 |
whismanoid | 0:3edb3708c8c5 | 839 | // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5 |
whismanoid | 0:3edb3708c8c5 | 840 | // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4 |
whismanoid | 0:3edb3708c8c5 | 841 | // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3 |
whismanoid | 0:3edb3708c8c5 | 842 | // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2 |
whismanoid | 0:3edb3708c8c5 | 843 | // | [ ] GND SDA P3_4 [x] | dig1 |
whismanoid | 0:3edb3708c8c5 | 844 | // +------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 845 | #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15 |
whismanoid | 0:3edb3708c8c5 | 846 | #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12 |
whismanoid | 0:3edb3708c8c5 | 847 | #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11 |
whismanoid | 0:3edb3708c8c5 | 848 | #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10 |
whismanoid | 0:3edb3708c8c5 | 849 | #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9 |
whismanoid | 0:3edb3708c8c5 | 850 | #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8 |
whismanoid | 0:3edb3708c8c5 | 851 | #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7 |
whismanoid | 0:3edb3708c8c5 | 852 | #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6 |
whismanoid | 0:3edb3708c8c5 | 853 | #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5 |
whismanoid | 0:3edb3708c8c5 | 854 | #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4 |
whismanoid | 0:3edb3708c8c5 | 855 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 856 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 857 | #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9 |
whismanoid | 0:3edb3708c8c5 | 858 | #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10 |
whismanoid | 0:3edb3708c8c5 | 859 | #else // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 860 | #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9 |
whismanoid | 0:3edb3708c8c5 | 861 | #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10 |
whismanoid | 0:3edb3708c8c5 | 862 | #endif // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 863 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 864 | // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 865 | #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11 |
whismanoid | 0:3edb3708c8c5 | 866 | #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12 |
whismanoid | 0:3edb3708c8c5 | 867 | #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13 |
whismanoid | 0:3edb3708c8c5 | 868 | #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14 |
whismanoid | 0:3edb3708c8c5 | 869 | #else // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 870 | #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11 |
whismanoid | 0:3edb3708c8c5 | 871 | #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12 |
whismanoid | 0:3edb3708c8c5 | 872 | #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13 |
whismanoid | 0:3edb3708c8c5 | 873 | #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14 |
whismanoid | 0:3edb3708c8c5 | 874 | #endif // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 875 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 876 | DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15 |
whismanoid | 0:3edb3708c8c5 | 877 | #endif |
whismanoid | 0:3edb3708c8c5 | 878 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 879 | DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12 |
whismanoid | 0:3edb3708c8c5 | 880 | #endif |
whismanoid | 0:3edb3708c8c5 | 881 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 882 | DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11 |
whismanoid | 0:3edb3708c8c5 | 883 | #endif |
whismanoid | 0:3edb3708c8c5 | 884 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 885 | DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10 |
whismanoid | 0:3edb3708c8c5 | 886 | #endif |
whismanoid | 0:3edb3708c8c5 | 887 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 888 | DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9 |
whismanoid | 0:3edb3708c8c5 | 889 | #endif |
whismanoid | 0:3edb3708c8c5 | 890 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 891 | DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8 |
whismanoid | 0:3edb3708c8c5 | 892 | #endif |
whismanoid | 0:3edb3708c8c5 | 893 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 894 | DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7 |
whismanoid | 0:3edb3708c8c5 | 895 | #endif |
whismanoid | 0:3edb3708c8c5 | 896 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 897 | DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6 |
whismanoid | 0:3edb3708c8c5 | 898 | #endif |
whismanoid | 0:3edb3708c8c5 | 899 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 900 | DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5 |
whismanoid | 0:3edb3708c8c5 | 901 | #endif |
whismanoid | 0:3edb3708c8c5 | 902 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 903 | DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4 |
whismanoid | 0:3edb3708c8c5 | 904 | #endif |
whismanoid | 0:3edb3708c8c5 | 905 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 906 | DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9 |
whismanoid | 0:3edb3708c8c5 | 907 | #endif |
whismanoid | 0:3edb3708c8c5 | 908 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 909 | DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10 |
whismanoid | 0:3edb3708c8c5 | 910 | #endif |
whismanoid | 0:3edb3708c8c5 | 911 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 912 | DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11 |
whismanoid | 0:3edb3708c8c5 | 913 | #endif |
whismanoid | 0:3edb3708c8c5 | 914 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 915 | DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12 |
whismanoid | 0:3edb3708c8c5 | 916 | #endif |
whismanoid | 0:3edb3708c8c5 | 917 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 918 | DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13 |
whismanoid | 0:3edb3708c8c5 | 919 | #endif |
whismanoid | 0:3edb3708c8c5 | 920 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 921 | DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14 |
whismanoid | 0:3edb3708c8c5 | 922 | #endif |
whismanoid | 0:3edb3708c8c5 | 923 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 924 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 925 | // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 926 | // +-------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 927 | // | MAX32625MBED Arduino UNO header | |
whismanoid | 0:3edb3708c8c5 | 928 | // | | |
whismanoid | 0:3edb3708c8c5 | 929 | // | A5/SCL[ ] | P1_7 dig15 |
whismanoid | 0:3edb3708c8c5 | 930 | // | A4/SDA[ ] | P1_6 dig14 |
whismanoid | 0:3edb3708c8c5 | 931 | // | AREF=N/C[ ] | |
whismanoid | 0:3edb3708c8c5 | 932 | // | GND[ ] | |
whismanoid | 0:3edb3708c8c5 | 933 | // | [ ]N/C SCK/13[ ] | P1_0 dig13 |
whismanoid | 0:3edb3708c8c5 | 934 | // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12 |
whismanoid | 0:3edb3708c8c5 | 935 | // | [ ]RST MOSI/11[ ]~| P1_1 dig11 |
whismanoid | 0:3edb3708c8c5 | 936 | // | [ ]3V3 CS/10[ ]~| P1_3 dig10 |
whismanoid | 0:3edb3708c8c5 | 937 | // | [ ]5V0 9[ ]~| P1_5 dig9 |
whismanoid | 0:3edb3708c8c5 | 938 | // | [ ]GND 8[ ] | P1_4 dig8 |
whismanoid | 0:3edb3708c8c5 | 939 | // | [ ]GND | |
whismanoid | 0:3edb3708c8c5 | 940 | // | [ ]Vin 7[ ] | P0_7 dig7 |
whismanoid | 0:3edb3708c8c5 | 941 | // | 6[ ]~| P0_6 dig6 |
whismanoid | 0:3edb3708c8c5 | 942 | // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5 |
whismanoid | 0:3edb3708c8c5 | 943 | // AIN_1 | [ ]A1 4[ ] | P0_4 dig4 |
whismanoid | 0:3edb3708c8c5 | 944 | // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3 |
whismanoid | 0:3edb3708c8c5 | 945 | // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2 |
whismanoid | 0:3edb3708c8c5 | 946 | // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1 |
whismanoid | 0:3edb3708c8c5 | 947 | // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0 |
whismanoid | 0:3edb3708c8c5 | 948 | // | [ ] [ ] [ ] | |
whismanoid | 0:3edb3708c8c5 | 949 | // | UNO_R3 GND MOSI 5V ____________/ |
whismanoid | 0:3edb3708c8c5 | 950 | // \_______________________/ |
whismanoid | 0:3edb3708c8c5 | 951 | // |
whismanoid | 0:3edb3708c8c5 | 952 | #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0 |
whismanoid | 0:3edb3708c8c5 | 953 | #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1 |
whismanoid | 0:3edb3708c8c5 | 954 | #if APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 955 | #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn |
whismanoid | 0:3edb3708c8c5 | 956 | #else |
whismanoid | 0:3edb3708c8c5 | 957 | #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2 |
whismanoid | 0:3edb3708c8c5 | 958 | #endif |
whismanoid | 0:3edb3708c8c5 | 959 | #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3 |
whismanoid | 0:3edb3708c8c5 | 960 | #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4 |
whismanoid | 0:3edb3708c8c5 | 961 | #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5 |
whismanoid | 0:3edb3708c8c5 | 962 | #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6 |
whismanoid | 0:3edb3708c8c5 | 963 | #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7 |
whismanoid | 0:3edb3708c8c5 | 964 | #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8 |
whismanoid | 0:3edb3708c8c5 | 965 | #if APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 966 | #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut |
whismanoid | 0:3edb3708c8c5 | 967 | #else |
whismanoid | 0:3edb3708c8c5 | 968 | #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9 |
whismanoid | 0:3edb3708c8c5 | 969 | #endif |
whismanoid | 0:3edb3708c8c5 | 970 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 971 | // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 972 | #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10 |
whismanoid | 0:3edb3708c8c5 | 973 | #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11 |
whismanoid | 0:3edb3708c8c5 | 974 | #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12 |
whismanoid | 0:3edb3708c8c5 | 975 | #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13 |
whismanoid | 0:3edb3708c8c5 | 976 | #else // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 977 | #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10 |
whismanoid | 0:3edb3708c8c5 | 978 | #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11 |
whismanoid | 0:3edb3708c8c5 | 979 | #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12 |
whismanoid | 0:3edb3708c8c5 | 980 | #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13 |
whismanoid | 0:3edb3708c8c5 | 981 | #endif // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 982 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 983 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 984 | #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 985 | #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 986 | #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 987 | #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 988 | #else // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 989 | #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 990 | #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 991 | #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 992 | #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 993 | #endif // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 994 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 995 | DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0 |
whismanoid | 0:3edb3708c8c5 | 996 | #endif |
whismanoid | 0:3edb3708c8c5 | 997 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 998 | DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1 |
whismanoid | 0:3edb3708c8c5 | 999 | #endif |
whismanoid | 0:3edb3708c8c5 | 1000 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 1001 | DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2 |
whismanoid | 0:3edb3708c8c5 | 1002 | #endif |
whismanoid | 0:3edb3708c8c5 | 1003 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 1004 | DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3 |
whismanoid | 0:3edb3708c8c5 | 1005 | #endif |
whismanoid | 0:3edb3708c8c5 | 1006 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 1007 | DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4 |
whismanoid | 0:3edb3708c8c5 | 1008 | #endif |
whismanoid | 0:3edb3708c8c5 | 1009 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 1010 | DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5 |
whismanoid | 0:3edb3708c8c5 | 1011 | #endif |
whismanoid | 0:3edb3708c8c5 | 1012 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 1013 | DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6 |
whismanoid | 0:3edb3708c8c5 | 1014 | #endif |
whismanoid | 0:3edb3708c8c5 | 1015 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 1016 | DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7 |
whismanoid | 0:3edb3708c8c5 | 1017 | #endif |
whismanoid | 0:3edb3708c8c5 | 1018 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 1019 | DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8 |
whismanoid | 0:3edb3708c8c5 | 1020 | #endif |
whismanoid | 0:3edb3708c8c5 | 1021 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 1022 | DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9 |
whismanoid | 0:3edb3708c8c5 | 1023 | #endif |
whismanoid | 0:3edb3708c8c5 | 1024 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 1025 | DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10 |
whismanoid | 0:3edb3708c8c5 | 1026 | #endif |
whismanoid | 0:3edb3708c8c5 | 1027 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 1028 | DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11 |
whismanoid | 0:3edb3708c8c5 | 1029 | #endif |
whismanoid | 0:3edb3708c8c5 | 1030 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 1031 | DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12 |
whismanoid | 0:3edb3708c8c5 | 1032 | #endif |
whismanoid | 0:3edb3708c8c5 | 1033 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 1034 | DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13 |
whismanoid | 0:3edb3708c8c5 | 1035 | #endif |
whismanoid | 0:3edb3708c8c5 | 1036 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 1037 | // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 |
whismanoid | 0:3edb3708c8c5 | 1038 | // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain |
whismanoid | 0:3edb3708c8c5 | 1039 | DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 1040 | #endif |
whismanoid | 0:3edb3708c8c5 | 1041 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 1042 | // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 |
whismanoid | 0:3edb3708c8c5 | 1043 | DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 1044 | #endif |
whismanoid | 0:3edb3708c8c5 | 1045 | #if HAS_digitalInOut16 |
whismanoid | 0:3edb3708c8c5 | 1046 | // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 |
whismanoid | 0:3edb3708c8c5 | 1047 | // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain |
whismanoid | 0:3edb3708c8c5 | 1048 | // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V |
whismanoid | 0:3edb3708c8c5 | 1049 | DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 1050 | #endif |
whismanoid | 0:3edb3708c8c5 | 1051 | #if HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 1052 | // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 |
whismanoid | 0:3edb3708c8c5 | 1053 | DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 1054 | #endif |
whismanoid | 0:3edb3708c8c5 | 1055 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1056 | #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 1057 | #define HAS_digitalInOut0 0 // P0_0 TARGET_MAX32625MBED D0 |
whismanoid | 0:3edb3708c8c5 | 1058 | #define HAS_digitalInOut1 0 // P0_1 TARGET_MAX32625MBED D1 |
whismanoid | 0:3edb3708c8c5 | 1059 | #if APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 1060 | #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn |
whismanoid | 0:3edb3708c8c5 | 1061 | #else |
whismanoid | 0:3edb3708c8c5 | 1062 | #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2 |
whismanoid | 0:3edb3708c8c5 | 1063 | #endif |
whismanoid | 0:3edb3708c8c5 | 1064 | #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3 |
whismanoid | 0:3edb3708c8c5 | 1065 | #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4 |
whismanoid | 0:3edb3708c8c5 | 1066 | #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5 |
whismanoid | 0:3edb3708c8c5 | 1067 | #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6 |
whismanoid | 0:3edb3708c8c5 | 1068 | #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7 |
whismanoid | 0:3edb3708c8c5 | 1069 | #if APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 1070 | #define HAS_digitalInOut8 0 // P1_4 TARGET_MAX32625MBED D8 -- MAX5715 CLRb DigitalOut |
whismanoid | 0:3edb3708c8c5 | 1071 | #else |
whismanoid | 0:3edb3708c8c5 | 1072 | #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8 |
whismanoid | 0:3edb3708c8c5 | 1073 | #endif |
whismanoid | 0:3edb3708c8c5 | 1074 | #if APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 1075 | #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX5715 LDACb DigitalOut |
whismanoid | 0:3edb3708c8c5 | 1076 | #elif APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 1077 | #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut |
whismanoid | 0:3edb3708c8c5 | 1078 | #else |
whismanoid | 0:3edb3708c8c5 | 1079 | #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9 |
whismanoid | 0:3edb3708c8c5 | 1080 | #endif |
whismanoid | 0:3edb3708c8c5 | 1081 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 1082 | // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 1083 | // Arduino digital pin D10 SPI function is CS/10 |
whismanoid | 0:3edb3708c8c5 | 1084 | // Arduino digital pin D11 SPI function is MOSI/11 |
whismanoid | 0:3edb3708c8c5 | 1085 | // Arduino digital pin D12 SPI function is MISO/12 |
whismanoid | 0:3edb3708c8c5 | 1086 | // Arduino digital pin D13 SPI function is SCK/13 |
whismanoid | 0:3edb3708c8c5 | 1087 | #define HAS_digitalInOut10 0 |
whismanoid | 0:3edb3708c8c5 | 1088 | #define HAS_digitalInOut11 0 |
whismanoid | 0:3edb3708c8c5 | 1089 | #define HAS_digitalInOut12 0 |
whismanoid | 0:3edb3708c8c5 | 1090 | #define HAS_digitalInOut13 0 |
whismanoid | 0:3edb3708c8c5 | 1091 | #else // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 1092 | #define HAS_digitalInOut10 1 |
whismanoid | 0:3edb3708c8c5 | 1093 | #define HAS_digitalInOut11 1 |
whismanoid | 0:3edb3708c8c5 | 1094 | #define HAS_digitalInOut12 1 |
whismanoid | 0:3edb3708c8c5 | 1095 | #define HAS_digitalInOut13 1 |
whismanoid | 0:3edb3708c8c5 | 1096 | #endif // HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 1097 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 1098 | // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 1099 | // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 1100 | // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 1101 | // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 1102 | // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 1103 | #define HAS_digitalInOut14 0 |
whismanoid | 0:3edb3708c8c5 | 1104 | #define HAS_digitalInOut15 0 |
whismanoid | 0:3edb3708c8c5 | 1105 | #define HAS_digitalInOut16 0 |
whismanoid | 0:3edb3708c8c5 | 1106 | #define HAS_digitalInOut17 0 |
whismanoid | 0:3edb3708c8c5 | 1107 | #else // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 1108 | #define HAS_digitalInOut14 1 |
whismanoid | 0:3edb3708c8c5 | 1109 | #define HAS_digitalInOut15 1 |
whismanoid | 0:3edb3708c8c5 | 1110 | #define HAS_digitalInOut16 0 |
whismanoid | 0:3edb3708c8c5 | 1111 | #define HAS_digitalInOut17 0 |
whismanoid | 0:3edb3708c8c5 | 1112 | #endif // HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 1113 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 1114 | DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1115 | #endif |
whismanoid | 0:3edb3708c8c5 | 1116 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 1117 | DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1118 | #endif |
whismanoid | 0:3edb3708c8c5 | 1119 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 1120 | DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1121 | #endif |
whismanoid | 0:3edb3708c8c5 | 1122 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 1123 | DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1124 | #endif |
whismanoid | 0:3edb3708c8c5 | 1125 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 1126 | DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1127 | #endif |
whismanoid | 0:3edb3708c8c5 | 1128 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 1129 | DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1130 | #endif |
whismanoid | 0:3edb3708c8c5 | 1131 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 1132 | DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1133 | #endif |
whismanoid | 0:3edb3708c8c5 | 1134 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 1135 | DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1136 | #endif |
whismanoid | 0:3edb3708c8c5 | 1137 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 1138 | DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1139 | #endif |
whismanoid | 0:3edb3708c8c5 | 1140 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 1141 | DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1142 | #endif |
whismanoid | 0:3edb3708c8c5 | 1143 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 1144 | // Arduino digital pin D10 SPI function is CS/10 |
whismanoid | 0:3edb3708c8c5 | 1145 | DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1146 | #endif |
whismanoid | 0:3edb3708c8c5 | 1147 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 1148 | // Arduino digital pin D11 SPI function is MOSI/11 |
whismanoid | 0:3edb3708c8c5 | 1149 | DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1150 | #endif |
whismanoid | 0:3edb3708c8c5 | 1151 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 1152 | // Arduino digital pin D12 SPI function is MISO/12 |
whismanoid | 0:3edb3708c8c5 | 1153 | DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1154 | #endif |
whismanoid | 0:3edb3708c8c5 | 1155 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 1156 | // Arduino digital pin D13 SPI function is SCK/13 |
whismanoid | 0:3edb3708c8c5 | 1157 | DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1158 | #endif |
whismanoid | 0:3edb3708c8c5 | 1159 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 1160 | // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 1161 | DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1162 | #endif |
whismanoid | 0:3edb3708c8c5 | 1163 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 1164 | // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 1165 | DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1166 | #endif |
whismanoid | 0:3edb3708c8c5 | 1167 | #if HAS_digitalInOut16 |
whismanoid | 0:3edb3708c8c5 | 1168 | // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 1169 | DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1170 | #endif |
whismanoid | 0:3edb3708c8c5 | 1171 | #if HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 1172 | // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 1173 | DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1174 | #endif |
whismanoid | 0:3edb3708c8c5 | 1175 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1176 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 1177 | #define HAS_digitalInOut0 1 |
whismanoid | 0:3edb3708c8c5 | 1178 | #define HAS_digitalInOut1 1 |
whismanoid | 0:3edb3708c8c5 | 1179 | #define HAS_digitalInOut2 1 |
whismanoid | 0:3edb3708c8c5 | 1180 | #define HAS_digitalInOut3 1 |
whismanoid | 0:3edb3708c8c5 | 1181 | #define HAS_digitalInOut4 1 |
whismanoid | 0:3edb3708c8c5 | 1182 | #define HAS_digitalInOut5 1 |
whismanoid | 0:3edb3708c8c5 | 1183 | #define HAS_digitalInOut6 1 |
whismanoid | 0:3edb3708c8c5 | 1184 | #define HAS_digitalInOut7 1 |
whismanoid | 0:3edb3708c8c5 | 1185 | #define HAS_digitalInOut8 1 |
whismanoid | 0:3edb3708c8c5 | 1186 | #define HAS_digitalInOut9 1 |
whismanoid | 0:3edb3708c8c5 | 1187 | // #define HAS_digitalInOut10 1 |
whismanoid | 0:3edb3708c8c5 | 1188 | // #define HAS_digitalInOut11 1 |
whismanoid | 0:3edb3708c8c5 | 1189 | // #define HAS_digitalInOut12 1 |
whismanoid | 0:3edb3708c8c5 | 1190 | // #define HAS_digitalInOut13 1 |
whismanoid | 0:3edb3708c8c5 | 1191 | // #define HAS_digitalInOut14 1 |
whismanoid | 0:3edb3708c8c5 | 1192 | // #define HAS_digitalInOut15 1 |
whismanoid | 0:3edb3708c8c5 | 1193 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 1194 | DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3 |
whismanoid | 0:3edb3708c8c5 | 1195 | #endif |
whismanoid | 0:3edb3708c8c5 | 1196 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 1197 | DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2 |
whismanoid | 0:3edb3708c8c5 | 1198 | #endif |
whismanoid | 0:3edb3708c8c5 | 1199 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 1200 | DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1 |
whismanoid | 0:3edb3708c8c5 | 1201 | #endif |
whismanoid | 0:3edb3708c8c5 | 1202 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 1203 | DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0 |
whismanoid | 0:3edb3708c8c5 | 1204 | #endif |
whismanoid | 0:3edb3708c8c5 | 1205 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 1206 | DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1 |
whismanoid | 0:3edb3708c8c5 | 1207 | #endif |
whismanoid | 0:3edb3708c8c5 | 1208 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 1209 | DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1 |
whismanoid | 0:3edb3708c8c5 | 1210 | #endif |
whismanoid | 0:3edb3708c8c5 | 1211 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 1212 | DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1 |
whismanoid | 0:3edb3708c8c5 | 1213 | #endif |
whismanoid | 0:3edb3708c8c5 | 1214 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 1215 | DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO |
whismanoid | 0:3edb3708c8c5 | 1216 | #endif |
whismanoid | 0:3edb3708c8c5 | 1217 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 1218 | DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK |
whismanoid | 0:3edb3708c8c5 | 1219 | #endif |
whismanoid | 0:3edb3708c8c5 | 1220 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 1221 | DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL |
whismanoid | 0:3edb3708c8c5 | 1222 | #endif |
whismanoid | 0:3edb3708c8c5 | 1223 | // |
whismanoid | 0:3edb3708c8c5 | 1224 | // these pins support analog input analogIn0 .. analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1225 | //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0 |
whismanoid | 0:3edb3708c8c5 | 1226 | //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1 |
whismanoid | 0:3edb3708c8c5 | 1227 | //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3 |
whismanoid | 0:3edb3708c8c5 | 1228 | //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3 |
whismanoid | 0:3edb3708c8c5 | 1229 | //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4 |
whismanoid | 0:3edb3708c8c5 | 1230 | //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5 |
whismanoid | 0:3edb3708c8c5 | 1231 | // |
whismanoid | 0:3edb3708c8c5 | 1232 | // these pins support PWM pwmDriver1 .. pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 1233 | //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0 |
whismanoid | 0:3edb3708c8c5 | 1234 | //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1 |
whismanoid | 0:3edb3708c8c5 | 1235 | //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2 |
whismanoid | 0:3edb3708c8c5 | 1236 | //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3 |
whismanoid | 0:3edb3708c8c5 | 1237 | //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1 |
whismanoid | 0:3edb3708c8c5 | 1238 | //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK |
whismanoid | 0:3edb3708c8c5 | 1239 | // |
whismanoid | 0:3edb3708c8c5 | 1240 | // these could be additional digitalInOut pins |
whismanoid | 0:3edb3708c8c5 | 1241 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 1242 | DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1 |
whismanoid | 0:3edb3708c8c5 | 1243 | #endif |
whismanoid | 0:3edb3708c8c5 | 1244 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 1245 | DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0 |
whismanoid | 0:3edb3708c8c5 | 1246 | #endif |
whismanoid | 0:3edb3708c8c5 | 1247 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 1248 | DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1 |
whismanoid | 0:3edb3708c8c5 | 1249 | #endif |
whismanoid | 0:3edb3708c8c5 | 1250 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 1251 | DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0 |
whismanoid | 0:3edb3708c8c5 | 1252 | #endif |
whismanoid | 0:3edb3708c8c5 | 1253 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 1254 | DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1255 | #endif |
whismanoid | 0:3edb3708c8c5 | 1256 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 1257 | DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1); |
whismanoid | 0:3edb3708c8c5 | 1258 | #endif |
whismanoid | 0:3edb3708c8c5 | 1259 | #else |
whismanoid | 0:3edb3708c8c5 | 1260 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 1261 | #endif |
whismanoid | 0:3edb3708c8c5 | 1262 | // uncrustify-0.66.1 *INDENT-ON* |
whismanoid | 0:3edb3708c8c5 | 1263 | #if HAS_digitalInOut0 || HAS_digitalInOut1 \ |
whismanoid | 0:3edb3708c8c5 | 1264 | || HAS_digitalInOut2 || HAS_digitalInOut3 \ |
whismanoid | 0:3edb3708c8c5 | 1265 | || HAS_digitalInOut4 || HAS_digitalInOut5 \ |
whismanoid | 0:3edb3708c8c5 | 1266 | || HAS_digitalInOut6 || HAS_digitalInOut7 \ |
whismanoid | 0:3edb3708c8c5 | 1267 | || HAS_digitalInOut8 || HAS_digitalInOut9 \ |
whismanoid | 0:3edb3708c8c5 | 1268 | || HAS_digitalInOut10 || HAS_digitalInOut11 \ |
whismanoid | 0:3edb3708c8c5 | 1269 | || HAS_digitalInOut12 || HAS_digitalInOut13 \ |
whismanoid | 0:3edb3708c8c5 | 1270 | || HAS_digitalInOut14 || HAS_digitalInOut15 \ |
whismanoid | 0:3edb3708c8c5 | 1271 | || HAS_digitalInOut16 || HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 1272 | #define HAS_digitalInOuts 1 |
whismanoid | 0:3edb3708c8c5 | 1273 | #endif |
whismanoid | 0:3edb3708c8c5 | 1274 | |
whismanoid | 0:3edb3708c8c5 | 1275 | // uncrustify-0.66.1 *INDENT-OFF* |
whismanoid | 0:3edb3708c8c5 | 1276 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1277 | // Declare the PwmOut driver |
whismanoid | 0:3edb3708c8c5 | 1278 | // Optional PwmOut support. If there is only one it should be pwmDriver1. |
whismanoid | 0:3edb3708c8c5 | 1279 | // P) PWM pin#, duty cycle |
whismanoid | 0:3edb3708c8c5 | 1280 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 1281 | // +-------------[microUSB]-------------+ |
whismanoid | 0:3edb3708c8c5 | 1282 | // | J1 MAX32630FTHR J2 | |
whismanoid | 0:3edb3708c8c5 | 1283 | // | [ ] RST GND [ ] | |
whismanoid | 0:3edb3708c8c5 | 1284 | // | [ ] 3V3 BAT+[ ] | |
whismanoid | 0:3edb3708c8c5 | 1285 | // | [ ] 1V8 reset SW1 | |
whismanoid | 0:3edb3708c8c5 | 1286 | // | [ ] GND J4 J3 | |
whismanoid | 0:3edb3708c8c5 | 1287 | // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] | |
whismanoid | 0:3edb3708c8c5 | 1288 | // | [ ] AIN_1 1.2Vfs PWR [ ] | |
whismanoid | 0:3edb3708c8c5 | 1289 | // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] | |
whismanoid | 0:3edb3708c8c5 | 1290 | // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [x] | pwm4 |
whismanoid | 0:3edb3708c8c5 | 1291 | // | [ ] P5_7 SDA2 SRN P5_6 [x] | pwm5 |
whismanoid | 0:3edb3708c8c5 | 1292 | // | [ ] P6_0 SCL2 SDIO3 P5_5 [x] | pwm6 |
whismanoid | 0:3edb3708c8c5 | 1293 | // pwm13 | [ ] P5_0 SCLK SDIO2 P5_4 [x] | pwm7 |
whismanoid | 0:3edb3708c8c5 | 1294 | // pwm14 | [ ] P5_1 MOSI SSEL P5_3 [x] | pwm8 |
whismanoid | 0:3edb3708c8c5 | 1295 | // pwm3 | [x] P5_2 MISO RTS P3_3 [x] | pwm9 |
whismanoid | 0:3edb3708c8c5 | 1296 | // pwm2 | [x] P3_0 RX CTS P3_2 [ ] | pwm10 |
whismanoid | 0:3edb3708c8c5 | 1297 | // pwm1 | [x] P3_1 TX SCL P3_5 [ ] | pwm11 |
whismanoid | 0:3edb3708c8c5 | 1298 | // | [ ] GND SDA P3_4 [ ] | pwm12 |
whismanoid | 0:3edb3708c8c5 | 1299 | // +------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 1300 | // MAX32630FTHR mbed PwmOut driver is limited to 32-bit counter value; |
whismanoid | 0:3edb3708c8c5 | 1301 | // see pwmout_update function in mbed-os/targets/TARGET_Maxim/TARGET_MAX32630/pwmout_api.c |
whismanoid | 0:3edb3708c8c5 | 1302 | // int div = (obj->period * (SystemCoreClock / 1000000))/32; |
whismanoid | 0:3edb3708c8c5 | 1303 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 1304 | // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut |
whismanoid | 0:3edb3708c8c5 | 1305 | #define HAS_pwmDriver13 0 // P5_0 PT8 TARGET_MAX32630 J1.11 pass ok; conflict PT8 P3_0 P5_0 |
whismanoid | 0:3edb3708c8c5 | 1306 | #define HAS_pwmDriver14 0 // P5_1 PT9 TARGET_MAX32630 J1.12 pass ok; conflict PT9 P3_1 P5_1 |
whismanoid | 0:3edb3708c8c5 | 1307 | #define HAS_pwmDriver3 0 // P5_2 PT10 TARGET_MAX32630 J1.13 pass ok; conflict PT10 P3_2 P5_2 |
whismanoid | 0:3edb3708c8c5 | 1308 | #define HAS_pwmDriver2 0 // P3_0 PT8 TARGET_MAX32630 J1.14 pass ok; conflict PT8 P3_0 P5_0 |
whismanoid | 0:3edb3708c8c5 | 1309 | #endif |
whismanoid | 0:3edb3708c8c5 | 1310 | // #define HAS_pwmDriver0 0 // not assigned |
whismanoid | 0:3edb3708c8c5 | 1311 | # ifndef HAS_pwmDriver1 |
whismanoid | 0:3edb3708c8c5 | 1312 | //~ #define HAS_pwmDriver1 1 // P3_1 PT9 TARGET_MAX32630 J1.15 pass ok; conflict PT9 P3_1 P5_1 |
whismanoid | 0:3edb3708c8c5 | 1313 | # endif |
whismanoid | 0:3edb3708c8c5 | 1314 | # ifndef HAS_pwmDriver2 |
whismanoid | 0:3edb3708c8c5 | 1315 | #define HAS_pwmDriver2 1 // P3_0 PT8 TARGET_MAX32630 J1.14 pass ok; conflict PT8 P3_0 P5_0 |
whismanoid | 0:3edb3708c8c5 | 1316 | # endif |
whismanoid | 0:3edb3708c8c5 | 1317 | # ifndef HAS_pwmDriver3 |
whismanoid | 0:3edb3708c8c5 | 1318 | #define HAS_pwmDriver3 1 // P5_2 PT10 TARGET_MAX32630 J1.13 pass ok; conflict PT10 P3_2 P5_2 |
whismanoid | 0:3edb3708c8c5 | 1319 | # endif |
whismanoid | 0:3edb3708c8c5 | 1320 | # ifndef HAS_pwmDriver4 |
whismanoid | 0:3edb3708c8c5 | 1321 | //~ #define HAS_pwmDriver4 1 // P4_0 PT0 TARGET_MAX32630 J3.4 pass ok |
whismanoid | 0:3edb3708c8c5 | 1322 | # endif |
whismanoid | 0:3edb3708c8c5 | 1323 | # ifndef HAS_pwmDriver5 |
whismanoid | 0:3edb3708c8c5 | 1324 | //~ #define HAS_pwmDriver5 1 // P5_6 PT14 TARGET_MAX32630 J3.5 pass ok |
whismanoid | 0:3edb3708c8c5 | 1325 | # endif |
whismanoid | 0:3edb3708c8c5 | 1326 | # ifndef HAS_pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 1327 | //~ #define HAS_pwmDriver6 1 // P5_5 PT13 TARGET_MAX32630 J3.6 pass ok; conflict PT13 P3_5 P5_5 |
whismanoid | 0:3edb3708c8c5 | 1328 | # endif |
whismanoid | 0:3edb3708c8c5 | 1329 | # ifndef HAS_pwmDriver7 |
whismanoid | 0:3edb3708c8c5 | 1330 | //~ #define HAS_pwmDriver7 1 // P5_4 PT12 TARGET_MAX32630 J3.7 pass ok; conflict PT12 P3_4 P5_4 |
whismanoid | 0:3edb3708c8c5 | 1331 | # endif |
whismanoid | 0:3edb3708c8c5 | 1332 | # ifndef HAS_pwmDriver8 |
whismanoid | 0:3edb3708c8c5 | 1333 | //~ #define HAS_pwmDriver8 1 // P5_3 PT11 TARGET_MAX32630 J3.8 pass ok; conflict PT11 P3_3 P5_3 |
whismanoid | 0:3edb3708c8c5 | 1334 | # endif |
whismanoid | 0:3edb3708c8c5 | 1335 | # ifndef HAS_pwmDriver9 |
whismanoid | 0:3edb3708c8c5 | 1336 | // #define HAS_pwmDriver9 1 // P3_3 PT11 TARGET_MAX32630 J3.9 pass ok; conflict PT11 P3_3 P5_3 |
whismanoid | 0:3edb3708c8c5 | 1337 | # endif |
whismanoid | 0:3edb3708c8c5 | 1338 | # ifndef HAS_pwmDriver10 |
whismanoid | 0:3edb3708c8c5 | 1339 | // #define HAS_pwmDriver10 1 // P3_2 PT10 TARGET_MAX32630 J3.10 pass ok; conflict PT10 P3_2 P5_2 |
whismanoid | 0:3edb3708c8c5 | 1340 | # endif |
whismanoid | 0:3edb3708c8c5 | 1341 | # ifndef HAS_pwmDriver11 |
whismanoid | 0:3edb3708c8c5 | 1342 | // #define HAS_pwmDriver11 1 // P3_5 PT13 TARGET_MAX32630 J3.11 pass ok; conflict PT13 P3_5 P5_5 |
whismanoid | 0:3edb3708c8c5 | 1343 | # endif |
whismanoid | 0:3edb3708c8c5 | 1344 | # ifndef HAS_pwmDriver12 |
whismanoid | 0:3edb3708c8c5 | 1345 | // #define HAS_pwmDriver12 1 // P3_4 PT12 TARGET_MAX32630 J3.12 pass ok; conflict PT12 P3_4 P5_4 |
whismanoid | 0:3edb3708c8c5 | 1346 | # endif |
whismanoid | 0:3edb3708c8c5 | 1347 | # ifndef HAS_pwmDriver13 |
whismanoid | 0:3edb3708c8c5 | 1348 | // #define HAS_pwmDriver13 1 // P5_0 PT8 TARGET_MAX32630 J1.11 pass ok; conflict PT8 P3_0 P5_0 |
whismanoid | 0:3edb3708c8c5 | 1349 | # endif |
whismanoid | 0:3edb3708c8c5 | 1350 | # ifndef HAS_pwmDriver14 |
whismanoid | 0:3edb3708c8c5 | 1351 | // #define HAS_pwmDriver14 1 // P5_1 PT9 TARGET_MAX32630 J1.12 pass ok; conflict PT9 P3_1 P5_1 |
whismanoid | 0:3edb3708c8c5 | 1352 | # endif |
whismanoid | 0:3edb3708c8c5 | 1353 | # ifndef HAS_pwmDriver15 |
whismanoid | 0:3edb3708c8c5 | 1354 | // #define HAS_pwmDriver15 0 // not assigned |
whismanoid | 0:3edb3708c8c5 | 1355 | # endif |
whismanoid | 0:3edb3708c8c5 | 1356 | #if HAS_pwmDriver0 |
whismanoid | 0:3edb3708c8c5 | 1357 | PwmOut pwmDriver0(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1358 | #endif |
whismanoid | 0:3edb3708c8c5 | 1359 | #if HAS_pwmDriver1 |
whismanoid | 0:3edb3708c8c5 | 1360 | PwmOut pwmDriver1(P3_1); // PT9 TARGET_MAX32630 J1.15 pass ok |
whismanoid | 0:3edb3708c8c5 | 1361 | // Investigating which TARGET_MAX32630 PWM drivers work. |
whismanoid | 0:3edb3708c8c5 | 1362 | // fail assert = runtime failure at system boot, as the only pwm pin |
whismanoid | 0:3edb3708c8c5 | 1363 | // pass? = no runtime failure as the only pwm pin, may be ok |
whismanoid | 0:3edb3708c8c5 | 1364 | // pass ok = plays well with others |
whismanoid | 0:3edb3708c8c5 | 1365 | // PT0..PT15 identify which Pulse Train resource drives that GPIO pin |
whismanoid | 0:3edb3708c8c5 | 1366 | //PwmOut pwmDriver1(P5_7); // P5_7 PT15 TARGET_MAX32630 J1.9 fail assert; resource conflict |
whismanoid | 0:3edb3708c8c5 | 1367 | //PwmOut pwmDriver1(P6_0); // P6_0 PT0 TARGET_MAX32630 J1.10 fail assert; resource conflict |
whismanoid | 0:3edb3708c8c5 | 1368 | //PwmOut pwmDriver1(P5_0); // P5_0 PT8 TARGET_MAX32630 J1.11 pass ok; conflict PT8 P3_0 P5_0 |
whismanoid | 0:3edb3708c8c5 | 1369 | //PwmOut pwmDriver1(P5_1); // P5_1 PT9 TARGET_MAX32630 J1.12 pass ok; conflict PT9 P3_1 P5_1 |
whismanoid | 0:3edb3708c8c5 | 1370 | //PwmOut pwmDriver1(P5_2); // P5_2 PT10 TARGET_MAX32630 J1.13 pass ok; conflict PT10 P3_2 P5_2 |
whismanoid | 0:3edb3708c8c5 | 1371 | //PwmOut pwmDriver1(P3_0); // P3_0 PT8 TARGET_MAX32630 J1.14 pass ok; conflict PT8 P3_0 P5_0 |
whismanoid | 0:3edb3708c8c5 | 1372 | //PwmOut pwmDriver1(P3_1); // P3_1 PT9 TARGET_MAX32630 J1.15 pass ok; conflict PT9 P3_1 P5_1 |
whismanoid | 0:3edb3708c8c5 | 1373 | // |
whismanoid | 0:3edb3708c8c5 | 1374 | //PwmOut pwmDriver1(P4_0); // P4_0 PT0 TARGET_MAX32630 J3.4 pass ok |
whismanoid | 0:3edb3708c8c5 | 1375 | //PwmOut pwmDriver1(P5_6); // P5_6 PT14 TARGET_MAX32630 J3.5 pass ok |
whismanoid | 0:3edb3708c8c5 | 1376 | //PwmOut pwmDriver1(P5_5); // P5_5 PT13 TARGET_MAX32630 J3.6 pass ok; conflict PT13 P3_5 P5_5 |
whismanoid | 0:3edb3708c8c5 | 1377 | //PwmOut pwmDriver1(P5_4); // P5_4 PT12 TARGET_MAX32630 J3.7 pass ok; conflict PT12 P3_4 P5_4 |
whismanoid | 0:3edb3708c8c5 | 1378 | //PwmOut pwmDriver1(P5_3); // P5_3 PT11 TARGET_MAX32630 J3.8 pass ok; conflict PT11 P3_3 P5_3 |
whismanoid | 0:3edb3708c8c5 | 1379 | //PwmOut pwmDriver1(P3_3); // P3_3 PT11 TARGET_MAX32630 J3.9 pass ok; conflict PT11 P3_3 P5_3 |
whismanoid | 0:3edb3708c8c5 | 1380 | //PwmOut pwmDriver1(P3_2); // P3_2 PT10 TARGET_MAX32630 J3.10 pass ok; conflict PT10 P3_2 P5_2 |
whismanoid | 0:3edb3708c8c5 | 1381 | //PwmOut pwmDriver1(P3_5); // P3_5 PT13 TARGET_MAX32630 J3.11 pass ok; conflict PT13 P3_5 P5_5 |
whismanoid | 0:3edb3708c8c5 | 1382 | //PwmOut pwmDriver1(P3_4); // P3_4 PT12 TARGET_MAX32630 J3.12 pass ok; conflict PT12 P3_4 P5_4 |
whismanoid | 0:3edb3708c8c5 | 1383 | #endif |
whismanoid | 0:3edb3708c8c5 | 1384 | #if HAS_pwmDriver2 |
whismanoid | 0:3edb3708c8c5 | 1385 | PwmOut pwmDriver2(P3_0); // P3_0 PT8 TARGET_MAX32630 J1.14 pass ok; conflict PT8 P3_0 P5_0 |
whismanoid | 0:3edb3708c8c5 | 1386 | #endif |
whismanoid | 0:3edb3708c8c5 | 1387 | #if HAS_pwmDriver3 |
whismanoid | 0:3edb3708c8c5 | 1388 | PwmOut pwmDriver3(P5_2); // P5_2 PT10 TARGET_MAX32630 J1.13 pass ok; conflict PT10 P3_2 P5_2 |
whismanoid | 0:3edb3708c8c5 | 1389 | #endif |
whismanoid | 0:3edb3708c8c5 | 1390 | #if HAS_pwmDriver4 |
whismanoid | 0:3edb3708c8c5 | 1391 | PwmOut pwmDriver4(P4_0); // P4_0 PT0 TARGET_MAX32630 J3.4 pass ok |
whismanoid | 0:3edb3708c8c5 | 1392 | #endif |
whismanoid | 0:3edb3708c8c5 | 1393 | #if HAS_pwmDriver5 |
whismanoid | 0:3edb3708c8c5 | 1394 | PwmOut pwmDriver5(P5_6); // P5_6 PT14 TARGET_MAX32630 J3.5 pass ok |
whismanoid | 0:3edb3708c8c5 | 1395 | #endif |
whismanoid | 0:3edb3708c8c5 | 1396 | #if HAS_pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 1397 | PwmOut pwmDriver6(P5_5); // P5_5 PT13 TARGET_MAX32630 J3.6 pass ok; conflict PT13 P3_5 P5_5 |
whismanoid | 0:3edb3708c8c5 | 1398 | #endif |
whismanoid | 0:3edb3708c8c5 | 1399 | #if HAS_pwmDriver7 |
whismanoid | 0:3edb3708c8c5 | 1400 | PwmOut pwmDriver7(P5_4); // P5_4 PT12 TARGET_MAX32630 J3.7 pass ok; conflict PT12 P3_4 P5_4 |
whismanoid | 0:3edb3708c8c5 | 1401 | #endif |
whismanoid | 0:3edb3708c8c5 | 1402 | #if HAS_pwmDriver8 |
whismanoid | 0:3edb3708c8c5 | 1403 | PwmOut pwmDriver8(P5_3); // P5_3 PT11 TARGET_MAX32630 J3.8 pass ok; conflict PT11 P3_3 P5_3 |
whismanoid | 0:3edb3708c8c5 | 1404 | #endif |
whismanoid | 0:3edb3708c8c5 | 1405 | #if HAS_pwmDriver9 |
whismanoid | 0:3edb3708c8c5 | 1406 | PwmOut pwmDriver9(P3_3); // P3_3 PT11 TARGET_MAX32630 J3.9 pass ok; conflict PT11 P3_3 P5_3 |
whismanoid | 0:3edb3708c8c5 | 1407 | #endif |
whismanoid | 0:3edb3708c8c5 | 1408 | #if HAS_pwmDriver10 |
whismanoid | 0:3edb3708c8c5 | 1409 | PwmOut pwmDriver10(P3_2); // P3_2 PT10 TARGET_MAX32630 J3.10 pass ok; conflict PT10 P3_2 P5_2 |
whismanoid | 0:3edb3708c8c5 | 1410 | #endif |
whismanoid | 0:3edb3708c8c5 | 1411 | #if HAS_pwmDriver11 |
whismanoid | 0:3edb3708c8c5 | 1412 | PwmOut pwmDriver11(P3_5); // P3_5 PT13 TARGET_MAX32630 J3.11 pass ok; conflict PT13 P3_5 P5_5 |
whismanoid | 0:3edb3708c8c5 | 1413 | #endif |
whismanoid | 0:3edb3708c8c5 | 1414 | #if HAS_pwmDriver12 |
whismanoid | 0:3edb3708c8c5 | 1415 | PwmOut pwmDriver12(P3_4); // P3_4 PT12 TARGET_MAX32630 J3.12 pass ok; conflict PT12 P3_4 P5_4 |
whismanoid | 0:3edb3708c8c5 | 1416 | #endif |
whismanoid | 0:3edb3708c8c5 | 1417 | #if HAS_pwmDriver13 |
whismanoid | 0:3edb3708c8c5 | 1418 | PwmOut pwmDriver13(P5_0); // P5_0 PT8 TARGET_MAX32630 J1.11 pass ok; conflict PT8 P3_0 P5_0 |
whismanoid | 0:3edb3708c8c5 | 1419 | #endif |
whismanoid | 0:3edb3708c8c5 | 1420 | #if HAS_pwmDriver14 |
whismanoid | 0:3edb3708c8c5 | 1421 | PwmOut pwmDriver14(P5_1); // P5_1 PT9 TARGET_MAX32630 J1.12 pass ok; conflict PT9 P3_1 P5_1 |
whismanoid | 0:3edb3708c8c5 | 1422 | #endif |
whismanoid | 0:3edb3708c8c5 | 1423 | #if HAS_pwmDriver15 |
whismanoid | 0:3edb3708c8c5 | 1424 | PwmOut pwmDriver15(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1425 | #endif |
whismanoid | 0:3edb3708c8c5 | 1426 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1427 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 1428 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1429 | // TODO1: pwmDriver TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 1430 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 1431 | // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM |
whismanoid | 0:3edb3708c8c5 | 1432 | // +-------------[microUSB]-------------+ |
whismanoid | 0:3edb3708c8c5 | 1433 | // ______ | [ ] GND +3.3V VOUT [ ] | |
whismanoid | 0:3edb3708c8c5 | 1434 | // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | |
whismanoid | 0:3edb3708c8c5 | 1435 | // ______ | [ ] VB USB.IF- [ ] | |
whismanoid | 0:3edb3708c8c5 | 1436 | // ______ | [ ] nR USB.IF+ [ ] | |
whismanoid | 0:3edb3708c8c5 | 1437 | // ______ | [ ] p5 MOSI ETHERNET.RD- [ ] | |
whismanoid | 0:3edb3708c8c5 | 1438 | // ______ | [ ] p6 MISO ETHERNET.RD+ [ ] | |
whismanoid | 0:3edb3708c8c5 | 1439 | // ______ | [ ] p7 SCLK ETHERNET.TD- [ ] | |
whismanoid | 0:3edb3708c8c5 | 1440 | // ______ | [ ] p8 ETHERNET.TD+ [ ] | |
whismanoid | 0:3edb3708c8c5 | 1441 | // ______ | [ ] p9 TX SDA USB.D- [ ] | |
whismanoid | 0:3edb3708c8c5 | 1442 | // ______ | [ ] p10 RX SCL USB.D+ [ ] | |
whismanoid | 0:3edb3708c8c5 | 1443 | // ______ | [ ] p11 MOSI CAN-RD p30 [ ] | |
whismanoid | 0:3edb3708c8c5 | 1444 | // ______ | [ ] p12 MISO CAN-TD p29 [ ] | |
whismanoid | 0:3edb3708c8c5 | 1445 | // ______ | [ ] p13 TX SCLK SDA TX p28 [ ] | |
whismanoid | 0:3edb3708c8c5 | 1446 | // ______ | [ ] p14 RX SCL RX p27 [ ] | |
whismanoid | 0:3edb3708c8c5 | 1447 | // ______ | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1 |
whismanoid | 0:3edb3708c8c5 | 1448 | // ______ | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2 |
whismanoid | 0:3edb3708c8c5 | 1449 | // ______ | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3 |
whismanoid | 0:3edb3708c8c5 | 1450 | // ______ | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4 |
whismanoid | 0:3edb3708c8c5 | 1451 | // ______ | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5 |
whismanoid | 0:3edb3708c8c5 | 1452 | // ______ | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 1453 | // +------------------------------------+ |
whismanoid | 0:3edb3708c8c5 | 1454 | // #define HAS_pwmDriver0 1 |
whismanoid | 0:3edb3708c8c5 | 1455 | # ifndef HAS_pwmDriver1 |
whismanoid | 0:3edb3708c8c5 | 1456 | #define HAS_pwmDriver1 1 |
whismanoid | 0:3edb3708c8c5 | 1457 | # endif |
whismanoid | 0:3edb3708c8c5 | 1458 | # ifndef HAS_pwmDriver2 |
whismanoid | 0:3edb3708c8c5 | 1459 | #define HAS_pwmDriver2 1 |
whismanoid | 0:3edb3708c8c5 | 1460 | # endif |
whismanoid | 0:3edb3708c8c5 | 1461 | # ifndef HAS_pwmDriver3 |
whismanoid | 0:3edb3708c8c5 | 1462 | #define HAS_pwmDriver3 1 |
whismanoid | 0:3edb3708c8c5 | 1463 | # endif |
whismanoid | 0:3edb3708c8c5 | 1464 | # ifndef HAS_pwmDriver4 |
whismanoid | 0:3edb3708c8c5 | 1465 | #define HAS_pwmDriver4 1 |
whismanoid | 0:3edb3708c8c5 | 1466 | # endif |
whismanoid | 0:3edb3708c8c5 | 1467 | # ifndef HAS_pwmDriver5 |
whismanoid | 0:3edb3708c8c5 | 1468 | #define HAS_pwmDriver5 1 |
whismanoid | 0:3edb3708c8c5 | 1469 | # endif |
whismanoid | 0:3edb3708c8c5 | 1470 | # ifndef HAS_pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 1471 | #define HAS_pwmDriver6 1 |
whismanoid | 0:3edb3708c8c5 | 1472 | # endif |
whismanoid | 0:3edb3708c8c5 | 1473 | # ifndef HAS_pwmDriver7 |
whismanoid | 0:3edb3708c8c5 | 1474 | // #define HAS_pwmDriver7 1 |
whismanoid | 0:3edb3708c8c5 | 1475 | # endif |
whismanoid | 0:3edb3708c8c5 | 1476 | # ifndef HAS_pwmDriver8 |
whismanoid | 0:3edb3708c8c5 | 1477 | // #define HAS_pwmDriver8 1 |
whismanoid | 0:3edb3708c8c5 | 1478 | # endif |
whismanoid | 0:3edb3708c8c5 | 1479 | # ifndef HAS_pwmDriver9 |
whismanoid | 0:3edb3708c8c5 | 1480 | // #define HAS_pwmDriver9 1 |
whismanoid | 0:3edb3708c8c5 | 1481 | # endif |
whismanoid | 0:3edb3708c8c5 | 1482 | # ifndef HAS_pwmDriver10 |
whismanoid | 0:3edb3708c8c5 | 1483 | // #define HAS_pwmDriver10 1 |
whismanoid | 0:3edb3708c8c5 | 1484 | # endif |
whismanoid | 0:3edb3708c8c5 | 1485 | # ifndef HAS_pwmDriver11 |
whismanoid | 0:3edb3708c8c5 | 1486 | // #define HAS_pwmDriver11 1 |
whismanoid | 0:3edb3708c8c5 | 1487 | # endif |
whismanoid | 0:3edb3708c8c5 | 1488 | # ifndef HAS_pwmDriver12 |
whismanoid | 0:3edb3708c8c5 | 1489 | // #define HAS_pwmDriver12 1 |
whismanoid | 0:3edb3708c8c5 | 1490 | # endif |
whismanoid | 0:3edb3708c8c5 | 1491 | # ifndef HAS_pwmDriver13 |
whismanoid | 0:3edb3708c8c5 | 1492 | // #define HAS_pwmDriver13 1 |
whismanoid | 0:3edb3708c8c5 | 1493 | # endif |
whismanoid | 0:3edb3708c8c5 | 1494 | # ifndef HAS_pwmDriver14 |
whismanoid | 0:3edb3708c8c5 | 1495 | // #define HAS_pwmDriver14 1 |
whismanoid | 0:3edb3708c8c5 | 1496 | # endif |
whismanoid | 0:3edb3708c8c5 | 1497 | # ifndef HAS_pwmDriver15 |
whismanoid | 0:3edb3708c8c5 | 1498 | // #define HAS_pwmDriver15 1 |
whismanoid | 0:3edb3708c8c5 | 1499 | # endif |
whismanoid | 0:3edb3708c8c5 | 1500 | #if HAS_pwmDriver0 |
whismanoid | 0:3edb3708c8c5 | 1501 | PwmOut pwmDriver0(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1502 | #endif |
whismanoid | 0:3edb3708c8c5 | 1503 | #if HAS_pwmDriver1 |
whismanoid | 0:3edb3708c8c5 | 1504 | PwmOut pwmDriver1(p26); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK |
whismanoid | 0:3edb3708c8c5 | 1505 | #endif |
whismanoid | 0:3edb3708c8c5 | 1506 | #if HAS_pwmDriver2 |
whismanoid | 0:3edb3708c8c5 | 1507 | PwmOut pwmDriver2(p25); // TARGET_LPC1768 P2.1/PWM1.2/RXD1 |
whismanoid | 0:3edb3708c8c5 | 1508 | #endif |
whismanoid | 0:3edb3708c8c5 | 1509 | #if HAS_pwmDriver3 |
whismanoid | 0:3edb3708c8c5 | 1510 | PwmOut pwmDriver3(p24); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3 |
whismanoid | 0:3edb3708c8c5 | 1511 | #endif |
whismanoid | 0:3edb3708c8c5 | 1512 | #if HAS_pwmDriver4 |
whismanoid | 0:3edb3708c8c5 | 1513 | PwmOut pwmDriver4(p23); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2 |
whismanoid | 0:3edb3708c8c5 | 1514 | #endif |
whismanoid | 0:3edb3708c8c5 | 1515 | #if HAS_pwmDriver5 |
whismanoid | 0:3edb3708c8c5 | 1516 | PwmOut pwmDriver5(p22); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1 |
whismanoid | 0:3edb3708c8c5 | 1517 | #endif |
whismanoid | 0:3edb3708c8c5 | 1518 | #if HAS_pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 1519 | PwmOut pwmDriver6(p21); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0 |
whismanoid | 0:3edb3708c8c5 | 1520 | #endif |
whismanoid | 0:3edb3708c8c5 | 1521 | #if HAS_pwmDriver7 |
whismanoid | 0:3edb3708c8c5 | 1522 | PwmOut pwmDriver7(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1523 | #endif |
whismanoid | 0:3edb3708c8c5 | 1524 | #if HAS_pwmDriver8 |
whismanoid | 0:3edb3708c8c5 | 1525 | PwmOut pwmDriver8(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1526 | #endif |
whismanoid | 0:3edb3708c8c5 | 1527 | #if HAS_pwmDriver9 |
whismanoid | 0:3edb3708c8c5 | 1528 | PwmOut pwmDriver9(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1529 | #endif |
whismanoid | 0:3edb3708c8c5 | 1530 | #if HAS_pwmDriver10 |
whismanoid | 0:3edb3708c8c5 | 1531 | PwmOut pwmDriver10(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1532 | #endif |
whismanoid | 0:3edb3708c8c5 | 1533 | #if HAS_pwmDriver11 |
whismanoid | 0:3edb3708c8c5 | 1534 | PwmOut pwmDriver11(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1535 | #endif |
whismanoid | 0:3edb3708c8c5 | 1536 | #if HAS_pwmDriver12 |
whismanoid | 0:3edb3708c8c5 | 1537 | PwmOut pwmDriver12(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1538 | #endif |
whismanoid | 0:3edb3708c8c5 | 1539 | #if HAS_pwmDriver13 |
whismanoid | 0:3edb3708c8c5 | 1540 | PwmOut pwmDriver13(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1541 | #endif |
whismanoid | 0:3edb3708c8c5 | 1542 | #if HAS_pwmDriver14 |
whismanoid | 0:3edb3708c8c5 | 1543 | PwmOut pwmDriver14(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1544 | #endif |
whismanoid | 0:3edb3708c8c5 | 1545 | #if HAS_pwmDriver15 |
whismanoid | 0:3edb3708c8c5 | 1546 | PwmOut pwmDriver15(____); // not assigned |
whismanoid | 0:3edb3708c8c5 | 1547 | #endif |
whismanoid | 0:3edb3708c8c5 | 1548 | #else |
whismanoid | 0:3edb3708c8c5 | 1549 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 1550 | #endif |
whismanoid | 0:3edb3708c8c5 | 1551 | // uncrustify-0.66.1 *INDENT-ON* |
whismanoid | 0:3edb3708c8c5 | 1552 | #if HAS_pwmDriver0 || HAS_pwmDriver1 \ |
whismanoid | 0:3edb3708c8c5 | 1553 | || HAS_pwmDriver2 || HAS_pwmDriver3 \ |
whismanoid | 0:3edb3708c8c5 | 1554 | || HAS_pwmDriver4 || HAS_pwmDriver5 \ |
whismanoid | 0:3edb3708c8c5 | 1555 | || HAS_pwmDriver6 || HAS_pwmDriver7 \ |
whismanoid | 0:3edb3708c8c5 | 1556 | || HAS_pwmDriver8 || HAS_pwmDriver9 \ |
whismanoid | 0:3edb3708c8c5 | 1557 | || HAS_pwmDriver10 || HAS_pwmDriver11 \ |
whismanoid | 0:3edb3708c8c5 | 1558 | || HAS_pwmDriver12 || HAS_pwmDriver13 \ |
whismanoid | 0:3edb3708c8c5 | 1559 | || HAS_pwmDriver14 || HAS_pwmDriver15 |
whismanoid | 0:3edb3708c8c5 | 1560 | #define HAS_pwmDrivers 1 |
whismanoid | 0:3edb3708c8c5 | 1561 | #endif |
whismanoid | 0:3edb3708c8c5 | 1562 | |
whismanoid | 0:3edb3708c8c5 | 1563 | // uncrustify-0.66.1 *INDENT-OFF* |
whismanoid | 0:3edb3708c8c5 | 1564 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1565 | // Declare the AnalogIn driver |
whismanoid | 0:3edb3708c8c5 | 1566 | // Optional analogIn support. If there is only one it should be analogIn1. |
whismanoid | 0:3edb3708c8c5 | 1567 | // A) analog input |
whismanoid | 0:3edb3708c8c5 | 1568 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 1569 | #define HAS_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 1570 | #define HAS_analogIn1 1 |
whismanoid | 0:3edb3708c8c5 | 1571 | #define HAS_analogIn2 1 |
whismanoid | 0:3edb3708c8c5 | 1572 | #define HAS_analogIn3 1 |
whismanoid | 0:3edb3708c8c5 | 1573 | #define HAS_analogIn4 1 |
whismanoid | 0:3edb3708c8c5 | 1574 | #define HAS_analogIn5 1 |
whismanoid | 0:3edb3708c8c5 | 1575 | #define HAS_analogIn6 1 |
whismanoid | 0:3edb3708c8c5 | 1576 | #define HAS_analogIn7 1 |
whismanoid | 0:3edb3708c8c5 | 1577 | #define HAS_analogIn8 1 |
whismanoid | 0:3edb3708c8c5 | 1578 | #define HAS_analogIn9 1 |
whismanoid | 0:3edb3708c8c5 | 1579 | // #define HAS_analogIn10 0 |
whismanoid | 0:3edb3708c8c5 | 1580 | // #define HAS_analogIn11 0 |
whismanoid | 0:3edb3708c8c5 | 1581 | // #define HAS_analogIn12 0 |
whismanoid | 0:3edb3708c8c5 | 1582 | // #define HAS_analogIn13 0 |
whismanoid | 0:3edb3708c8c5 | 1583 | // #define HAS_analogIn14 0 |
whismanoid | 0:3edb3708c8c5 | 1584 | // #define HAS_analogIn15 0 |
whismanoid | 0:3edb3708c8c5 | 1585 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 1586 | AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1587 | #endif |
whismanoid | 0:3edb3708c8c5 | 1588 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 1589 | AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1590 | #endif |
whismanoid | 0:3edb3708c8c5 | 1591 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 1592 | AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1593 | #endif |
whismanoid | 0:3edb3708c8c5 | 1594 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 1595 | AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1596 | #endif |
whismanoid | 0:3edb3708c8c5 | 1597 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 1598 | AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 1599 | #endif |
whismanoid | 0:3edb3708c8c5 | 1600 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1601 | AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 1602 | #endif |
whismanoid | 0:3edb3708c8c5 | 1603 | #if HAS_analogIn6 |
whismanoid | 0:3edb3708c8c5 | 1604 | AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 1605 | #endif |
whismanoid | 0:3edb3708c8c5 | 1606 | #if HAS_analogIn7 |
whismanoid | 0:3edb3708c8c5 | 1607 | AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1608 | #endif |
whismanoid | 0:3edb3708c8c5 | 1609 | #if HAS_analogIn8 |
whismanoid | 0:3edb3708c8c5 | 1610 | AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1611 | #endif |
whismanoid | 0:3edb3708c8c5 | 1612 | #if HAS_analogIn9 |
whismanoid | 0:3edb3708c8c5 | 1613 | AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V |
whismanoid | 0:3edb3708c8c5 | 1614 | #endif |
whismanoid | 0:3edb3708c8c5 | 1615 | #if HAS_analogIn10 |
whismanoid | 0:3edb3708c8c5 | 1616 | AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined? |
whismanoid | 0:3edb3708c8c5 | 1617 | #endif |
whismanoid | 0:3edb3708c8c5 | 1618 | #if HAS_analogIn11 |
whismanoid | 0:3edb3708c8c5 | 1619 | AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 1620 | #endif |
whismanoid | 0:3edb3708c8c5 | 1621 | #if HAS_analogIn12 |
whismanoid | 0:3edb3708c8c5 | 1622 | AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 1623 | #endif |
whismanoid | 0:3edb3708c8c5 | 1624 | #if HAS_analogIn13 |
whismanoid | 0:3edb3708c8c5 | 1625 | AnalogIn analogIn13(____); |
whismanoid | 0:3edb3708c8c5 | 1626 | #endif |
whismanoid | 0:3edb3708c8c5 | 1627 | #if HAS_analogIn14 |
whismanoid | 0:3edb3708c8c5 | 1628 | AnalogIn analogIn14(____); |
whismanoid | 0:3edb3708c8c5 | 1629 | #endif |
whismanoid | 0:3edb3708c8c5 | 1630 | #if HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 1631 | AnalogIn analogIn15(____); |
whismanoid | 0:3edb3708c8c5 | 1632 | #endif |
whismanoid | 0:3edb3708c8c5 | 1633 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1634 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 1635 | #define HAS_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 1636 | #define HAS_analogIn1 1 |
whismanoid | 0:3edb3708c8c5 | 1637 | #define HAS_analogIn2 1 |
whismanoid | 0:3edb3708c8c5 | 1638 | #define HAS_analogIn3 1 |
whismanoid | 0:3edb3708c8c5 | 1639 | #define HAS_analogIn4 1 |
whismanoid | 0:3edb3708c8c5 | 1640 | #define HAS_analogIn5 1 |
whismanoid | 0:3edb3708c8c5 | 1641 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 1642 | AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1643 | #endif |
whismanoid | 0:3edb3708c8c5 | 1644 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 1645 | AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1646 | #endif |
whismanoid | 0:3edb3708c8c5 | 1647 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 1648 | AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1649 | #endif |
whismanoid | 0:3edb3708c8c5 | 1650 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 1651 | AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 1652 | #endif |
whismanoid | 0:3edb3708c8c5 | 1653 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 1654 | AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 1655 | #endif |
whismanoid | 0:3edb3708c8c5 | 1656 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1657 | AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 1658 | #endif |
whismanoid | 0:3edb3708c8c5 | 1659 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1660 | #elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 1661 | #define HAS_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 1662 | #define HAS_analogIn1 1 |
whismanoid | 0:3edb3708c8c5 | 1663 | #define HAS_analogIn2 1 |
whismanoid | 0:3edb3708c8c5 | 1664 | #define HAS_analogIn3 1 |
whismanoid | 0:3edb3708c8c5 | 1665 | #define HAS_analogIn4 1 |
whismanoid | 0:3edb3708c8c5 | 1666 | #define HAS_analogIn5 1 |
whismanoid | 0:3edb3708c8c5 | 1667 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 1668 | AnalogIn analogIn0(A0); |
whismanoid | 0:3edb3708c8c5 | 1669 | #endif |
whismanoid | 0:3edb3708c8c5 | 1670 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 1671 | AnalogIn analogIn1(A1); |
whismanoid | 0:3edb3708c8c5 | 1672 | #endif |
whismanoid | 0:3edb3708c8c5 | 1673 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 1674 | AnalogIn analogIn2(A2); |
whismanoid | 0:3edb3708c8c5 | 1675 | #endif |
whismanoid | 0:3edb3708c8c5 | 1676 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 1677 | AnalogIn analogIn3(A3); |
whismanoid | 0:3edb3708c8c5 | 1678 | #endif |
whismanoid | 0:3edb3708c8c5 | 1679 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 1680 | AnalogIn analogIn4(A4); |
whismanoid | 0:3edb3708c8c5 | 1681 | #endif |
whismanoid | 0:3edb3708c8c5 | 1682 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1683 | AnalogIn analogIn5(A5); |
whismanoid | 0:3edb3708c8c5 | 1684 | #endif |
whismanoid | 0:3edb3708c8c5 | 1685 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1686 | #elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 1687 | #define HAS_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 1688 | #define HAS_analogIn1 1 |
whismanoid | 0:3edb3708c8c5 | 1689 | #define HAS_analogIn2 1 |
whismanoid | 0:3edb3708c8c5 | 1690 | #define HAS_analogIn3 1 |
whismanoid | 0:3edb3708c8c5 | 1691 | #define HAS_analogIn4 1 |
whismanoid | 0:3edb3708c8c5 | 1692 | #define HAS_analogIn5 1 |
whismanoid | 0:3edb3708c8c5 | 1693 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 1694 | AnalogIn analogIn0(A0); |
whismanoid | 0:3edb3708c8c5 | 1695 | #endif |
whismanoid | 0:3edb3708c8c5 | 1696 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 1697 | AnalogIn analogIn1(A1); |
whismanoid | 0:3edb3708c8c5 | 1698 | #endif |
whismanoid | 0:3edb3708c8c5 | 1699 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 1700 | AnalogIn analogIn2(A2); |
whismanoid | 0:3edb3708c8c5 | 1701 | #endif |
whismanoid | 0:3edb3708c8c5 | 1702 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 1703 | AnalogIn analogIn3(A3); |
whismanoid | 0:3edb3708c8c5 | 1704 | #endif |
whismanoid | 0:3edb3708c8c5 | 1705 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 1706 | AnalogIn analogIn4(A4); |
whismanoid | 0:3edb3708c8c5 | 1707 | #endif |
whismanoid | 0:3edb3708c8c5 | 1708 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1709 | AnalogIn analogIn5(A5); |
whismanoid | 0:3edb3708c8c5 | 1710 | #endif |
whismanoid | 0:3edb3708c8c5 | 1711 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1712 | // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 1713 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 1714 | #define HAS_analogIn0 1 |
whismanoid | 0:3edb3708c8c5 | 1715 | #define HAS_analogIn1 1 |
whismanoid | 0:3edb3708c8c5 | 1716 | #define HAS_analogIn2 1 |
whismanoid | 0:3edb3708c8c5 | 1717 | #define HAS_analogIn3 1 |
whismanoid | 0:3edb3708c8c5 | 1718 | #define HAS_analogIn4 1 |
whismanoid | 0:3edb3708c8c5 | 1719 | #define HAS_analogIn5 1 |
whismanoid | 0:3edb3708c8c5 | 1720 | // #define HAS_analogIn6 1 |
whismanoid | 0:3edb3708c8c5 | 1721 | // #define HAS_analogIn7 1 |
whismanoid | 0:3edb3708c8c5 | 1722 | // #define HAS_analogIn8 1 |
whismanoid | 0:3edb3708c8c5 | 1723 | // #define HAS_analogIn9 1 |
whismanoid | 0:3edb3708c8c5 | 1724 | // #define HAS_analogIn10 1 |
whismanoid | 0:3edb3708c8c5 | 1725 | // #define HAS_analogIn11 1 |
whismanoid | 0:3edb3708c8c5 | 1726 | // #define HAS_analogIn12 1 |
whismanoid | 0:3edb3708c8c5 | 1727 | // #define HAS_analogIn13 1 |
whismanoid | 0:3edb3708c8c5 | 1728 | // #define HAS_analogIn14 1 |
whismanoid | 0:3edb3708c8c5 | 1729 | // #define HAS_analogIn15 1 |
whismanoid | 0:3edb3708c8c5 | 1730 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 1731 | AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0 |
whismanoid | 0:3edb3708c8c5 | 1732 | #endif |
whismanoid | 0:3edb3708c8c5 | 1733 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 1734 | AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1 |
whismanoid | 0:3edb3708c8c5 | 1735 | #endif |
whismanoid | 0:3edb3708c8c5 | 1736 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 1737 | AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3 |
whismanoid | 0:3edb3708c8c5 | 1738 | #endif |
whismanoid | 0:3edb3708c8c5 | 1739 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 1740 | AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3 |
whismanoid | 0:3edb3708c8c5 | 1741 | #endif |
whismanoid | 0:3edb3708c8c5 | 1742 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 1743 | AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4 |
whismanoid | 0:3edb3708c8c5 | 1744 | #endif |
whismanoid | 0:3edb3708c8c5 | 1745 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 1746 | AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5 |
whismanoid | 0:3edb3708c8c5 | 1747 | #endif |
whismanoid | 0:3edb3708c8c5 | 1748 | #if HAS_analogIn6 |
whismanoid | 0:3edb3708c8c5 | 1749 | AnalogIn analogIn6(____); |
whismanoid | 0:3edb3708c8c5 | 1750 | #endif |
whismanoid | 0:3edb3708c8c5 | 1751 | #if HAS_analogIn7 |
whismanoid | 0:3edb3708c8c5 | 1752 | AnalogIn analogIn7(____); |
whismanoid | 0:3edb3708c8c5 | 1753 | #endif |
whismanoid | 0:3edb3708c8c5 | 1754 | #if HAS_analogIn8 |
whismanoid | 0:3edb3708c8c5 | 1755 | AnalogIn analogIn8(____); |
whismanoid | 0:3edb3708c8c5 | 1756 | #endif |
whismanoid | 0:3edb3708c8c5 | 1757 | #if HAS_analogIn9 |
whismanoid | 0:3edb3708c8c5 | 1758 | AnalogIn analogIn9(____); |
whismanoid | 0:3edb3708c8c5 | 1759 | #endif |
whismanoid | 0:3edb3708c8c5 | 1760 | #if HAS_analogIn10 |
whismanoid | 0:3edb3708c8c5 | 1761 | AnalogIn analogIn10(____); |
whismanoid | 0:3edb3708c8c5 | 1762 | #endif |
whismanoid | 0:3edb3708c8c5 | 1763 | #if HAS_analogIn11 |
whismanoid | 0:3edb3708c8c5 | 1764 | AnalogIn analogIn11(____); |
whismanoid | 0:3edb3708c8c5 | 1765 | #endif |
whismanoid | 0:3edb3708c8c5 | 1766 | #if HAS_analogIn12 |
whismanoid | 0:3edb3708c8c5 | 1767 | AnalogIn analogIn12(____); |
whismanoid | 0:3edb3708c8c5 | 1768 | #endif |
whismanoid | 0:3edb3708c8c5 | 1769 | #if HAS_analogIn13 |
whismanoid | 0:3edb3708c8c5 | 1770 | AnalogIn analogIn13(____); |
whismanoid | 0:3edb3708c8c5 | 1771 | #endif |
whismanoid | 0:3edb3708c8c5 | 1772 | #if HAS_analogIn14 |
whismanoid | 0:3edb3708c8c5 | 1773 | AnalogIn analogIn14(____); |
whismanoid | 0:3edb3708c8c5 | 1774 | #endif |
whismanoid | 0:3edb3708c8c5 | 1775 | #if HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 1776 | AnalogIn analogIn15(____); |
whismanoid | 0:3edb3708c8c5 | 1777 | #endif |
whismanoid | 0:3edb3708c8c5 | 1778 | #else |
whismanoid | 0:3edb3708c8c5 | 1779 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 1780 | #endif |
whismanoid | 0:3edb3708c8c5 | 1781 | // uncrustify-0.66.1 *INDENT-ON* |
whismanoid | 0:3edb3708c8c5 | 1782 | #if HAS_analogIn0 || HAS_analogIn1 \ |
whismanoid | 0:3edb3708c8c5 | 1783 | || HAS_analogIn2 || HAS_analogIn3 \ |
whismanoid | 0:3edb3708c8c5 | 1784 | || HAS_analogIn4 || HAS_analogIn5 \ |
whismanoid | 0:3edb3708c8c5 | 1785 | || HAS_analogIn6 || HAS_analogIn7 \ |
whismanoid | 0:3edb3708c8c5 | 1786 | || HAS_analogIn8 || HAS_analogIn9 \ |
whismanoid | 0:3edb3708c8c5 | 1787 | || HAS_analogIn10 || HAS_analogIn11 \ |
whismanoid | 0:3edb3708c8c5 | 1788 | || HAS_analogIn12 || HAS_analogIn13 \ |
whismanoid | 0:3edb3708c8c5 | 1789 | || HAS_analogIn14 || HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 1790 | #define HAS_analogIns 1 |
whismanoid | 0:3edb3708c8c5 | 1791 | #endif |
whismanoid | 0:3edb3708c8c5 | 1792 | |
whismanoid | 0:3edb3708c8c5 | 1793 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1794 | // Diagnostic: scope trigger |
whismanoid | 0:3edb3708c8c5 | 1795 | //#define SCOPE_TRIG_PIN p11 |
whismanoid | 0:3edb3708c8c5 | 1796 | //#ifdef SCOPE_TRIG_PIN |
whismanoid | 0:3edb3708c8c5 | 1797 | //# if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 1798 | // // TARGET=MAX32630 |
whismanoid | 0:3edb3708c8c5 | 1799 | // DigitalOut scopeTrigPinP11(P3_1, 1); |
whismanoid | 0:3edb3708c8c5 | 1800 | // DigitalOut scopePinP12(P3_0, 1); |
whismanoid | 0:3edb3708c8c5 | 1801 | //# elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 1802 | // // TARGET=LPC1768 |
whismanoid | 0:3edb3708c8c5 | 1803 | // DigitalOut scopeTrigPinP11(p11, 1); |
whismanoid | 0:3edb3708c8c5 | 1804 | // DigitalOut scopePinP12(p12, 1); |
whismanoid | 0:3edb3708c8c5 | 1805 | //# else |
whismanoid | 0:3edb3708c8c5 | 1806 | // // unknown target |
whismanoid | 0:3edb3708c8c5 | 1807 | //# endif |
whismanoid | 0:3edb3708c8c5 | 1808 | //#endif |
whismanoid | 0:3edb3708c8c5 | 1809 | |
whismanoid | 0:3edb3708c8c5 | 1810 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1811 | // Option to use LEDs to show status |
whismanoid | 0:3edb3708c8c5 | 1812 | #ifndef USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 1813 | #define USE_LEDS 1 |
whismanoid | 0:3edb3708c8c5 | 1814 | #endif |
whismanoid | 0:3edb3708c8c5 | 1815 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 1816 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 1817 | # define LED_ON 0 |
whismanoid | 0:3edb3708c8c5 | 1818 | # define LED_OFF 1 |
whismanoid | 0:3edb3708c8c5 | 1819 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1820 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 1821 | # define LED_ON 0 |
whismanoid | 0:3edb3708c8c5 | 1822 | # define LED_OFF 1 |
whismanoid | 0:3edb3708c8c5 | 1823 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1824 | // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM |
whismanoid | 0:3edb3708c8c5 | 1825 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 1826 | # define LED_ON 1 |
whismanoid | 0:3edb3708c8c5 | 1827 | # define LED_OFF 0 |
whismanoid | 0:3edb3708c8c5 | 1828 | #else // not defined(TARGET_LPC1768 etc.) |
whismanoid | 0:3edb3708c8c5 | 1829 | # define LED_ON 1 |
whismanoid | 0:3edb3708c8c5 | 1830 | # define LED_OFF 0 |
whismanoid | 0:3edb3708c8c5 | 1831 | #endif // target definition |
whismanoid | 0:3edb3708c8c5 | 1832 | DigitalOut led1(LED1, LED_OFF); // MAX32630FTHR: LED1 = LED_RED |
whismanoid | 0:3edb3708c8c5 | 1833 | DigitalOut led2(LED2, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN |
whismanoid | 0:3edb3708c8c5 | 1834 | DigitalOut led3(LED3, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE |
whismanoid | 0:3edb3708c8c5 | 1835 | DigitalOut led4(LED4, LED_OFF); |
whismanoid | 0:3edb3708c8c5 | 1836 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 1837 | |
whismanoid | 0:3edb3708c8c5 | 1838 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1839 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 1840 | class RGB_LED { |
whismanoid | 0:3edb3708c8c5 | 1841 | public: |
whismanoid | 0:3edb3708c8c5 | 1842 | RGB_LED(DigitalOut &led_red, DigitalOut &led_green, DigitalOut &led_blue) |
whismanoid | 0:3edb3708c8c5 | 1843 | : m_red(led_red), m_green(led_green), m_blue(led_blue) |
whismanoid | 0:3edb3708c8c5 | 1844 | { |
whismanoid | 0:3edb3708c8c5 | 1845 | }; |
whismanoid | 0:3edb3708c8c5 | 1846 | DigitalOut &m_red; |
whismanoid | 0:3edb3708c8c5 | 1847 | DigitalOut &m_green; |
whismanoid | 0:3edb3708c8c5 | 1848 | DigitalOut &m_blue; |
whismanoid | 0:3edb3708c8c5 | 1849 | ~RGB_LED() |
whismanoid | 0:3edb3708c8c5 | 1850 | { |
whismanoid | 0:3edb3708c8c5 | 1851 | }; |
whismanoid | 0:3edb3708c8c5 | 1852 | /* diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 1853 | */ |
whismanoid | 0:3edb3708c8c5 | 1854 | void red() { |
whismanoid | 0:3edb3708c8c5 | 1855 | m_red = LED_ON; m_green = LED_OFF; m_blue = LED_OFF; // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 1856 | }; |
whismanoid | 0:3edb3708c8c5 | 1857 | /* diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 1858 | */ |
whismanoid | 0:3edb3708c8c5 | 1859 | void green() { |
whismanoid | 0:3edb3708c8c5 | 1860 | m_red = LED_OFF; m_green = LED_ON; m_blue = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 1861 | }; |
whismanoid | 0:3edb3708c8c5 | 1862 | /* diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 1863 | */ |
whismanoid | 0:3edb3708c8c5 | 1864 | void blue() { |
whismanoid | 0:3edb3708c8c5 | 1865 | m_red = LED_OFF; m_green = LED_OFF; m_blue = LED_ON; // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 1866 | }; |
whismanoid | 0:3edb3708c8c5 | 1867 | /* diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 1868 | */ |
whismanoid | 0:3edb3708c8c5 | 1869 | void white() { |
whismanoid | 0:3edb3708c8c5 | 1870 | m_red = LED_ON; m_green = LED_ON; m_blue = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 1871 | }; |
whismanoid | 0:3edb3708c8c5 | 1872 | /* diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 1873 | */ |
whismanoid | 0:3edb3708c8c5 | 1874 | void cyan() { |
whismanoid | 0:3edb3708c8c5 | 1875 | m_red = LED_OFF; m_green = LED_ON; m_blue = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 1876 | }; |
whismanoid | 0:3edb3708c8c5 | 1877 | /* diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 1878 | */ |
whismanoid | 0:3edb3708c8c5 | 1879 | void magenta() { |
whismanoid | 0:3edb3708c8c5 | 1880 | m_red = LED_ON; m_green = LED_OFF; m_blue = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 1881 | }; |
whismanoid | 0:3edb3708c8c5 | 1882 | /* diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 1883 | */ |
whismanoid | 0:3edb3708c8c5 | 1884 | void yellow() { |
whismanoid | 0:3edb3708c8c5 | 1885 | m_red = LED_ON; m_green = LED_ON; m_blue = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 1886 | }; |
whismanoid | 0:3edb3708c8c5 | 1887 | /* diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 1888 | */ |
whismanoid | 0:3edb3708c8c5 | 1889 | void black() { |
whismanoid | 0:3edb3708c8c5 | 1890 | m_red = LED_OFF; m_green = LED_OFF; m_blue = LED_OFF; // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 1891 | }; |
whismanoid | 0:3edb3708c8c5 | 1892 | }; |
whismanoid | 0:3edb3708c8c5 | 1893 | RGB_LED rgb_led(led1, led2, led3); // red, green, blue LEDs |
whismanoid | 0:3edb3708c8c5 | 1894 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 1895 | |
whismanoid | 0:3edb3708c8c5 | 1896 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1897 | // use BUTTON1 trigger some action |
whismanoid | 0:3edb3708c8c5 | 1898 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 1899 | #define HAS_BUTTON1_DEMO_INTERRUPT 1 |
whismanoid | 0:3edb3708c8c5 | 1900 | #elif defined(TARGET_MAX32625) |
whismanoid | 0:3edb3708c8c5 | 1901 | #define HAS_BUTTON1_DEMO_INTERRUPT 1 |
whismanoid | 0:3edb3708c8c5 | 1902 | #define HAS_BUTTON2_DEMO_INTERRUPT 1 |
whismanoid | 0:3edb3708c8c5 | 1903 | #elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 1904 | #define HAS_BUTTON1_DEMO_INTERRUPT 0 |
whismanoid | 0:3edb3708c8c5 | 1905 | #define HAS_BUTTON2_DEMO_INTERRUPT 0 |
whismanoid | 0:3edb3708c8c5 | 1906 | #elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 1907 | #define HAS_BUTTON1_DEMO_INTERRUPT 0 |
whismanoid | 0:3edb3708c8c5 | 1908 | #define HAS_BUTTON2_DEMO_INTERRUPT 0 |
whismanoid | 0:3edb3708c8c5 | 1909 | #endif |
whismanoid | 0:3edb3708c8c5 | 1910 | // |
whismanoid | 0:3edb3708c8c5 | 1911 | #ifndef HAS_BUTTON1_DEMO |
whismanoid | 0:3edb3708c8c5 | 1912 | #define HAS_BUTTON1_DEMO 0 |
whismanoid | 0:3edb3708c8c5 | 1913 | #endif |
whismanoid | 0:3edb3708c8c5 | 1914 | #ifndef HAS_BUTTON2_DEMO |
whismanoid | 0:3edb3708c8c5 | 1915 | #define HAS_BUTTON2_DEMO 0 |
whismanoid | 0:3edb3708c8c5 | 1916 | #endif |
whismanoid | 0:3edb3708c8c5 | 1917 | // |
whismanoid | 0:3edb3708c8c5 | 1918 | // avoid runtime error on button1 press [mbed-os-5.11] |
whismanoid | 0:3edb3708c8c5 | 1919 | // instead of using InterruptIn, use DigitalIn and poll in main while(1) |
whismanoid | 0:3edb3708c8c5 | 1920 | #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 1921 | #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1 |
whismanoid | 0:3edb3708c8c5 | 1922 | #endif |
whismanoid | 0:3edb3708c8c5 | 1923 | // |
whismanoid | 0:3edb3708c8c5 | 1924 | #ifndef HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 1925 | #define HAS_BUTTON1_DEMO_INTERRUPT 1 |
whismanoid | 0:3edb3708c8c5 | 1926 | #endif |
whismanoid | 0:3edb3708c8c5 | 1927 | #ifndef HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 1928 | #define HAS_BUTTON2_DEMO_INTERRUPT 1 |
whismanoid | 0:3edb3708c8c5 | 1929 | #endif |
whismanoid | 0:3edb3708c8c5 | 1930 | // |
whismanoid | 0:3edb3708c8c5 | 1931 | #if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 1932 | # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 1933 | // avoid runtime error on button1 press [mbed-os-5.11] |
whismanoid | 0:3edb3708c8c5 | 1934 | // instead of using InterruptIn, use DigitalIn and poll in main while(1) |
whismanoid | 0:3edb3708c8c5 | 1935 | DigitalIn button1(BUTTON1); |
whismanoid | 0:3edb3708c8c5 | 1936 | # else |
whismanoid | 0:3edb3708c8c5 | 1937 | InterruptIn button1(BUTTON1); |
whismanoid | 0:3edb3708c8c5 | 1938 | # endif |
whismanoid | 0:3edb3708c8c5 | 1939 | #elif HAS_BUTTON1_DEMO |
whismanoid | 0:3edb3708c8c5 | 1940 | DigitalIn button1(BUTTON1); |
whismanoid | 0:3edb3708c8c5 | 1941 | #endif |
whismanoid | 0:3edb3708c8c5 | 1942 | #if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 1943 | # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 1944 | // avoid runtime error on button1 press [mbed-os-5.11] |
whismanoid | 0:3edb3708c8c5 | 1945 | // instead of using InterruptIn, use DigitalIn and poll in main while(1) |
whismanoid | 0:3edb3708c8c5 | 1946 | DigitalIn button2(BUTTON2); |
whismanoid | 0:3edb3708c8c5 | 1947 | # else |
whismanoid | 0:3edb3708c8c5 | 1948 | InterruptIn button2(BUTTON2); |
whismanoid | 0:3edb3708c8c5 | 1949 | # endif |
whismanoid | 0:3edb3708c8c5 | 1950 | #elif HAS_BUTTON2_DEMO |
whismanoid | 0:3edb3708c8c5 | 1951 | DigitalIn button2(BUTTON2); |
whismanoid | 0:3edb3708c8c5 | 1952 | #endif |
whismanoid | 0:3edb3708c8c5 | 1953 | |
whismanoid | 0:3edb3708c8c5 | 1954 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1955 | // Ticker is the periodic interrupt timer itself |
whismanoid | 0:3edb3708c8c5 | 1956 | #define USE_PERIODIC_TIMER 0 |
whismanoid | 0:3edb3708c8c5 | 1957 | #if USE_PERIODIC_TIMER |
whismanoid | 0:3edb3708c8c5 | 1958 | Ticker periodicInterruptTimer; |
whismanoid | 0:3edb3708c8c5 | 1959 | us_timestamp_t periodicInterruptTimer_interval_usec = 50; |
whismanoid | 0:3edb3708c8c5 | 1960 | us_timestamp_t periodicInterruptTimer_interval_usec_MAX = 1000; |
whismanoid | 0:3edb3708c8c5 | 1961 | us_timestamp_t periodicInterruptTimer_interval_usec_MIN = 20; |
whismanoid | 0:3edb3708c8c5 | 1962 | #endif |
whismanoid | 0:3edb3708c8c5 | 1963 | |
whismanoid | 0:3edb3708c8c5 | 1964 | |
whismanoid | 0:3edb3708c8c5 | 1965 | #if APPLICATION_MAX5715 // hardware interface functions |
whismanoid | 0:3edb3708c8c5 | 1966 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1967 | // User-provided hardware function |
whismanoid | 0:3edb3708c8c5 | 1968 | // declare user-provided hardware interface function drive MAX5717_LDACb_Pin LDAC# |
whismanoid | 0:3edb3708c8c5 | 1969 | // drive LDAC# Active-Low Asynchronous Load DAC Input for MAX5715 |
whismanoid | 0:3edb3708c8c5 | 1970 | // |
whismanoid | 0:3edb3708c8c5 | 1971 | //void GPIOoutputLDACb(int isLogicHigh) |
whismanoid | 0:3edb3708c8c5 | 1972 | //{ |
whismanoid | 0:3edb3708c8c5 | 1973 | // digitalInOut9.output(); |
whismanoid | 0:3edb3708c8c5 | 1974 | // digitalInOut9.write(isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 1975 | // |
whismanoid | 0:3edb3708c8c5 | 1976 | //#if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 1977 | // cmdLine_microUSBserial.serial().printf(" digitalInOutPin 9 Output %d ", isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 1978 | //#endif |
whismanoid | 0:3edb3708c8c5 | 1979 | //#if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 1980 | // cmdLine_DAPLINKserial.serial().printf(" digitalInOutPin 9 Output %d ", isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 1981 | //#endif |
whismanoid | 0:3edb3708c8c5 | 1982 | //} |
whismanoid | 0:3edb3708c8c5 | 1983 | |
whismanoid | 0:3edb3708c8c5 | 1984 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 1985 | // User-provided hardware function |
whismanoid | 0:3edb3708c8c5 | 1986 | // declare user-provided hardware interface function drive MAX5717_CLRb_Pin CLR# |
whismanoid | 0:3edb3708c8c5 | 1987 | // drive CLR# Active-Low Clear Input for MAX5715 |
whismanoid | 0:3edb3708c8c5 | 1988 | // |
whismanoid | 0:3edb3708c8c5 | 1989 | //void GPIOoutputCLRb(int isLogicHigh) |
whismanoid | 0:3edb3708c8c5 | 1990 | //{ |
whismanoid | 0:3edb3708c8c5 | 1991 | // digitalInOut8.output(); |
whismanoid | 0:3edb3708c8c5 | 1992 | // digitalInOut8.write(isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 1993 | // |
whismanoid | 0:3edb3708c8c5 | 1994 | //#if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 1995 | // cmdLine_microUSBserial.serial().printf(" digitalInOutPin 8 Output %d ", isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 1996 | //#endif |
whismanoid | 0:3edb3708c8c5 | 1997 | //#if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 1998 | // cmdLine_DAPLINKserial.serial().printf(" digitalInOutPin 8 Output %d ", isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 1999 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2000 | //} |
whismanoid | 0:3edb3708c8c5 | 2001 | #endif |
whismanoid | 0:3edb3708c8c5 | 2002 | |
whismanoid | 0:3edb3708c8c5 | 2003 | |
whismanoid | 0:3edb3708c8c5 | 2004 | #if APPLICATION_MAX11131 // hardware interface functions |
whismanoid | 0:3edb3708c8c5 | 2005 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2006 | void print_value(CmdLine& cmdLine, int16_t value_u12, int channelId) |
whismanoid | 0:3edb3708c8c5 | 2007 | { |
whismanoid | 0:3edb3708c8c5 | 2008 | int channelPairIndex = channelId / 2; |
whismanoid | 0:3edb3708c8c5 | 2009 | // 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 | 2010 | // unused variable: int UCHn = (g_MAX11131_device.UNIPOLAR >> (10 - channelPairIndex)) & 0x01; |
whismanoid | 0:3edb3708c8c5 | 2011 | int BCHn = (g_MAX11131_device.BIPOLAR >> (10 - channelPairIndex)) & 0x01; |
whismanoid | 0:3edb3708c8c5 | 2012 | // unused variable: int RANGEn = (g_MAX11131_device.RANGE >> (10 - channelPairIndex)) & 0x01; |
whismanoid | 0:3edb3708c8c5 | 2013 | // |
whismanoid | 0:3edb3708c8c5 | 2014 | cmdLine.serial().printf(" ch="); |
whismanoid | 0:3edb3708c8c5 | 2015 | // TODO1: if CHANID=0 don't print ch=channelId |
whismanoid | 0:3edb3708c8c5 | 2016 | if ((g_MAX11131_device.isExternalClock == 0) || (g_MAX11131_device.chan_id_0_1 == 1)) |
whismanoid | 0:3edb3708c8c5 | 2017 | { |
whismanoid | 0:3edb3708c8c5 | 2018 | // Internal clock modes always use channel ID. |
whismanoid | 0:3edb3708c8c5 | 2019 | // External clock modes use channel ID if ADC_MODE_CONTROL.CHAN_ID is 1. |
whismanoid | 0:3edb3708c8c5 | 2020 | cmdLine.serial().printf("%d", channelId); |
whismanoid | 0:3edb3708c8c5 | 2021 | } else { |
whismanoid | 0:3edb3708c8c5 | 2022 | cmdLine.serial().printf("?"); |
whismanoid | 0:3edb3708c8c5 | 2023 | } |
whismanoid | 0:3edb3708c8c5 | 2024 | if (BCHn) |
whismanoid | 0:3edb3708c8c5 | 2025 | { |
whismanoid | 0:3edb3708c8c5 | 2026 | cmdLine.serial().printf(" xb=%d", g_MAX11131_device.TwosComplementValue(value_u12)); |
whismanoid | 0:3edb3708c8c5 | 2027 | } |
whismanoid | 0:3edb3708c8c5 | 2028 | else |
whismanoid | 0:3edb3708c8c5 | 2029 | { |
whismanoid | 0:3edb3708c8c5 | 2030 | cmdLine.serial().printf(" xu=%d", value_u12); |
whismanoid | 0:3edb3708c8c5 | 2031 | } |
whismanoid | 0:3edb3708c8c5 | 2032 | cmdLine.serial().printf(" = 0x%4.4x = %6.4fV", |
whismanoid | 0:3edb3708c8c5 | 2033 | (value_u12 & 0xFFFF), |
whismanoid | 0:3edb3708c8c5 | 2034 | g_MAX11131_device.VoltageOfCode(value_u12, channelId) |
whismanoid | 0:3edb3708c8c5 | 2035 | ); |
whismanoid | 0:3edb3708c8c5 | 2036 | // dtostrf width and precision: 2.5v / 4096 LSB = 0.0006103515625 volts per LSB |
whismanoid | 0:3edb3708c8c5 | 2037 | } |
whismanoid | 0:3edb3708c8c5 | 2038 | |
whismanoid | 0:3edb3708c8c5 | 2039 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2040 | // read data words |
whismanoid | 0:3edb3708c8c5 | 2041 | // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 2042 | // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 2043 | // For internal clock modes, the data format always includes the channel address. |
whismanoid | 0:3edb3708c8c5 | 2044 | // misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 2045 | void AINcode_print_value_chanID(CmdLine& cmdLine, int nWords) |
whismanoid | 0:3edb3708c8c5 | 2046 | { |
whismanoid | 0:3edb3708c8c5 | 2047 | cmdLine.serial().printf("ScanRead_nWords_chanID nWords=%d\r\n", nWords); |
whismanoid | 0:3edb3708c8c5 | 2048 | for (int index = 0; index < nWords; index++) { |
whismanoid | 0:3edb3708c8c5 | 2049 | //~ int16_t misoData16 = MAX11131_ScanRead(); |
whismanoid | 0:3edb3708c8c5 | 2050 | // For internal clock modes, the data format always includes the channel address. |
whismanoid | 0:3edb3708c8c5 | 2051 | // misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 2052 | int16_t value_u12 = (g_MAX11131_device.RAW_misoData16[index] & 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2053 | int channelId = ((g_MAX11131_device.RAW_misoData16[index] >> 12) & 0x000F); |
whismanoid | 0:3edb3708c8c5 | 2054 | // diagnostic: print raw MISO data |
whismanoid | 0:3edb3708c8c5 | 2055 | cmdLine.serial().printf(" MAX11131.MISO[%u]=0x%4.4x:", index, |
whismanoid | 0:3edb3708c8c5 | 2056 | (g_MAX11131_device.RAW_misoData16[index] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 2057 | print_value(cmdLine, value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 2058 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2059 | } |
whismanoid | 0:3edb3708c8c5 | 2060 | } |
whismanoid | 0:3edb3708c8c5 | 2061 | |
whismanoid | 0:3edb3708c8c5 | 2062 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2063 | // read data words |
whismanoid | 0:3edb3708c8c5 | 2064 | // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 2065 | // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 2066 | // For external clock modes, the data format returned depends on the CHAN_ID bit. |
whismanoid | 0:3edb3708c8c5 | 2067 | // when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x |
whismanoid | 0:3edb3708c8c5 | 2068 | // when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 2069 | void AINcode_print_value_externalClock(CmdLine& cmdLine, int nWords) |
whismanoid | 0:3edb3708c8c5 | 2070 | { |
whismanoid | 0:3edb3708c8c5 | 2071 | // For external clock modes, the data format returned depends on the CHAN_ID bit. |
whismanoid | 0:3edb3708c8c5 | 2072 | // when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x |
whismanoid | 0:3edb3708c8c5 | 2073 | // when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 2074 | // For internal clock modes, the data format always includes the channel address. |
whismanoid | 0:3edb3708c8c5 | 2075 | // misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 2076 | if (g_MAX11131_device.chan_id_0_1 != 0) { |
whismanoid | 0:3edb3708c8c5 | 2077 | AINcode_print_value_chanID(cmdLine, nWords); |
whismanoid | 0:3edb3708c8c5 | 2078 | return; |
whismanoid | 0:3edb3708c8c5 | 2079 | } |
whismanoid | 0:3edb3708c8c5 | 2080 | cmdLine.serial().printf("ScanRead_nWords_externalClock nWords=%d\r\n", nWords); |
whismanoid | 0:3edb3708c8c5 | 2081 | for (int index = 0; index < nWords; index++) { |
whismanoid | 0:3edb3708c8c5 | 2082 | // int16_t misoData16 = MAX11131_ScanRead(); |
whismanoid | 0:3edb3708c8c5 | 2083 | int16_t value_u12 = ((g_MAX11131_device.RAW_misoData16[index] >> 3) & 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2084 | int channelId = g_MAX11131_device.channelNumber_0_15; |
whismanoid | 0:3edb3708c8c5 | 2085 | // diagnostic: print raw MISO data |
whismanoid | 0:3edb3708c8c5 | 2086 | cmdLine.serial().printf(" MAX11131.MISO[%u]=0x%4.4x:", index, |
whismanoid | 0:3edb3708c8c5 | 2087 | (g_MAX11131_device.RAW_misoData16[index] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 2088 | print_value(cmdLine, value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 2089 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2090 | } |
whismanoid | 0:3edb3708c8c5 | 2091 | } |
whismanoid | 0:3edb3708c8c5 | 2092 | |
whismanoid | 0:3edb3708c8c5 | 2093 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2094 | // read data words and calculate mean, stddev |
whismanoid | 0:3edb3708c8c5 | 2095 | // @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 2096 | // @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 2097 | void AINcode_print_value_chanID_mean(CmdLine& cmdLine, int nWords) |
whismanoid | 0:3edb3708c8c5 | 2098 | { |
whismanoid | 0:3edb3708c8c5 | 2099 | cmdLine.serial().printf("ScanRead_nWords_chanID_mean nWords=%d\r\n", nWords); |
whismanoid | 0:3edb3708c8c5 | 2100 | double Sx = 0; |
whismanoid | 0:3edb3708c8c5 | 2101 | double Sxx = 0; |
whismanoid | 0:3edb3708c8c5 | 2102 | for (int index = 0; index < nWords; index++) { |
whismanoid | 0:3edb3708c8c5 | 2103 | //~ int16_t misoData16 = MAX11131_ScanRead(); |
whismanoid | 0:3edb3708c8c5 | 2104 | // For internal clock modes, the data format always includes the channel address. |
whismanoid | 0:3edb3708c8c5 | 2105 | // misoData16 = CH[3:0] DATA[11:0] |
whismanoid | 0:3edb3708c8c5 | 2106 | int16_t value_u12 = (g_MAX11131_device.RAW_misoData16[index] & 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 2107 | int channelId = ((g_MAX11131_device.RAW_misoData16[index] >> 12) & 0x000F); |
whismanoid | 0:3edb3708c8c5 | 2108 | // TODO: sign-extend value_s12 from value_u12 |
whismanoid | 0:3edb3708c8c5 | 2109 | // |
whismanoid | 0:3edb3708c8c5 | 2110 | cmdLine.serial().printf("n=%d", index); |
whismanoid | 0:3edb3708c8c5 | 2111 | print_value(cmdLine, value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 2112 | // |
whismanoid | 0:3edb3708c8c5 | 2113 | Sx = Sx + value_u12; |
whismanoid | 0:3edb3708c8c5 | 2114 | Sxx = Sxx + ((double)value_u12 * value_u12); |
whismanoid | 0:3edb3708c8c5 | 2115 | cmdLine.serial().printf(" Sx=%f Sxx=%f\r\n", Sx, Sxx); |
whismanoid | 0:3edb3708c8c5 | 2116 | } |
whismanoid | 0:3edb3708c8c5 | 2117 | double mean = Sx / nWords; |
whismanoid | 0:3edb3708c8c5 | 2118 | cmdLine.serial().printf(" mean=%f=0x%4.4x", mean, (int)mean); |
whismanoid | 0:3edb3708c8c5 | 2119 | // calculate standard deviation from N, Sx, Sxx |
whismanoid | 0:3edb3708c8c5 | 2120 | if (nWords >= 2) |
whismanoid | 0:3edb3708c8c5 | 2121 | { |
whismanoid | 0:3edb3708c8c5 | 2122 | double variance = (Sxx - ( Sx * Sx / nWords)) / (nWords - 1); |
whismanoid | 0:3edb3708c8c5 | 2123 | // stddev = square root of variance |
whismanoid | 0:3edb3708c8c5 | 2124 | double stddev = sqrt(variance); |
whismanoid | 0:3edb3708c8c5 | 2125 | cmdLine.serial().printf(" variance=%f stddev=%f", variance, stddev); |
whismanoid | 0:3edb3708c8c5 | 2126 | } |
whismanoid | 0:3edb3708c8c5 | 2127 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2128 | } |
whismanoid | 0:3edb3708c8c5 | 2129 | |
whismanoid | 0:3edb3708c8c5 | 2130 | /* MAX11131_print_register_verbose |
whismanoid | 0:3edb3708c8c5 | 2131 | * |
whismanoid | 0:3edb3708c8c5 | 2132 | * TODO: document this function |
whismanoid | 0:3edb3708c8c5 | 2133 | * This header was inserted by uncrustify; see uncrustify_func_header.txt. |
whismanoid | 0:3edb3708c8c5 | 2134 | * |
whismanoid | 0:3edb3708c8c5 | 2135 | */ |
whismanoid | 0:3edb3708c8c5 | 2136 | void MAX11131_print_register_verbose(CmdLine& cmdLine, int16_t registerData) |
whismanoid | 0:3edb3708c8c5 | 2137 | { |
whismanoid | 0:3edb3708c8c5 | 2138 | if (registerData & 0x8000) |
whismanoid | 0:3edb3708c8c5 | 2139 | { |
whismanoid | 0:3edb3708c8c5 | 2140 | switch (registerData & 0xF800) |
whismanoid | 0:3edb3708c8c5 | 2141 | { |
whismanoid | 0:3edb3708c8c5 | 2142 | 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 | 2143 | cmdLine.serial().printf(" ADC_CONFIGURATION"); |
whismanoid | 0:3edb3708c8c5 | 2144 | { |
whismanoid | 0:3edb3708c8c5 | 2145 | // define write-only register ADC_CONFIGURATION |
whismanoid | 0:3edb3708c8c5 | 2146 | //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 | 2147 | const int REFSEL_LSB = 10; const int REFSEL_BITS = 0x01; // ADC_CONFIGURATION.REFSEL |
whismanoid | 0:3edb3708c8c5 | 2148 | const int AVGON_LSB = 9; const int AVGON_BITS = 0x01; // ADC_CONFIGURATION.AVGON |
whismanoid | 0:3edb3708c8c5 | 2149 | const int NAVG_LSB = 7; const int NAVG_BITS = 0x03; // ADC_CONFIGURATION.NAVG[1:0] |
whismanoid | 0:3edb3708c8c5 | 2150 | const int NSCAN_LSB = 5; const int NSCAN_BITS = 0x03; // ADC_CONFIGURATION.NSCAN[1:0] |
whismanoid | 0:3edb3708c8c5 | 2151 | const int SPM_LSB = 3; const int SPM_BITS = 0x03; // ADC_CONFIGURATION.SPM[1:0] |
whismanoid | 0:3edb3708c8c5 | 2152 | const int ECHO_LSB = 2; const int ECHO_BITS = 0x01; // ADC_CONFIGURATION.ECHO |
whismanoid | 0:3edb3708c8c5 | 2153 | |
whismanoid | 0:3edb3708c8c5 | 2154 | const int REFSEL = ((registerData >> REFSEL_LSB) & REFSEL_BITS); |
whismanoid | 0:3edb3708c8c5 | 2155 | const int AVGON = ((registerData >> AVGON_LSB) & AVGON_BITS); |
whismanoid | 0:3edb3708c8c5 | 2156 | const int NAVG = ((registerData >> NAVG_LSB) & NAVG_BITS); |
whismanoid | 0:3edb3708c8c5 | 2157 | const int NSCAN = ((registerData >> NSCAN_LSB) & NSCAN_BITS); |
whismanoid | 0:3edb3708c8c5 | 2158 | const int SPM = ((registerData >> SPM_LSB) & SPM_BITS); |
whismanoid | 0:3edb3708c8c5 | 2159 | const int ECHO = ((registerData >> ECHO_LSB) & ECHO_BITS); |
whismanoid | 0:3edb3708c8c5 | 2160 | |
whismanoid | 0:3edb3708c8c5 | 2161 | if (REFSEL) { |
whismanoid | 0:3edb3708c8c5 | 2162 | cmdLine.serial().printf(" REFSEL=%d", REFSEL); |
whismanoid | 0:3edb3708c8c5 | 2163 | } |
whismanoid | 0:3edb3708c8c5 | 2164 | if (AVGON) { |
whismanoid | 0:3edb3708c8c5 | 2165 | cmdLine.serial().printf(" AVGON=%d", AVGON); |
whismanoid | 0:3edb3708c8c5 | 2166 | } |
whismanoid | 0:3edb3708c8c5 | 2167 | if (NAVG) { |
whismanoid | 0:3edb3708c8c5 | 2168 | cmdLine.serial().printf(" NAVG=%d", NAVG); |
whismanoid | 0:3edb3708c8c5 | 2169 | } |
whismanoid | 0:3edb3708c8c5 | 2170 | if (NSCAN) { |
whismanoid | 0:3edb3708c8c5 | 2171 | cmdLine.serial().printf(" NSCAN=%d", NSCAN); |
whismanoid | 0:3edb3708c8c5 | 2172 | } |
whismanoid | 0:3edb3708c8c5 | 2173 | if (SPM) { |
whismanoid | 0:3edb3708c8c5 | 2174 | cmdLine.serial().printf(" SPM=%d", SPM); |
whismanoid | 0:3edb3708c8c5 | 2175 | } |
whismanoid | 0:3edb3708c8c5 | 2176 | if (ECHO) { |
whismanoid | 0:3edb3708c8c5 | 2177 | cmdLine.serial().printf(" ECHO=%d", ECHO); |
whismanoid | 0:3edb3708c8c5 | 2178 | } |
whismanoid | 0:3edb3708c8c5 | 2179 | } |
whismanoid | 0:3edb3708c8c5 | 2180 | break; |
whismanoid | 0:3edb3708c8c5 | 2181 | 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 | 2182 | cmdLine.serial().printf(" UNIPOLAR 0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 2183 | if ((registerData >> 2) & 0x01) { |
whismanoid | 0:3edb3708c8c5 | 2184 | cmdLine.serial().printf(" PDIFF_COM"); |
whismanoid | 0:3edb3708c8c5 | 2185 | } |
whismanoid | 0:3edb3708c8c5 | 2186 | break; |
whismanoid | 0:3edb3708c8c5 | 2187 | 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 | 2188 | cmdLine.serial().printf(" BIPOLAR 0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 2189 | break; |
whismanoid | 0:3edb3708c8c5 | 2190 | 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 | 2191 | cmdLine.serial().printf(" RANGE 0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 2192 | break; |
whismanoid | 0:3edb3708c8c5 | 2193 | 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 | 2194 | cmdLine.serial().printf(" CSCAN0 0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 2195 | break; |
whismanoid | 0:3edb3708c8c5 | 2196 | 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 | 2197 | cmdLine.serial().printf(" CSCAN1 0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 2198 | break; |
whismanoid | 0:3edb3708c8c5 | 2199 | case 0xB000: // SAMPLESET 0xB000..0xB7FF format: 1 0 1 1 0 SEQ_LENGTH[7:0] x x x |
whismanoid | 0:3edb3708c8c5 | 2200 | cmdLine.serial().printf(" SAMPLESET SEQ_LENGTH[7:0]=0x%4.4x", ((registerData >> 3) & 0xFF)); |
whismanoid | 0:3edb3708c8c5 | 2201 | cmdLine.serial().printf(" so length=%d channels", (((registerData >> 3) & 0xFF) + 1)); |
whismanoid | 0:3edb3708c8c5 | 2202 | break; |
whismanoid | 0:3edb3708c8c5 | 2203 | default: |
whismanoid | 0:3edb3708c8c5 | 2204 | cmdLine.serial().printf(" ???"); |
whismanoid | 0:3edb3708c8c5 | 2205 | break; |
whismanoid | 0:3edb3708c8c5 | 2206 | } |
whismanoid | 0:3edb3708c8c5 | 2207 | } |
whismanoid | 0:3edb3708c8c5 | 2208 | else |
whismanoid | 0:3edb3708c8c5 | 2209 | { |
whismanoid | 0:3edb3708c8c5 | 2210 | // 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 | 2211 | cmdLine.serial().printf(" ADC_MODE_CONTROL"); |
whismanoid | 0:3edb3708c8c5 | 2212 | |
whismanoid | 0:3edb3708c8c5 | 2213 | // define write-only register ADC_MODE_CONTROL |
whismanoid | 0:3edb3708c8c5 | 2214 | //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 | 2215 | const int SCAN_LSB = 11; const int SCAN_BITS = 0x0F; //!< ADC_MODE_CONTROL.SCAN[3:0] ADC Scan Control (command) |
whismanoid | 0:3edb3708c8c5 | 2216 | 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 | 2217 | 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 | 2218 | 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 | 2219 | const int CHAN_ID_LSB = 2; const int CHAN_ID_BITS = 0x01; //!< ADC_MODE_CONTROL.CHAN_ID |
whismanoid | 0:3edb3708c8c5 | 2220 | const int SWCNV_LSB = 1; const int SWCNV_BITS = 0x01; //!< ADC_MODE_CONTROL.SWCNV |
whismanoid | 0:3edb3708c8c5 | 2221 | |
whismanoid | 0:3edb3708c8c5 | 2222 | const int SCAN = ((registerData >> SCAN_LSB) & SCAN_BITS); |
whismanoid | 0:3edb3708c8c5 | 2223 | const int CHSEL = ((registerData >> CHSEL_LSB) & CHSEL_BITS); |
whismanoid | 0:3edb3708c8c5 | 2224 | const int RESET = ((registerData >> RESET_LSB) & RESET_BITS); |
whismanoid | 0:3edb3708c8c5 | 2225 | const int PM = ((registerData >> PM_LSB) & PM_BITS); |
whismanoid | 0:3edb3708c8c5 | 2226 | const int CHANID = ((registerData >> CHAN_ID_LSB) & CHAN_ID_BITS); |
whismanoid | 0:3edb3708c8c5 | 2227 | const int SWCNV = ((registerData >> SWCNV_LSB) & SWCNV_BITS); |
whismanoid | 0:3edb3708c8c5 | 2228 | |
whismanoid | 0:3edb3708c8c5 | 2229 | switch (SCAN) |
whismanoid | 0:3edb3708c8c5 | 2230 | { |
whismanoid | 0:3edb3708c8c5 | 2231 | case MAX11131::SCAN_0000_NOP: |
whismanoid | 0:3edb3708c8c5 | 2232 | cmdLine.serial().printf(" SCAN_0000_NOP"); |
whismanoid | 0:3edb3708c8c5 | 2233 | break; |
whismanoid | 0:3edb3708c8c5 | 2234 | case MAX11131::SCAN_0001_Manual: |
whismanoid | 0:3edb3708c8c5 | 2235 | cmdLine.serial().printf(" SCAN_0001_Manual CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 2236 | break; |
whismanoid | 0:3edb3708c8c5 | 2237 | case MAX11131::SCAN_0010_Repeat: |
whismanoid | 0:3edb3708c8c5 | 2238 | cmdLine.serial().printf(" SCAN_0010_Repeat CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 2239 | break; |
whismanoid | 0:3edb3708c8c5 | 2240 | case MAX11131::SCAN_0011_StandardInternalClock: |
whismanoid | 0:3edb3708c8c5 | 2241 | cmdLine.serial().printf(" SCAN_0011_StandardInt CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 2242 | break; |
whismanoid | 0:3edb3708c8c5 | 2243 | case MAX11131::SCAN_0100_StandardExternalClock: |
whismanoid | 0:3edb3708c8c5 | 2244 | cmdLine.serial().printf(" SCAN_0100_StandardExt CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 2245 | break; |
whismanoid | 0:3edb3708c8c5 | 2246 | case MAX11131::SCAN_0101_UpperInternalClock: |
whismanoid | 0:3edb3708c8c5 | 2247 | cmdLine.serial().printf(" SCAN_0101_UpperInt CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 2248 | break; |
whismanoid | 0:3edb3708c8c5 | 2249 | case MAX11131::SCAN_0110_UpperExternalClock: |
whismanoid | 0:3edb3708c8c5 | 2250 | cmdLine.serial().printf(" SCAN_0110_UpperExt CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 2251 | break; |
whismanoid | 0:3edb3708c8c5 | 2252 | case MAX11131::SCAN_0111_CustomInternalClock: |
whismanoid | 0:3edb3708c8c5 | 2253 | cmdLine.serial().printf(" SCAN_0111_CustomInt"); |
whismanoid | 0:3edb3708c8c5 | 2254 | break; |
whismanoid | 0:3edb3708c8c5 | 2255 | case MAX11131::SCAN_1000_CustomExternalClock: |
whismanoid | 0:3edb3708c8c5 | 2256 | cmdLine.serial().printf(" SCAN_1000_CustomExt"); |
whismanoid | 0:3edb3708c8c5 | 2257 | break; |
whismanoid | 0:3edb3708c8c5 | 2258 | case MAX11131::SCAN_1001_SampleSetExternalClock: |
whismanoid | 0:3edb3708c8c5 | 2259 | cmdLine.serial().printf(" SCAN_1001_SampleSetExt"); |
whismanoid | 0:3edb3708c8c5 | 2260 | break; |
whismanoid | 0:3edb3708c8c5 | 2261 | default: |
whismanoid | 0:3edb3708c8c5 | 2262 | cmdLine.serial().printf(" SCAN=%d", SCAN); |
whismanoid | 0:3edb3708c8c5 | 2263 | cmdLine.serial().printf(" CHSEL=%d", CHSEL); |
whismanoid | 0:3edb3708c8c5 | 2264 | } |
whismanoid | 0:3edb3708c8c5 | 2265 | if (RESET) { |
whismanoid | 0:3edb3708c8c5 | 2266 | cmdLine.serial().printf(" RESET=%d", RESET); |
whismanoid | 0:3edb3708c8c5 | 2267 | } |
whismanoid | 0:3edb3708c8c5 | 2268 | if (PM) { |
whismanoid | 0:3edb3708c8c5 | 2269 | cmdLine.serial().printf(" PM=%d", PM); |
whismanoid | 0:3edb3708c8c5 | 2270 | } |
whismanoid | 0:3edb3708c8c5 | 2271 | if (SCAN != MAX11131::SCAN_0000_NOP) |
whismanoid | 0:3edb3708c8c5 | 2272 | { |
whismanoid | 0:3edb3708c8c5 | 2273 | if (g_MAX11131_device.isExternalClock) |
whismanoid | 0:3edb3708c8c5 | 2274 | { |
whismanoid | 0:3edb3708c8c5 | 2275 | // if external clock mode, print CHANID |
whismanoid | 0:3edb3708c8c5 | 2276 | cmdLine.serial().printf(" CHANID=%d", CHANID); |
whismanoid | 0:3edb3708c8c5 | 2277 | } |
whismanoid | 0:3edb3708c8c5 | 2278 | else |
whismanoid | 0:3edb3708c8c5 | 2279 | { |
whismanoid | 0:3edb3708c8c5 | 2280 | // if internal clock mode, print SWCNV |
whismanoid | 0:3edb3708c8c5 | 2281 | cmdLine.serial().printf(" SWCNV=%d", SWCNV); |
whismanoid | 0:3edb3708c8c5 | 2282 | } |
whismanoid | 0:3edb3708c8c5 | 2283 | } |
whismanoid | 0:3edb3708c8c5 | 2284 | } |
whismanoid | 0:3edb3708c8c5 | 2285 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2286 | } |
whismanoid | 0:3edb3708c8c5 | 2287 | |
whismanoid | 0:3edb3708c8c5 | 2288 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2289 | // User-provided hardware function |
whismanoid | 0:3edb3708c8c5 | 2290 | // declare user-provided hardware interface function |
whismanoid | 0:3edb3708c8c5 | 2291 | // Assert CNVST convert start. |
whismanoid | 0:3edb3708c8c5 | 2292 | // Required when using any of the InternalClock modes with SWCNV 0. |
whismanoid | 0:3edb3708c8c5 | 2293 | // Trigger measurement by driving CNVST/AIN14 pin low for a minimum active-low pulse duration of 5ns. (AIN14 is not available) |
whismanoid | 0:3edb3708c8c5 | 2294 | // |
whismanoid | 0:3edb3708c8c5 | 2295 | //void CNVSToutputPulseLow() |
whismanoid | 0:3edb3708c8c5 | 2296 | //{ |
whismanoid | 0:3edb3708c8c5 | 2297 | // digitalInOut9.output(); |
whismanoid | 0:3edb3708c8c5 | 2298 | // digitalInOut9.write(0); |
whismanoid | 0:3edb3708c8c5 | 2299 | // // CNVST active-low pulse duration must be 5ns (0.005us) minimum. |
whismanoid | 0:3edb3708c8c5 | 2300 | // digitalInOut9.write(1); |
whismanoid | 0:3edb3708c8c5 | 2301 | // |
whismanoid | 0:3edb3708c8c5 | 2302 | //#if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 2303 | // cmdLine_microUSBserial.serial().printf(" CNVSToutputPulseLow "); |
whismanoid | 0:3edb3708c8c5 | 2304 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2305 | //#if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 2306 | // cmdLine_DAPLINKserial.serial().printf(" CNVSToutputPulseLow "); |
whismanoid | 0:3edb3708c8c5 | 2307 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2308 | //} |
whismanoid | 0:3edb3708c8c5 | 2309 | |
whismanoid | 0:3edb3708c8c5 | 2310 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2311 | // User-provided hardware function |
whismanoid | 0:3edb3708c8c5 | 2312 | // declare user-provided hardware interface function |
whismanoid | 0:3edb3708c8c5 | 2313 | // Wait for EOC pin low, indicating end of conversion. |
whismanoid | 0:3edb3708c8c5 | 2314 | // Required when using any of the InternalClock modes. |
whismanoid | 0:3edb3708c8c5 | 2315 | // |
whismanoid | 0:3edb3708c8c5 | 2316 | //void EOCinputWaitUntilLow() |
whismanoid | 0:3edb3708c8c5 | 2317 | //{ |
whismanoid | 0:3edb3708c8c5 | 2318 | // // |
whismanoid | 0:3edb3708c8c5 | 2319 | // // Arduino: pulseIn(pinIndex, HIGH | LOW, timeout_usec) // length of pulse in usec, or 0 if timeout |
whismanoid | 0:3edb3708c8c5 | 2320 | // // |
whismanoid | 0:3edb3708c8c5 | 2321 | // // const int timeout_usec = 1000; |
whismanoid | 0:3edb3708c8c5 | 2322 | // // TODO1: implement EOCinputWaitUntilLow APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 2323 | // // similar to Arduino pulseIn(MAX11131_EOC_Pin, LOW, timeout_usec); |
whismanoid | 0:3edb3708c8c5 | 2324 | //#if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 2325 | // cmdLine_microUSBserial.serial().printf(" EOCinputWaitUntilLow "); |
whismanoid | 0:3edb3708c8c5 | 2326 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2327 | //#if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 2328 | // cmdLine_DAPLINKserial.serial().printf(" EOCinputWaitUntilLow "); |
whismanoid | 0:3edb3708c8c5 | 2329 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2330 | //} |
whismanoid | 0:3edb3708c8c5 | 2331 | |
whismanoid | 0:3edb3708c8c5 | 2332 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2333 | // User-provided hardware function |
whismanoid | 0:3edb3708c8c5 | 2334 | // declare user-provided hardware interface function |
whismanoid | 0:3edb3708c8c5 | 2335 | // Assert SPI Chip Select |
whismanoid | 0:3edb3708c8c5 | 2336 | // SPI chip-select for MAX5715 |
whismanoid | 0:3edb3708c8c5 | 2337 | // |
whismanoid | 0:3edb3708c8c5 | 2338 | //void SPIoutputCS(int isLogicHigh) |
whismanoid | 0:3edb3708c8c5 | 2339 | //{ |
whismanoid | 0:3edb3708c8c5 | 2340 | // g_SPI_cs_state = isLogicHigh; |
whismanoid | 0:3edb3708c8c5 | 2341 | // spi_cs = g_SPI_cs_state; |
whismanoid | 0:3edb3708c8c5 | 2342 | //} |
whismanoid | 0:3edb3708c8c5 | 2343 | |
whismanoid | 0:3edb3708c8c5 | 2344 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2345 | // User-provided hardware function |
whismanoid | 0:3edb3708c8c5 | 2346 | // declare user-provided hardware interface function SPI write 16 bits |
whismanoid | 0:3edb3708c8c5 | 2347 | // SPI interface to MAX11131 shift 16 bits mosiData16 into MAX11131 DIN |
whismanoid | 0:3edb3708c8c5 | 2348 | // ignoring MAX11131 DOUT |
whismanoid | 0:3edb3708c8c5 | 2349 | //void SPIwrite16bits(int16_t mosiData16) |
whismanoid | 0:3edb3708c8c5 | 2350 | //{ |
whismanoid | 0:3edb3708c8c5 | 2351 | // // TODO1: implement SPIwrite16bits |
whismanoid | 0:3edb3708c8c5 | 2352 | // size_t byteCount = 2; |
whismanoid | 0:3edb3708c8c5 | 2353 | // static char mosiData[2]; |
whismanoid | 0:3edb3708c8c5 | 2354 | // static char misoData[2]; |
whismanoid | 0:3edb3708c8c5 | 2355 | // mosiData[0] = (char)((mosiData16 >> 8) & 0xFF); // MSByte |
whismanoid | 0:3edb3708c8c5 | 2356 | // mosiData[1] = (char)((mosiData16 >> 0) & 0xFF); // LSByte |
whismanoid | 0:3edb3708c8c5 | 2357 | // // |
whismanoid | 0:3edb3708c8c5 | 2358 | // // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() |
whismanoid | 0:3edb3708c8c5 | 2359 | // //~ noInterrupts(); |
whismanoid | 0:3edb3708c8c5 | 2360 | // // |
whismanoid | 0:3edb3708c8c5 | 2361 | // //~ digitalWrite(Scope_Trigger_Pin, LOW); // diagnostic Scope_Trigger_Pin |
whismanoid | 0:3edb3708c8c5 | 2362 | // // |
whismanoid | 0:3edb3708c8c5 | 2363 | // unsigned int numBytesTransferred = spi.write(mosiData, byteCount, misoData, byteCount); |
whismanoid | 0:3edb3708c8c5 | 2364 | // //~ SPI.transfer(mosiData8_FF0000); |
whismanoid | 0:3edb3708c8c5 | 2365 | // //~ SPI.transfer(mosiData16_00FF00); |
whismanoid | 0:3edb3708c8c5 | 2366 | // //~ SPI.transfer(mosiData16_0000FF); |
whismanoid | 0:3edb3708c8c5 | 2367 | // // |
whismanoid | 0:3edb3708c8c5 | 2368 | // //~ digitalWrite(Scope_Trigger_Pin, HIGH); // diagnostic Scope_Trigger_Pin |
whismanoid | 0:3edb3708c8c5 | 2369 | // // |
whismanoid | 0:3edb3708c8c5 | 2370 | // // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() |
whismanoid | 0:3edb3708c8c5 | 2371 | // //~ interrupts(); |
whismanoid | 0:3edb3708c8c5 | 2372 | // // |
whismanoid | 0:3edb3708c8c5 | 2373 | // // VERIFY: SPIwrite24bits print diagnostic information |
whismanoid | 0:3edb3708c8c5 | 2374 | // //cmdLine.serial().printf(" MOSI->")); |
whismanoid | 0:3edb3708c8c5 | 2375 | // //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:3edb3708c8c5 | 2376 | // //Serial.print( (mosiData8_FF0000 & 0xFF), HEX); |
whismanoid | 0:3edb3708c8c5 | 2377 | // //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:3edb3708c8c5 | 2378 | // //Serial.print( (mosiData16_00FF00 & 0xFF), HEX); |
whismanoid | 0:3edb3708c8c5 | 2379 | // //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:3edb3708c8c5 | 2380 | // //Serial.print( (mosiData16_0000FF & 0xFF), HEX); |
whismanoid | 0:3edb3708c8c5 | 2381 | // // hex dump mosiData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 2382 | //#if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 2383 | // cmdLine_microUSBserial.serial().printf("\r\nSPI"); |
whismanoid | 0:3edb3708c8c5 | 2384 | // if (byteCount > 7) { |
whismanoid | 0:3edb3708c8c5 | 2385 | // cmdLine_microUSBserial.serial().printf(" byteCount:%d", byteCount); |
whismanoid | 0:3edb3708c8c5 | 2386 | // } |
whismanoid | 0:3edb3708c8c5 | 2387 | // cmdLine_microUSBserial.serial().printf(" MOSI->"); |
whismanoid | 0:3edb3708c8c5 | 2388 | // for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2389 | // { |
whismanoid | 0:3edb3708c8c5 | 2390 | // cmdLine_microUSBserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2391 | // } |
whismanoid | 0:3edb3708c8c5 | 2392 | // // hex dump misoData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 2393 | // cmdLine_microUSBserial.serial().printf(" MISO<-"); |
whismanoid | 0:3edb3708c8c5 | 2394 | // for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2395 | // { |
whismanoid | 0:3edb3708c8c5 | 2396 | // cmdLine_microUSBserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2397 | // } |
whismanoid | 0:3edb3708c8c5 | 2398 | // cmdLine_microUSBserial.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 2399 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2400 | //#if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 2401 | // cmdLine_DAPLINKserial.serial().printf("\r\nSPI"); |
whismanoid | 0:3edb3708c8c5 | 2402 | // if (byteCount > 7) { |
whismanoid | 0:3edb3708c8c5 | 2403 | // cmdLine_DAPLINKserial.serial().printf(" byteCount:%d", byteCount); |
whismanoid | 0:3edb3708c8c5 | 2404 | // } |
whismanoid | 0:3edb3708c8c5 | 2405 | // cmdLine_DAPLINKserial.serial().printf(" MOSI->"); |
whismanoid | 0:3edb3708c8c5 | 2406 | // for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2407 | // { |
whismanoid | 0:3edb3708c8c5 | 2408 | // cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2409 | // } |
whismanoid | 0:3edb3708c8c5 | 2410 | // // hex dump misoData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 2411 | // cmdLine_DAPLINKserial.serial().printf(" MISO<-"); |
whismanoid | 0:3edb3708c8c5 | 2412 | // for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2413 | // { |
whismanoid | 0:3edb3708c8c5 | 2414 | // cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2415 | // } |
whismanoid | 0:3edb3708c8c5 | 2416 | // cmdLine_DAPLINKserial.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 2417 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2418 | // // VERIFY: DIAGNOSTIC: print MAX5715 device register write |
whismanoid | 0:3edb3708c8c5 | 2419 | // // TODO: MAX5715_print_register_verbose(mosiData8_FF0000, mosiData16_00FFFF); |
whismanoid | 0:3edb3708c8c5 | 2420 | // // TODO: print_verbose_SPI_diagnostic(mosiData16_FF00, mosiData16_00FF, misoData16_FF00, misoData16_00FF); |
whismanoid | 0:3edb3708c8c5 | 2421 | // // |
whismanoid | 0:3edb3708c8c5 | 2422 | // // int misoData16 = (misoData16_FF00 << 8) | misoData16_00FF; |
whismanoid | 0:3edb3708c8c5 | 2423 | // // return misoData16; |
whismanoid | 0:3edb3708c8c5 | 2424 | //} |
whismanoid | 0:3edb3708c8c5 | 2425 | |
whismanoid | 0:3edb3708c8c5 | 2426 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2427 | // User-provided hardware function |
whismanoid | 0:3edb3708c8c5 | 2428 | // declare user-provided hardware interface function SPI write 17-24 bits |
whismanoid | 0:3edb3708c8c5 | 2429 | // SPI interface to MAX11131 shift 16 bits mosiData16 into MAX11131 DIN |
whismanoid | 0:3edb3708c8c5 | 2430 | // followed by one additional SCLK byte. |
whismanoid | 0:3edb3708c8c5 | 2431 | // ignoring MAX11131 DOUT |
whismanoid | 0:3edb3708c8c5 | 2432 | //void SPIwrite24bits(int16_t mosiData16_FFFF00, int8_t mosiData8_0000FF) |
whismanoid | 0:3edb3708c8c5 | 2433 | //{ |
whismanoid | 0:3edb3708c8c5 | 2434 | // // TODO1: implement SPIwrite24bits |
whismanoid | 0:3edb3708c8c5 | 2435 | // size_t byteCount = 3; |
whismanoid | 0:3edb3708c8c5 | 2436 | // static char mosiData[3]; |
whismanoid | 0:3edb3708c8c5 | 2437 | // static char misoData[3]; |
whismanoid | 0:3edb3708c8c5 | 2438 | // mosiData[0] = (char)((mosiData16_FFFF00 >> 8) & 0xFF); // MSByte |
whismanoid | 0:3edb3708c8c5 | 2439 | // mosiData[1] = (char)((mosiData16_FFFF00 >> 0) & 0xFF); // LSByte |
whismanoid | 0:3edb3708c8c5 | 2440 | // mosiData[2] = mosiData8_0000FF; |
whismanoid | 0:3edb3708c8c5 | 2441 | // // |
whismanoid | 0:3edb3708c8c5 | 2442 | // // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() |
whismanoid | 0:3edb3708c8c5 | 2443 | // //~ noInterrupts(); |
whismanoid | 0:3edb3708c8c5 | 2444 | // // |
whismanoid | 0:3edb3708c8c5 | 2445 | // //~ digitalWrite(Scope_Trigger_Pin, LOW); // diagnostic Scope_Trigger_Pin |
whismanoid | 0:3edb3708c8c5 | 2446 | // // |
whismanoid | 0:3edb3708c8c5 | 2447 | // unsigned int numBytesTransferred = spi.write(mosiData, byteCount, misoData, byteCount); |
whismanoid | 0:3edb3708c8c5 | 2448 | // //~ SPI.transfer(mosiData8_FF0000); |
whismanoid | 0:3edb3708c8c5 | 2449 | // //~ SPI.transfer(mosiData16_00FF00); |
whismanoid | 0:3edb3708c8c5 | 2450 | // //~ SPI.transfer(mosiData16_0000FF); |
whismanoid | 0:3edb3708c8c5 | 2451 | // // |
whismanoid | 0:3edb3708c8c5 | 2452 | // //~ digitalWrite(Scope_Trigger_Pin, HIGH); // diagnostic Scope_Trigger_Pin |
whismanoid | 0:3edb3708c8c5 | 2453 | // // |
whismanoid | 0:3edb3708c8c5 | 2454 | // // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() |
whismanoid | 0:3edb3708c8c5 | 2455 | // //~ interrupts(); |
whismanoid | 0:3edb3708c8c5 | 2456 | // // |
whismanoid | 0:3edb3708c8c5 | 2457 | // // VERIFY: SPIwrite24bits print diagnostic information |
whismanoid | 0:3edb3708c8c5 | 2458 | // //cmdLine.serial().printf(" MOSI->")); |
whismanoid | 0:3edb3708c8c5 | 2459 | // //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:3edb3708c8c5 | 2460 | // //Serial.print( (mosiData8_FF0000 & 0xFF), HEX); |
whismanoid | 0:3edb3708c8c5 | 2461 | // //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:3edb3708c8c5 | 2462 | // //Serial.print( (mosiData16_00FF00 & 0xFF), HEX); |
whismanoid | 0:3edb3708c8c5 | 2463 | // //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:3edb3708c8c5 | 2464 | // //Serial.print( (mosiData16_0000FF & 0xFF), HEX); |
whismanoid | 0:3edb3708c8c5 | 2465 | // // hex dump mosiData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 2466 | //#if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 2467 | // cmdLine_microUSBserial.serial().printf("\r\nSPI"); |
whismanoid | 0:3edb3708c8c5 | 2468 | // if (byteCount > 7) { |
whismanoid | 0:3edb3708c8c5 | 2469 | // cmdLine_microUSBserial.serial().printf(" byteCount:%d", byteCount); |
whismanoid | 0:3edb3708c8c5 | 2470 | // } |
whismanoid | 0:3edb3708c8c5 | 2471 | // cmdLine_microUSBserial.serial().printf(" MOSI->"); |
whismanoid | 0:3edb3708c8c5 | 2472 | // for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2473 | // { |
whismanoid | 0:3edb3708c8c5 | 2474 | // cmdLine_microUSBserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2475 | // } |
whismanoid | 0:3edb3708c8c5 | 2476 | // // hex dump misoData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 2477 | // cmdLine_microUSBserial.serial().printf(" MISO<-"); |
whismanoid | 0:3edb3708c8c5 | 2478 | // for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2479 | // { |
whismanoid | 0:3edb3708c8c5 | 2480 | // cmdLine_microUSBserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2481 | // } |
whismanoid | 0:3edb3708c8c5 | 2482 | // cmdLine_microUSBserial.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 2483 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2484 | //#if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 2485 | // cmdLine_DAPLINKserial.serial().printf("\r\nSPI"); |
whismanoid | 0:3edb3708c8c5 | 2486 | // if (byteCount > 7) { |
whismanoid | 0:3edb3708c8c5 | 2487 | // cmdLine_DAPLINKserial.serial().printf(" byteCount:%d", byteCount); |
whismanoid | 0:3edb3708c8c5 | 2488 | // } |
whismanoid | 0:3edb3708c8c5 | 2489 | // cmdLine_DAPLINKserial.serial().printf(" MOSI->"); |
whismanoid | 0:3edb3708c8c5 | 2490 | // for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2491 | // { |
whismanoid | 0:3edb3708c8c5 | 2492 | // cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2493 | // } |
whismanoid | 0:3edb3708c8c5 | 2494 | // // hex dump misoData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 2495 | // cmdLine_DAPLINKserial.serial().printf(" MISO<-"); |
whismanoid | 0:3edb3708c8c5 | 2496 | // for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2497 | // { |
whismanoid | 0:3edb3708c8c5 | 2498 | // cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2499 | // } |
whismanoid | 0:3edb3708c8c5 | 2500 | // cmdLine_DAPLINKserial.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 2501 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2502 | // // VERIFY: DIAGNOSTIC: print MAX5715 device register write |
whismanoid | 0:3edb3708c8c5 | 2503 | // // TODO: MAX5715_print_register_verbose(mosiData8_FF0000, mosiData16_00FFFF); |
whismanoid | 0:3edb3708c8c5 | 2504 | // // |
whismanoid | 0:3edb3708c8c5 | 2505 | // // int misoData16 = (misoData16_FF00 << 8) | misoData16_00FF; |
whismanoid | 0:3edb3708c8c5 | 2506 | // // return misoData16; |
whismanoid | 0:3edb3708c8c5 | 2507 | //} |
whismanoid | 0:3edb3708c8c5 | 2508 | |
whismanoid | 0:3edb3708c8c5 | 2509 | //---------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2510 | // User-provided hardware function |
whismanoid | 0:3edb3708c8c5 | 2511 | // declare user-provided hardware interface function SPI read 16 bits while MOSI (Maxim DIN) is 0 |
whismanoid | 0:3edb3708c8c5 | 2512 | // SPI interface to capture 16 bits miso data from MAX11131 DOUT |
whismanoid | 0:3edb3708c8c5 | 2513 | //int16_t SPIread16bits() |
whismanoid | 0:3edb3708c8c5 | 2514 | //{ |
whismanoid | 0:3edb3708c8c5 | 2515 | // // TODO1: implement SPIread16bits |
whismanoid | 0:3edb3708c8c5 | 2516 | // int mosiData16 = 0; |
whismanoid | 0:3edb3708c8c5 | 2517 | // size_t byteCount = 2; |
whismanoid | 0:3edb3708c8c5 | 2518 | // static char mosiData[2]; |
whismanoid | 0:3edb3708c8c5 | 2519 | // static char misoData[2]; |
whismanoid | 0:3edb3708c8c5 | 2520 | // mosiData[0] = (char)((mosiData16 >> 8) & 0xFF); // MSByte |
whismanoid | 0:3edb3708c8c5 | 2521 | // mosiData[1] = (char)((mosiData16 >> 0) & 0xFF); // LSByte |
whismanoid | 0:3edb3708c8c5 | 2522 | // // |
whismanoid | 0:3edb3708c8c5 | 2523 | // // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() |
whismanoid | 0:3edb3708c8c5 | 2524 | // //~ noInterrupts(); |
whismanoid | 0:3edb3708c8c5 | 2525 | // // |
whismanoid | 0:3edb3708c8c5 | 2526 | // //~ digitalWrite(Scope_Trigger_Pin, LOW); // diagnostic Scope_Trigger_Pin |
whismanoid | 0:3edb3708c8c5 | 2527 | // // |
whismanoid | 0:3edb3708c8c5 | 2528 | // unsigned int numBytesTransferred = spi.write(mosiData, byteCount, misoData, byteCount); |
whismanoid | 0:3edb3708c8c5 | 2529 | // //~ SPI.transfer(mosiData8_FF0000); |
whismanoid | 0:3edb3708c8c5 | 2530 | // //~ SPI.transfer(mosiData16_00FF00); |
whismanoid | 0:3edb3708c8c5 | 2531 | // //~ SPI.transfer(mosiData16_0000FF); |
whismanoid | 0:3edb3708c8c5 | 2532 | // // |
whismanoid | 0:3edb3708c8c5 | 2533 | // //~ digitalWrite(Scope_Trigger_Pin, HIGH); // diagnostic Scope_Trigger_Pin |
whismanoid | 0:3edb3708c8c5 | 2534 | // // |
whismanoid | 0:3edb3708c8c5 | 2535 | // // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() |
whismanoid | 0:3edb3708c8c5 | 2536 | // //~ interrupts(); |
whismanoid | 0:3edb3708c8c5 | 2537 | // // |
whismanoid | 0:3edb3708c8c5 | 2538 | // // VERIFY: SPIwrite24bits print diagnostic information |
whismanoid | 0:3edb3708c8c5 | 2539 | // //cmdLine.serial().printf(" MOSI->")); |
whismanoid | 0:3edb3708c8c5 | 2540 | // //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:3edb3708c8c5 | 2541 | // //Serial.print( (mosiData8_FF0000 & 0xFF), HEX); |
whismanoid | 0:3edb3708c8c5 | 2542 | // //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:3edb3708c8c5 | 2543 | // //Serial.print( (mosiData16_00FF00 & 0xFF), HEX); |
whismanoid | 0:3edb3708c8c5 | 2544 | // //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:3edb3708c8c5 | 2545 | // //Serial.print( (mosiData16_0000FF & 0xFF), HEX); |
whismanoid | 0:3edb3708c8c5 | 2546 | // // hex dump mosiData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 2547 | //#if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 2548 | // cmdLine_microUSBserial.serial().printf("\r\nSPI"); |
whismanoid | 0:3edb3708c8c5 | 2549 | // if (byteCount > 7) { |
whismanoid | 0:3edb3708c8c5 | 2550 | // cmdLine_microUSBserial.serial().printf(" byteCount:%d", byteCount); |
whismanoid | 0:3edb3708c8c5 | 2551 | // } |
whismanoid | 0:3edb3708c8c5 | 2552 | // cmdLine_microUSBserial.serial().printf(" MOSI->"); |
whismanoid | 0:3edb3708c8c5 | 2553 | // for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2554 | // { |
whismanoid | 0:3edb3708c8c5 | 2555 | // cmdLine_microUSBserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2556 | // } |
whismanoid | 0:3edb3708c8c5 | 2557 | // // hex dump misoData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 2558 | // cmdLine_microUSBserial.serial().printf(" MISO<-"); |
whismanoid | 0:3edb3708c8c5 | 2559 | // for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2560 | // { |
whismanoid | 0:3edb3708c8c5 | 2561 | // cmdLine_microUSBserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2562 | // } |
whismanoid | 0:3edb3708c8c5 | 2563 | // cmdLine_microUSBserial.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 2564 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2565 | //#if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 2566 | // cmdLine_DAPLINKserial.serial().printf("\r\nSPI"); |
whismanoid | 0:3edb3708c8c5 | 2567 | // if (byteCount > 7) { |
whismanoid | 0:3edb3708c8c5 | 2568 | // cmdLine_DAPLINKserial.serial().printf(" byteCount:%d", byteCount); |
whismanoid | 0:3edb3708c8c5 | 2569 | // } |
whismanoid | 0:3edb3708c8c5 | 2570 | // cmdLine_DAPLINKserial.serial().printf(" MOSI->"); |
whismanoid | 0:3edb3708c8c5 | 2571 | // for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2572 | // { |
whismanoid | 0:3edb3708c8c5 | 2573 | // cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2574 | // } |
whismanoid | 0:3edb3708c8c5 | 2575 | // // hex dump misoData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 2576 | // cmdLine_DAPLINKserial.serial().printf(" MISO<-"); |
whismanoid | 0:3edb3708c8c5 | 2577 | // for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 2578 | // { |
whismanoid | 0:3edb3708c8c5 | 2579 | // cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 2580 | // } |
whismanoid | 0:3edb3708c8c5 | 2581 | // cmdLine_DAPLINKserial.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 2582 | //#endif |
whismanoid | 0:3edb3708c8c5 | 2583 | // // VERIFY: DIAGNOSTIC: print MAX5715 device register write |
whismanoid | 0:3edb3708c8c5 | 2584 | // // TODO: MAX5715_print_register_verbose(mosiData8_FF0000, mosiData16_00FFFF); |
whismanoid | 0:3edb3708c8c5 | 2585 | // // TODO: print_verbose_SPI_diagnostic(mosiData16_FF00, mosiData16_00FF, misoData16_FF00, misoData16_00FF); |
whismanoid | 0:3edb3708c8c5 | 2586 | // // |
whismanoid | 0:3edb3708c8c5 | 2587 | // int misoData16 = (misoData[0] << 8) | misoData[1]; |
whismanoid | 0:3edb3708c8c5 | 2588 | // return misoData16; |
whismanoid | 0:3edb3708c8c5 | 2589 | //} |
whismanoid | 0:3edb3708c8c5 | 2590 | |
whismanoid | 0:3edb3708c8c5 | 2591 | #endif |
whismanoid | 0:3edb3708c8c5 | 2592 | |
whismanoid | 0:3edb3708c8c5 | 2593 | |
whismanoid | 0:3edb3708c8c5 | 2594 | #if APPLICATION_MAX5171 // hardware interface functions |
whismanoid | 0:3edb3708c8c5 | 2595 | #endif |
whismanoid | 0:3edb3708c8c5 | 2596 | |
whismanoid | 0:3edb3708c8c5 | 2597 | |
whismanoid | 0:3edb3708c8c5 | 2598 | #if APPLICATION_MAX11410 // hardware interface functions |
whismanoid | 0:3edb3708c8c5 | 2599 | #endif |
whismanoid | 0:3edb3708c8c5 | 2600 | |
whismanoid | 0:3edb3708c8c5 | 2601 | |
whismanoid | 0:3edb3708c8c5 | 2602 | #if APPLICATION_MAX12345 // hardware interface functions |
whismanoid | 0:3edb3708c8c5 | 2603 | #endif |
whismanoid | 0:3edb3708c8c5 | 2604 | |
whismanoid | 0:3edb3708c8c5 | 2605 | |
whismanoid | 0:3edb3708c8c5 | 2606 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 2607 | // print banner message to serial port |
whismanoid | 0:3edb3708c8c5 | 2608 | void print_banner() |
whismanoid | 0:3edb3708c8c5 | 2609 | { |
whismanoid | 0:3edb3708c8c5 | 2610 | #if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 2611 | DAPLINKserial.printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2612 | # if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 2613 | DAPLINKserial.printf("MAX32630"); |
whismanoid | 0:3edb3708c8c5 | 2614 | # elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 2615 | DAPLINKserial.printf("MAX32625MBED"); |
whismanoid | 0:3edb3708c8c5 | 2616 | # elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 2617 | DAPLINKserial.printf("NUCLEO_F446RE"); |
whismanoid | 0:3edb3708c8c5 | 2618 | # elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 2619 | DAPLINKserial.printf("NUCLEO_F401RE"); |
whismanoid | 0:3edb3708c8c5 | 2620 | # elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 2621 | DAPLINKserial.printf("LPC1768"); |
whismanoid | 0:3edb3708c8c5 | 2622 | # else |
whismanoid | 0:3edb3708c8c5 | 2623 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 2624 | DAPLINKserial.printf("unknownTarget"); |
whismanoid | 0:3edb3708c8c5 | 2625 | # endif |
whismanoid | 0:3edb3708c8c5 | 2626 | DAPLINKserial.printf(" DAPLINKserial\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2627 | #endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 2628 | |
whismanoid | 0:3edb3708c8c5 | 2629 | #if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 2630 | microUSBserial.printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2631 | # if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 2632 | microUSBserial.printf("MAX32630"); |
whismanoid | 0:3edb3708c8c5 | 2633 | # elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 2634 | microUSBserial.printf("MAX32625MBED"); |
whismanoid | 0:3edb3708c8c5 | 2635 | # elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 2636 | microUSBserial.printf("NUCLEO_F446RE"); |
whismanoid | 0:3edb3708c8c5 | 2637 | # elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 2638 | microUSBserial.printf("NUCLEO_F401RE"); |
whismanoid | 0:3edb3708c8c5 | 2639 | # elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 2640 | microUSBserial.printf("LPC1768"); |
whismanoid | 0:3edb3708c8c5 | 2641 | # else |
whismanoid | 0:3edb3708c8c5 | 2642 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 2643 | microUSBserial.printf("unknownTarget"); |
whismanoid | 0:3edb3708c8c5 | 2644 | # endif |
whismanoid | 0:3edb3708c8c5 | 2645 | microUSBserial.printf(" microUSBserial\r\n"); |
whismanoid | 0:3edb3708c8c5 | 2646 | #endif // HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 2647 | } |
whismanoid | 0:3edb3708c8c5 | 2648 | |
whismanoid | 0:3edb3708c8c5 | 2649 | // DigitalInOut pin resource: print the pin index names to microUSBserial |
whismanoid | 0:3edb3708c8c5 | 2650 | #if HAS_digitalInOuts |
whismanoid | 0:3edb3708c8c5 | 2651 | void list_digitalInOutPins(Stream& serialStream) |
whismanoid | 0:3edb3708c8c5 | 2652 | { |
whismanoid | 0:3edb3708c8c5 | 2653 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 2654 | serialStream.printf(" 0"); |
whismanoid | 0:3edb3708c8c5 | 2655 | #endif |
whismanoid | 0:3edb3708c8c5 | 2656 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 2657 | serialStream.printf(" 1"); |
whismanoid | 0:3edb3708c8c5 | 2658 | #endif |
whismanoid | 0:3edb3708c8c5 | 2659 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 2660 | serialStream.printf(" 2"); |
whismanoid | 0:3edb3708c8c5 | 2661 | #endif |
whismanoid | 0:3edb3708c8c5 | 2662 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 2663 | serialStream.printf(" 3"); |
whismanoid | 0:3edb3708c8c5 | 2664 | #endif |
whismanoid | 0:3edb3708c8c5 | 2665 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 2666 | serialStream.printf(" 4"); |
whismanoid | 0:3edb3708c8c5 | 2667 | #endif |
whismanoid | 0:3edb3708c8c5 | 2668 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 2669 | serialStream.printf(" 5"); |
whismanoid | 0:3edb3708c8c5 | 2670 | #endif |
whismanoid | 0:3edb3708c8c5 | 2671 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 2672 | serialStream.printf(" 6"); |
whismanoid | 0:3edb3708c8c5 | 2673 | #endif |
whismanoid | 0:3edb3708c8c5 | 2674 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 2675 | serialStream.printf(" 7"); |
whismanoid | 0:3edb3708c8c5 | 2676 | #endif |
whismanoid | 0:3edb3708c8c5 | 2677 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 2678 | serialStream.printf(" 8"); |
whismanoid | 0:3edb3708c8c5 | 2679 | #endif |
whismanoid | 0:3edb3708c8c5 | 2680 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 2681 | serialStream.printf(" 9"); |
whismanoid | 0:3edb3708c8c5 | 2682 | #endif |
whismanoid | 0:3edb3708c8c5 | 2683 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 2684 | serialStream.printf(" 10"); |
whismanoid | 0:3edb3708c8c5 | 2685 | #endif |
whismanoid | 0:3edb3708c8c5 | 2686 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 2687 | serialStream.printf(" 11"); |
whismanoid | 0:3edb3708c8c5 | 2688 | #endif |
whismanoid | 0:3edb3708c8c5 | 2689 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 2690 | serialStream.printf(" 12"); |
whismanoid | 0:3edb3708c8c5 | 2691 | #endif |
whismanoid | 0:3edb3708c8c5 | 2692 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 2693 | serialStream.printf(" 13"); |
whismanoid | 0:3edb3708c8c5 | 2694 | #endif |
whismanoid | 0:3edb3708c8c5 | 2695 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 2696 | serialStream.printf(" 14"); |
whismanoid | 0:3edb3708c8c5 | 2697 | #endif |
whismanoid | 0:3edb3708c8c5 | 2698 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 2699 | serialStream.printf(" 15"); |
whismanoid | 0:3edb3708c8c5 | 2700 | #endif |
whismanoid | 0:3edb3708c8c5 | 2701 | #if HAS_digitalInOut16 |
whismanoid | 0:3edb3708c8c5 | 2702 | serialStream.printf(" 16"); |
whismanoid | 0:3edb3708c8c5 | 2703 | #endif |
whismanoid | 0:3edb3708c8c5 | 2704 | #if HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 2705 | serialStream.printf(" 17"); |
whismanoid | 0:3edb3708c8c5 | 2706 | #endif |
whismanoid | 0:3edb3708c8c5 | 2707 | } |
whismanoid | 0:3edb3708c8c5 | 2708 | #endif |
whismanoid | 0:3edb3708c8c5 | 2709 | |
whismanoid | 0:3edb3708c8c5 | 2710 | // DigitalInOut pin resource: present? |
whismanoid | 0:3edb3708c8c5 | 2711 | #if HAS_digitalInOuts |
whismanoid | 0:3edb3708c8c5 | 2712 | bool has_digitalInOutPin(int cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2713 | { |
whismanoid | 0:3edb3708c8c5 | 2714 | switch (cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2715 | { |
whismanoid | 0:3edb3708c8c5 | 2716 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 2717 | case '0': case 0x00: return true; |
whismanoid | 0:3edb3708c8c5 | 2718 | #endif |
whismanoid | 0:3edb3708c8c5 | 2719 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 2720 | case '1': case 0x01: return true; |
whismanoid | 0:3edb3708c8c5 | 2721 | #endif |
whismanoid | 0:3edb3708c8c5 | 2722 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 2723 | case '2': case 0x02: return true; |
whismanoid | 0:3edb3708c8c5 | 2724 | #endif |
whismanoid | 0:3edb3708c8c5 | 2725 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 2726 | case '3': case 0x03: return true; |
whismanoid | 0:3edb3708c8c5 | 2727 | #endif |
whismanoid | 0:3edb3708c8c5 | 2728 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 2729 | case '4': case 0x04: return true; |
whismanoid | 0:3edb3708c8c5 | 2730 | #endif |
whismanoid | 0:3edb3708c8c5 | 2731 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 2732 | case '5': case 0x05: return true; |
whismanoid | 0:3edb3708c8c5 | 2733 | #endif |
whismanoid | 0:3edb3708c8c5 | 2734 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 2735 | case '6': case 0x06: return true; |
whismanoid | 0:3edb3708c8c5 | 2736 | #endif |
whismanoid | 0:3edb3708c8c5 | 2737 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 2738 | case '7': case 0x07: return true; |
whismanoid | 0:3edb3708c8c5 | 2739 | #endif |
whismanoid | 0:3edb3708c8c5 | 2740 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 2741 | case '8': case 0x08: return true; |
whismanoid | 0:3edb3708c8c5 | 2742 | #endif |
whismanoid | 0:3edb3708c8c5 | 2743 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 2744 | case '9': case 0x09: return true; |
whismanoid | 0:3edb3708c8c5 | 2745 | #endif |
whismanoid | 0:3edb3708c8c5 | 2746 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 2747 | case 'a': case 0x0a: return true; |
whismanoid | 0:3edb3708c8c5 | 2748 | #endif |
whismanoid | 0:3edb3708c8c5 | 2749 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 2750 | case 'b': case 0x0b: return true; |
whismanoid | 0:3edb3708c8c5 | 2751 | #endif |
whismanoid | 0:3edb3708c8c5 | 2752 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 2753 | case 'c': case 0x0c: return true; |
whismanoid | 0:3edb3708c8c5 | 2754 | #endif |
whismanoid | 0:3edb3708c8c5 | 2755 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 2756 | case 'd': case 0x0d: return true; |
whismanoid | 0:3edb3708c8c5 | 2757 | #endif |
whismanoid | 0:3edb3708c8c5 | 2758 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 2759 | case 'e': case 0x0e: return true; |
whismanoid | 0:3edb3708c8c5 | 2760 | #endif |
whismanoid | 0:3edb3708c8c5 | 2761 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 2762 | case 'f': case 0x0f: return true; |
whismanoid | 0:3edb3708c8c5 | 2763 | #endif |
whismanoid | 0:3edb3708c8c5 | 2764 | default: |
whismanoid | 0:3edb3708c8c5 | 2765 | return false; |
whismanoid | 0:3edb3708c8c5 | 2766 | } |
whismanoid | 0:3edb3708c8c5 | 2767 | } |
whismanoid | 0:3edb3708c8c5 | 2768 | #endif |
whismanoid | 0:3edb3708c8c5 | 2769 | |
whismanoid | 0:3edb3708c8c5 | 2770 | // DigitalInOut pin resource: search index |
whismanoid | 0:3edb3708c8c5 | 2771 | #if HAS_digitalInOuts |
whismanoid | 0:3edb3708c8c5 | 2772 | DigitalInOut& find_digitalInOutPin(int cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2773 | { |
whismanoid | 0:3edb3708c8c5 | 2774 | switch (cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2775 | { |
whismanoid | 0:3edb3708c8c5 | 2776 | default: // default to the first defined digitalInOut pin |
whismanoid | 0:3edb3708c8c5 | 2777 | #if HAS_digitalInOut0 |
whismanoid | 0:3edb3708c8c5 | 2778 | case '0': case 0x00: return digitalInOut0; |
whismanoid | 0:3edb3708c8c5 | 2779 | #endif |
whismanoid | 0:3edb3708c8c5 | 2780 | #if HAS_digitalInOut1 |
whismanoid | 0:3edb3708c8c5 | 2781 | case '1': case 0x01: return digitalInOut1; |
whismanoid | 0:3edb3708c8c5 | 2782 | #endif |
whismanoid | 0:3edb3708c8c5 | 2783 | #if HAS_digitalInOut2 |
whismanoid | 0:3edb3708c8c5 | 2784 | case '2': case 0x02: return digitalInOut2; |
whismanoid | 0:3edb3708c8c5 | 2785 | #endif |
whismanoid | 0:3edb3708c8c5 | 2786 | #if HAS_digitalInOut3 |
whismanoid | 0:3edb3708c8c5 | 2787 | case '3': case 0x03: return digitalInOut3; |
whismanoid | 0:3edb3708c8c5 | 2788 | #endif |
whismanoid | 0:3edb3708c8c5 | 2789 | #if HAS_digitalInOut4 |
whismanoid | 0:3edb3708c8c5 | 2790 | case '4': case 0x04: return digitalInOut4; |
whismanoid | 0:3edb3708c8c5 | 2791 | #endif |
whismanoid | 0:3edb3708c8c5 | 2792 | #if HAS_digitalInOut5 |
whismanoid | 0:3edb3708c8c5 | 2793 | case '5': case 0x05: return digitalInOut5; |
whismanoid | 0:3edb3708c8c5 | 2794 | #endif |
whismanoid | 0:3edb3708c8c5 | 2795 | #if HAS_digitalInOut6 |
whismanoid | 0:3edb3708c8c5 | 2796 | case '6': case 0x06: return digitalInOut6; |
whismanoid | 0:3edb3708c8c5 | 2797 | #endif |
whismanoid | 0:3edb3708c8c5 | 2798 | #if HAS_digitalInOut7 |
whismanoid | 0:3edb3708c8c5 | 2799 | case '7': case 0x07: return digitalInOut7; |
whismanoid | 0:3edb3708c8c5 | 2800 | #endif |
whismanoid | 0:3edb3708c8c5 | 2801 | #if HAS_digitalInOut8 |
whismanoid | 0:3edb3708c8c5 | 2802 | case '8': case 0x08: return digitalInOut8; |
whismanoid | 0:3edb3708c8c5 | 2803 | #endif |
whismanoid | 0:3edb3708c8c5 | 2804 | #if HAS_digitalInOut9 |
whismanoid | 0:3edb3708c8c5 | 2805 | case '9': case 0x09: return digitalInOut9; |
whismanoid | 0:3edb3708c8c5 | 2806 | #endif |
whismanoid | 0:3edb3708c8c5 | 2807 | #if HAS_digitalInOut10 |
whismanoid | 0:3edb3708c8c5 | 2808 | case 'a': case 0x0a: return digitalInOut10; |
whismanoid | 0:3edb3708c8c5 | 2809 | #endif |
whismanoid | 0:3edb3708c8c5 | 2810 | #if HAS_digitalInOut11 |
whismanoid | 0:3edb3708c8c5 | 2811 | case 'b': case 0x0b: return digitalInOut11; |
whismanoid | 0:3edb3708c8c5 | 2812 | #endif |
whismanoid | 0:3edb3708c8c5 | 2813 | #if HAS_digitalInOut12 |
whismanoid | 0:3edb3708c8c5 | 2814 | case 'c': case 0x0c: return digitalInOut12; |
whismanoid | 0:3edb3708c8c5 | 2815 | #endif |
whismanoid | 0:3edb3708c8c5 | 2816 | #if HAS_digitalInOut13 |
whismanoid | 0:3edb3708c8c5 | 2817 | case 'd': case 0x0d: return digitalInOut13; |
whismanoid | 0:3edb3708c8c5 | 2818 | #endif |
whismanoid | 0:3edb3708c8c5 | 2819 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 2820 | case 'e': case 0x0e: return digitalInOut14; |
whismanoid | 0:3edb3708c8c5 | 2821 | #endif |
whismanoid | 0:3edb3708c8c5 | 2822 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 2823 | case 'f': case 0x0f: return digitalInOut15; |
whismanoid | 0:3edb3708c8c5 | 2824 | #endif |
whismanoid | 0:3edb3708c8c5 | 2825 | #if HAS_digitalInOut16 |
whismanoid | 0:3edb3708c8c5 | 2826 | case 'g': case 0x10: return digitalInOut16; |
whismanoid | 0:3edb3708c8c5 | 2827 | #endif |
whismanoid | 0:3edb3708c8c5 | 2828 | #if HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 2829 | case 'h': case 0x11: return digitalInOut17; |
whismanoid | 0:3edb3708c8c5 | 2830 | #endif |
whismanoid | 0:3edb3708c8c5 | 2831 | } |
whismanoid | 0:3edb3708c8c5 | 2832 | } |
whismanoid | 0:3edb3708c8c5 | 2833 | #endif |
whismanoid | 0:3edb3708c8c5 | 2834 | |
whismanoid | 0:3edb3708c8c5 | 2835 | // AnalogIn pin resource: print the pin index names to microUSBserial |
whismanoid | 0:3edb3708c8c5 | 2836 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 2837 | void list_analogInPins(Stream& serialStream) |
whismanoid | 0:3edb3708c8c5 | 2838 | { |
whismanoid | 0:3edb3708c8c5 | 2839 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2840 | serialStream.printf(" 0"); |
whismanoid | 0:3edb3708c8c5 | 2841 | #endif |
whismanoid | 0:3edb3708c8c5 | 2842 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 2843 | serialStream.printf(" 1"); |
whismanoid | 0:3edb3708c8c5 | 2844 | #endif |
whismanoid | 0:3edb3708c8c5 | 2845 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 2846 | serialStream.printf(" 2"); |
whismanoid | 0:3edb3708c8c5 | 2847 | #endif |
whismanoid | 0:3edb3708c8c5 | 2848 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 2849 | serialStream.printf(" 3"); |
whismanoid | 0:3edb3708c8c5 | 2850 | #endif |
whismanoid | 0:3edb3708c8c5 | 2851 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 2852 | serialStream.printf(" 4"); |
whismanoid | 0:3edb3708c8c5 | 2853 | #endif |
whismanoid | 0:3edb3708c8c5 | 2854 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 2855 | serialStream.printf(" 5"); |
whismanoid | 0:3edb3708c8c5 | 2856 | #endif |
whismanoid | 0:3edb3708c8c5 | 2857 | #if HAS_analogIn6 |
whismanoid | 0:3edb3708c8c5 | 2858 | serialStream.printf(" 6"); |
whismanoid | 0:3edb3708c8c5 | 2859 | #endif |
whismanoid | 0:3edb3708c8c5 | 2860 | #if HAS_analogIn7 |
whismanoid | 0:3edb3708c8c5 | 2861 | serialStream.printf(" 7"); |
whismanoid | 0:3edb3708c8c5 | 2862 | #endif |
whismanoid | 0:3edb3708c8c5 | 2863 | #if HAS_analogIn8 |
whismanoid | 0:3edb3708c8c5 | 2864 | serialStream.printf(" 8"); |
whismanoid | 0:3edb3708c8c5 | 2865 | #endif |
whismanoid | 0:3edb3708c8c5 | 2866 | #if HAS_analogIn9 |
whismanoid | 0:3edb3708c8c5 | 2867 | serialStream.printf(" 9"); |
whismanoid | 0:3edb3708c8c5 | 2868 | #endif |
whismanoid | 0:3edb3708c8c5 | 2869 | #if HAS_analogIn10 |
whismanoid | 0:3edb3708c8c5 | 2870 | serialStream.printf(" a"); |
whismanoid | 0:3edb3708c8c5 | 2871 | #endif |
whismanoid | 0:3edb3708c8c5 | 2872 | #if HAS_analogIn11 |
whismanoid | 0:3edb3708c8c5 | 2873 | serialStream.printf(" b"); |
whismanoid | 0:3edb3708c8c5 | 2874 | #endif |
whismanoid | 0:3edb3708c8c5 | 2875 | #if HAS_analogIn12 |
whismanoid | 0:3edb3708c8c5 | 2876 | serialStream.printf(" c"); |
whismanoid | 0:3edb3708c8c5 | 2877 | #endif |
whismanoid | 0:3edb3708c8c5 | 2878 | #if HAS_analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2879 | serialStream.printf(" d"); |
whismanoid | 0:3edb3708c8c5 | 2880 | #endif |
whismanoid | 0:3edb3708c8c5 | 2881 | #if HAS_analogIn14 |
whismanoid | 0:3edb3708c8c5 | 2882 | serialStream.printf(" e"); |
whismanoid | 0:3edb3708c8c5 | 2883 | #endif |
whismanoid | 0:3edb3708c8c5 | 2884 | #if HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 2885 | serialStream.printf(" f"); |
whismanoid | 0:3edb3708c8c5 | 2886 | #endif |
whismanoid | 0:3edb3708c8c5 | 2887 | } |
whismanoid | 0:3edb3708c8c5 | 2888 | #endif |
whismanoid | 0:3edb3708c8c5 | 2889 | |
whismanoid | 0:3edb3708c8c5 | 2890 | // AnalogIn pin resource: present? |
whismanoid | 0:3edb3708c8c5 | 2891 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 2892 | bool has_analogInPin(int cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2893 | { |
whismanoid | 0:3edb3708c8c5 | 2894 | switch (cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2895 | { |
whismanoid | 0:3edb3708c8c5 | 2896 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2897 | case '0': case 0x00: return true; |
whismanoid | 0:3edb3708c8c5 | 2898 | #endif |
whismanoid | 0:3edb3708c8c5 | 2899 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 2900 | case '1': case 0x01: return true; |
whismanoid | 0:3edb3708c8c5 | 2901 | #endif |
whismanoid | 0:3edb3708c8c5 | 2902 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 2903 | case '2': case 0x02: return true; |
whismanoid | 0:3edb3708c8c5 | 2904 | #endif |
whismanoid | 0:3edb3708c8c5 | 2905 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 2906 | case '3': case 0x03: return true; |
whismanoid | 0:3edb3708c8c5 | 2907 | #endif |
whismanoid | 0:3edb3708c8c5 | 2908 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 2909 | case '4': case 0x04: return true; |
whismanoid | 0:3edb3708c8c5 | 2910 | #endif |
whismanoid | 0:3edb3708c8c5 | 2911 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 2912 | case '5': case 0x05: return true; |
whismanoid | 0:3edb3708c8c5 | 2913 | #endif |
whismanoid | 0:3edb3708c8c5 | 2914 | #if HAS_analogIn6 |
whismanoid | 0:3edb3708c8c5 | 2915 | case '6': case 0x06: return true; |
whismanoid | 0:3edb3708c8c5 | 2916 | #endif |
whismanoid | 0:3edb3708c8c5 | 2917 | #if HAS_analogIn7 |
whismanoid | 0:3edb3708c8c5 | 2918 | case '7': case 0x07: return true; |
whismanoid | 0:3edb3708c8c5 | 2919 | #endif |
whismanoid | 0:3edb3708c8c5 | 2920 | #if HAS_analogIn8 |
whismanoid | 0:3edb3708c8c5 | 2921 | case '8': case 0x08: return true; |
whismanoid | 0:3edb3708c8c5 | 2922 | #endif |
whismanoid | 0:3edb3708c8c5 | 2923 | #if HAS_analogIn9 |
whismanoid | 0:3edb3708c8c5 | 2924 | case '9': case 0x09: return true; |
whismanoid | 0:3edb3708c8c5 | 2925 | #endif |
whismanoid | 0:3edb3708c8c5 | 2926 | #if HAS_analogIn10 |
whismanoid | 0:3edb3708c8c5 | 2927 | case 'a': case 0x0a: return true; |
whismanoid | 0:3edb3708c8c5 | 2928 | #endif |
whismanoid | 0:3edb3708c8c5 | 2929 | #if HAS_analogIn11 |
whismanoid | 0:3edb3708c8c5 | 2930 | case 'b': case 0x0b: return true; |
whismanoid | 0:3edb3708c8c5 | 2931 | #endif |
whismanoid | 0:3edb3708c8c5 | 2932 | #if HAS_analogIn12 |
whismanoid | 0:3edb3708c8c5 | 2933 | case 'c': case 0x0c: return true; |
whismanoid | 0:3edb3708c8c5 | 2934 | #endif |
whismanoid | 0:3edb3708c8c5 | 2935 | #if HAS_analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2936 | case 'd': case 0x0d: return true; |
whismanoid | 0:3edb3708c8c5 | 2937 | #endif |
whismanoid | 0:3edb3708c8c5 | 2938 | #if HAS_analogIn14 |
whismanoid | 0:3edb3708c8c5 | 2939 | case 'e': case 0x0e: return true; |
whismanoid | 0:3edb3708c8c5 | 2940 | #endif |
whismanoid | 0:3edb3708c8c5 | 2941 | #if HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 2942 | case 'f': case 0x0f: return true; |
whismanoid | 0:3edb3708c8c5 | 2943 | #endif |
whismanoid | 0:3edb3708c8c5 | 2944 | default: |
whismanoid | 0:3edb3708c8c5 | 2945 | return false; |
whismanoid | 0:3edb3708c8c5 | 2946 | } |
whismanoid | 0:3edb3708c8c5 | 2947 | } |
whismanoid | 0:3edb3708c8c5 | 2948 | #endif |
whismanoid | 0:3edb3708c8c5 | 2949 | |
whismanoid | 0:3edb3708c8c5 | 2950 | // AnalogIn pin resource: search index |
whismanoid | 0:3edb3708c8c5 | 2951 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 2952 | AnalogIn& find_analogInPin(int cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2953 | { |
whismanoid | 0:3edb3708c8c5 | 2954 | switch (cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 2955 | { |
whismanoid | 0:3edb3708c8c5 | 2956 | default: // default to the first defined analogIn pin |
whismanoid | 0:3edb3708c8c5 | 2957 | #if HAS_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 2958 | case '0': case 0x00: return analogIn0; |
whismanoid | 0:3edb3708c8c5 | 2959 | #endif |
whismanoid | 0:3edb3708c8c5 | 2960 | #if HAS_analogIn1 |
whismanoid | 0:3edb3708c8c5 | 2961 | case '1': case 0x01: return analogIn1; |
whismanoid | 0:3edb3708c8c5 | 2962 | #endif |
whismanoid | 0:3edb3708c8c5 | 2963 | #if HAS_analogIn2 |
whismanoid | 0:3edb3708c8c5 | 2964 | case '2': case 0x02: return analogIn2; |
whismanoid | 0:3edb3708c8c5 | 2965 | #endif |
whismanoid | 0:3edb3708c8c5 | 2966 | #if HAS_analogIn3 |
whismanoid | 0:3edb3708c8c5 | 2967 | case '3': case 0x03: return analogIn3; |
whismanoid | 0:3edb3708c8c5 | 2968 | #endif |
whismanoid | 0:3edb3708c8c5 | 2969 | #if HAS_analogIn4 |
whismanoid | 0:3edb3708c8c5 | 2970 | case '4': case 0x04: return analogIn4; |
whismanoid | 0:3edb3708c8c5 | 2971 | #endif |
whismanoid | 0:3edb3708c8c5 | 2972 | #if HAS_analogIn5 |
whismanoid | 0:3edb3708c8c5 | 2973 | case '5': case 0x05: return analogIn5; |
whismanoid | 0:3edb3708c8c5 | 2974 | #endif |
whismanoid | 0:3edb3708c8c5 | 2975 | #if HAS_analogIn6 |
whismanoid | 0:3edb3708c8c5 | 2976 | case '6': case 0x06: return analogIn6; |
whismanoid | 0:3edb3708c8c5 | 2977 | #endif |
whismanoid | 0:3edb3708c8c5 | 2978 | #if HAS_analogIn7 |
whismanoid | 0:3edb3708c8c5 | 2979 | case '7': case 0x07: return analogIn7; |
whismanoid | 0:3edb3708c8c5 | 2980 | #endif |
whismanoid | 0:3edb3708c8c5 | 2981 | #if HAS_analogIn8 |
whismanoid | 0:3edb3708c8c5 | 2982 | case '8': case 0x08: return analogIn8; |
whismanoid | 0:3edb3708c8c5 | 2983 | #endif |
whismanoid | 0:3edb3708c8c5 | 2984 | #if HAS_analogIn9 |
whismanoid | 0:3edb3708c8c5 | 2985 | case '9': case 0x09: return analogIn9; |
whismanoid | 0:3edb3708c8c5 | 2986 | #endif |
whismanoid | 0:3edb3708c8c5 | 2987 | #if HAS_analogIn10 |
whismanoid | 0:3edb3708c8c5 | 2988 | case 'a': case 0x0a: return analogIn10; |
whismanoid | 0:3edb3708c8c5 | 2989 | #endif |
whismanoid | 0:3edb3708c8c5 | 2990 | #if HAS_analogIn11 |
whismanoid | 0:3edb3708c8c5 | 2991 | case 'b': case 0x0b: return analogIn11; |
whismanoid | 0:3edb3708c8c5 | 2992 | #endif |
whismanoid | 0:3edb3708c8c5 | 2993 | #if HAS_analogIn12 |
whismanoid | 0:3edb3708c8c5 | 2994 | case 'c': case 0x0c: return analogIn12; |
whismanoid | 0:3edb3708c8c5 | 2995 | #endif |
whismanoid | 0:3edb3708c8c5 | 2996 | #if HAS_analogIn13 |
whismanoid | 0:3edb3708c8c5 | 2997 | case 'd': case 0x0d: return analogIn13; |
whismanoid | 0:3edb3708c8c5 | 2998 | #endif |
whismanoid | 0:3edb3708c8c5 | 2999 | #if HAS_analogIn14 |
whismanoid | 0:3edb3708c8c5 | 3000 | case 'e': case 0x0e: return analogIn14; |
whismanoid | 0:3edb3708c8c5 | 3001 | #endif |
whismanoid | 0:3edb3708c8c5 | 3002 | #if HAS_analogIn15 |
whismanoid | 0:3edb3708c8c5 | 3003 | case 'f': case 0x0f: return analogIn15; |
whismanoid | 0:3edb3708c8c5 | 3004 | #endif |
whismanoid | 0:3edb3708c8c5 | 3005 | } |
whismanoid | 0:3edb3708c8c5 | 3006 | } |
whismanoid | 0:3edb3708c8c5 | 3007 | #endif |
whismanoid | 0:3edb3708c8c5 | 3008 | |
whismanoid | 0:3edb3708c8c5 | 3009 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 3010 | const float analogInPin_fullScaleVoltage[] = { |
whismanoid | 0:3edb3708c8c5 | 3011 | # if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 3012 | ADC_FULL_SCALE_VOLTAGE, // analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3013 | ADC_FULL_SCALE_VOLTAGE, // analogIn1 |
whismanoid | 0:3edb3708c8c5 | 3014 | ADC_FULL_SCALE_VOLTAGE, // analogIn2 |
whismanoid | 0:3edb3708c8c5 | 3015 | ADC_FULL_SCALE_VOLTAGE, // analogIn3 |
whismanoid | 0:3edb3708c8c5 | 3016 | ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 3017 | ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 3018 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 3019 | ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 3020 | ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 3021 | ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V |
whismanoid | 0:3edb3708c8c5 | 3022 | ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined? |
whismanoid | 0:3edb3708c8c5 | 3023 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 3024 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 3025 | ADC_FULL_SCALE_VOLTAGE, // analogIn13 |
whismanoid | 0:3edb3708c8c5 | 3026 | ADC_FULL_SCALE_VOLTAGE, // analogIn14 |
whismanoid | 0:3edb3708c8c5 | 3027 | ADC_FULL_SCALE_VOLTAGE // analogIn15 |
whismanoid | 0:3edb3708c8c5 | 3028 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 3029 | ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 3030 | ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 3031 | ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 3032 | ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 3033 | ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 3034 | ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 3035 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 3036 | ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 3037 | ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V |
whismanoid | 0:3edb3708c8c5 | 3038 | ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V |
whismanoid | 0:3edb3708c8c5 | 3039 | ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined? |
whismanoid | 0:3edb3708c8c5 | 3040 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 3041 | ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V |
whismanoid | 0:3edb3708c8c5 | 3042 | ADC_FULL_SCALE_VOLTAGE, // analogIn13 |
whismanoid | 0:3edb3708c8c5 | 3043 | ADC_FULL_SCALE_VOLTAGE, // analogIn14 |
whismanoid | 0:3edb3708c8c5 | 3044 | ADC_FULL_SCALE_VOLTAGE // analogIn15 |
whismanoid | 0:3edb3708c8c5 | 3045 | #elif defined(TARGET_NUCLEO_F446RE) |
whismanoid | 0:3edb3708c8c5 | 3046 | ADC_FULL_SCALE_VOLTAGE, // analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3047 | ADC_FULL_SCALE_VOLTAGE, // analogIn1 |
whismanoid | 0:3edb3708c8c5 | 3048 | ADC_FULL_SCALE_VOLTAGE, // analogIn2 |
whismanoid | 0:3edb3708c8c5 | 3049 | ADC_FULL_SCALE_VOLTAGE, // analogIn3 |
whismanoid | 0:3edb3708c8c5 | 3050 | ADC_FULL_SCALE_VOLTAGE, // analogIn4 |
whismanoid | 0:3edb3708c8c5 | 3051 | ADC_FULL_SCALE_VOLTAGE, // analogIn5 |
whismanoid | 0:3edb3708c8c5 | 3052 | ADC_FULL_SCALE_VOLTAGE, // analogIn6 |
whismanoid | 0:3edb3708c8c5 | 3053 | ADC_FULL_SCALE_VOLTAGE, // analogIn7 |
whismanoid | 0:3edb3708c8c5 | 3054 | ADC_FULL_SCALE_VOLTAGE, // analogIn8 |
whismanoid | 0:3edb3708c8c5 | 3055 | ADC_FULL_SCALE_VOLTAGE, // analogIn9 |
whismanoid | 0:3edb3708c8c5 | 3056 | ADC_FULL_SCALE_VOLTAGE, // analogIn10 |
whismanoid | 0:3edb3708c8c5 | 3057 | ADC_FULL_SCALE_VOLTAGE, // analogIn11 |
whismanoid | 0:3edb3708c8c5 | 3058 | ADC_FULL_SCALE_VOLTAGE, // analogIn12 |
whismanoid | 0:3edb3708c8c5 | 3059 | ADC_FULL_SCALE_VOLTAGE, // analogIn13 |
whismanoid | 0:3edb3708c8c5 | 3060 | ADC_FULL_SCALE_VOLTAGE, // analogIn14 |
whismanoid | 0:3edb3708c8c5 | 3061 | ADC_FULL_SCALE_VOLTAGE // analogIn15 |
whismanoid | 0:3edb3708c8c5 | 3062 | #elif defined(TARGET_NUCLEO_F401RE) |
whismanoid | 0:3edb3708c8c5 | 3063 | ADC_FULL_SCALE_VOLTAGE, // analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3064 | ADC_FULL_SCALE_VOLTAGE, // analogIn1 |
whismanoid | 0:3edb3708c8c5 | 3065 | ADC_FULL_SCALE_VOLTAGE, // analogIn2 |
whismanoid | 0:3edb3708c8c5 | 3066 | ADC_FULL_SCALE_VOLTAGE, // analogIn3 |
whismanoid | 0:3edb3708c8c5 | 3067 | ADC_FULL_SCALE_VOLTAGE, // analogIn4 |
whismanoid | 0:3edb3708c8c5 | 3068 | ADC_FULL_SCALE_VOLTAGE, // analogIn5 |
whismanoid | 0:3edb3708c8c5 | 3069 | ADC_FULL_SCALE_VOLTAGE, // analogIn6 |
whismanoid | 0:3edb3708c8c5 | 3070 | ADC_FULL_SCALE_VOLTAGE, // analogIn7 |
whismanoid | 0:3edb3708c8c5 | 3071 | ADC_FULL_SCALE_VOLTAGE, // analogIn8 |
whismanoid | 0:3edb3708c8c5 | 3072 | ADC_FULL_SCALE_VOLTAGE, // analogIn9 |
whismanoid | 0:3edb3708c8c5 | 3073 | ADC_FULL_SCALE_VOLTAGE, // analogIn10 |
whismanoid | 0:3edb3708c8c5 | 3074 | ADC_FULL_SCALE_VOLTAGE, // analogIn11 |
whismanoid | 0:3edb3708c8c5 | 3075 | ADC_FULL_SCALE_VOLTAGE, // analogIn12 |
whismanoid | 0:3edb3708c8c5 | 3076 | ADC_FULL_SCALE_VOLTAGE, // analogIn13 |
whismanoid | 0:3edb3708c8c5 | 3077 | ADC_FULL_SCALE_VOLTAGE, // analogIn14 |
whismanoid | 0:3edb3708c8c5 | 3078 | ADC_FULL_SCALE_VOLTAGE // analogIn15 |
whismanoid | 0:3edb3708c8c5 | 3079 | //#elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 3080 | #else |
whismanoid | 0:3edb3708c8c5 | 3081 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 3082 | ADC_FULL_SCALE_VOLTAGE, // analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3083 | ADC_FULL_SCALE_VOLTAGE, // analogIn1 |
whismanoid | 0:3edb3708c8c5 | 3084 | ADC_FULL_SCALE_VOLTAGE, // analogIn2 |
whismanoid | 0:3edb3708c8c5 | 3085 | ADC_FULL_SCALE_VOLTAGE, // analogIn3 |
whismanoid | 0:3edb3708c8c5 | 3086 | ADC_FULL_SCALE_VOLTAGE, // analogIn4 |
whismanoid | 0:3edb3708c8c5 | 3087 | ADC_FULL_SCALE_VOLTAGE, // analogIn5 |
whismanoid | 0:3edb3708c8c5 | 3088 | ADC_FULL_SCALE_VOLTAGE, // analogIn6 |
whismanoid | 0:3edb3708c8c5 | 3089 | ADC_FULL_SCALE_VOLTAGE, // analogIn7 |
whismanoid | 0:3edb3708c8c5 | 3090 | ADC_FULL_SCALE_VOLTAGE, // analogIn8 |
whismanoid | 0:3edb3708c8c5 | 3091 | ADC_FULL_SCALE_VOLTAGE, // analogIn9 |
whismanoid | 0:3edb3708c8c5 | 3092 | ADC_FULL_SCALE_VOLTAGE, // analogIn10 |
whismanoid | 0:3edb3708c8c5 | 3093 | ADC_FULL_SCALE_VOLTAGE, // analogIn11 |
whismanoid | 0:3edb3708c8c5 | 3094 | ADC_FULL_SCALE_VOLTAGE, // analogIn12 |
whismanoid | 0:3edb3708c8c5 | 3095 | ADC_FULL_SCALE_VOLTAGE, // analogIn13 |
whismanoid | 0:3edb3708c8c5 | 3096 | ADC_FULL_SCALE_VOLTAGE, // analogIn14 |
whismanoid | 0:3edb3708c8c5 | 3097 | ADC_FULL_SCALE_VOLTAGE // analogIn15 |
whismanoid | 0:3edb3708c8c5 | 3098 | # endif |
whismanoid | 0:3edb3708c8c5 | 3099 | }; |
whismanoid | 0:3edb3708c8c5 | 3100 | #endif |
whismanoid | 0:3edb3708c8c5 | 3101 | |
whismanoid | 0:3edb3708c8c5 | 3102 | // PwmOut pin resource: print the pin index names to microUSBserial |
whismanoid | 0:3edb3708c8c5 | 3103 | #if HAS_pwmDrivers |
whismanoid | 0:3edb3708c8c5 | 3104 | void list_pwmDriverPins(Stream& serialStream) |
whismanoid | 0:3edb3708c8c5 | 3105 | { |
whismanoid | 0:3edb3708c8c5 | 3106 | #if HAS_pwmDriver0 |
whismanoid | 0:3edb3708c8c5 | 3107 | serialStream.printf(" 0"); |
whismanoid | 0:3edb3708c8c5 | 3108 | #endif |
whismanoid | 0:3edb3708c8c5 | 3109 | #if HAS_pwmDriver1 |
whismanoid | 0:3edb3708c8c5 | 3110 | serialStream.printf(" 1"); |
whismanoid | 0:3edb3708c8c5 | 3111 | #endif |
whismanoid | 0:3edb3708c8c5 | 3112 | #if HAS_pwmDriver2 |
whismanoid | 0:3edb3708c8c5 | 3113 | serialStream.printf(" 2"); |
whismanoid | 0:3edb3708c8c5 | 3114 | #endif |
whismanoid | 0:3edb3708c8c5 | 3115 | #if HAS_pwmDriver3 |
whismanoid | 0:3edb3708c8c5 | 3116 | serialStream.printf(" 3"); |
whismanoid | 0:3edb3708c8c5 | 3117 | #endif |
whismanoid | 0:3edb3708c8c5 | 3118 | #if HAS_pwmDriver4 |
whismanoid | 0:3edb3708c8c5 | 3119 | serialStream.printf(" 4"); |
whismanoid | 0:3edb3708c8c5 | 3120 | #endif |
whismanoid | 0:3edb3708c8c5 | 3121 | #if HAS_pwmDriver5 |
whismanoid | 0:3edb3708c8c5 | 3122 | serialStream.printf(" 5"); |
whismanoid | 0:3edb3708c8c5 | 3123 | #endif |
whismanoid | 0:3edb3708c8c5 | 3124 | #if HAS_pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 3125 | serialStream.printf(" 6"); |
whismanoid | 0:3edb3708c8c5 | 3126 | #endif |
whismanoid | 0:3edb3708c8c5 | 3127 | #if HAS_pwmDriver7 |
whismanoid | 0:3edb3708c8c5 | 3128 | serialStream.printf(" 7"); |
whismanoid | 0:3edb3708c8c5 | 3129 | #endif |
whismanoid | 0:3edb3708c8c5 | 3130 | #if HAS_pwmDriver8 |
whismanoid | 0:3edb3708c8c5 | 3131 | serialStream.printf(" 8"); |
whismanoid | 0:3edb3708c8c5 | 3132 | #endif |
whismanoid | 0:3edb3708c8c5 | 3133 | #if HAS_pwmDriver9 |
whismanoid | 0:3edb3708c8c5 | 3134 | serialStream.printf(" 9"); |
whismanoid | 0:3edb3708c8c5 | 3135 | #endif |
whismanoid | 0:3edb3708c8c5 | 3136 | #if HAS_pwmDriver10 |
whismanoid | 0:3edb3708c8c5 | 3137 | serialStream.printf(" a"); |
whismanoid | 0:3edb3708c8c5 | 3138 | #endif |
whismanoid | 0:3edb3708c8c5 | 3139 | #if HAS_pwmDriver11 |
whismanoid | 0:3edb3708c8c5 | 3140 | serialStream.printf(" b"); |
whismanoid | 0:3edb3708c8c5 | 3141 | #endif |
whismanoid | 0:3edb3708c8c5 | 3142 | #if HAS_pwmDriver12 |
whismanoid | 0:3edb3708c8c5 | 3143 | serialStream.printf(" c"); |
whismanoid | 0:3edb3708c8c5 | 3144 | #endif |
whismanoid | 0:3edb3708c8c5 | 3145 | #if HAS_pwmDriver13 |
whismanoid | 0:3edb3708c8c5 | 3146 | serialStream.printf(" d"); |
whismanoid | 0:3edb3708c8c5 | 3147 | #endif |
whismanoid | 0:3edb3708c8c5 | 3148 | #if HAS_pwmDriver14 |
whismanoid | 0:3edb3708c8c5 | 3149 | serialStream.printf(" e"); |
whismanoid | 0:3edb3708c8c5 | 3150 | #endif |
whismanoid | 0:3edb3708c8c5 | 3151 | #if HAS_pwmDriver15 |
whismanoid | 0:3edb3708c8c5 | 3152 | serialStream.printf(" f"); |
whismanoid | 0:3edb3708c8c5 | 3153 | #endif |
whismanoid | 0:3edb3708c8c5 | 3154 | } |
whismanoid | 0:3edb3708c8c5 | 3155 | #endif |
whismanoid | 0:3edb3708c8c5 | 3156 | |
whismanoid | 0:3edb3708c8c5 | 3157 | // PwmOut pin resource: present? |
whismanoid | 0:3edb3708c8c5 | 3158 | #if HAS_pwmDrivers |
whismanoid | 0:3edb3708c8c5 | 3159 | bool has_pwmDriverPin(int cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 3160 | { |
whismanoid | 0:3edb3708c8c5 | 3161 | switch (cPinIndex) |
whismanoid | 0:3edb3708c8c5 | 3162 | { |
whismanoid | 0:3edb3708c8c5 | 3163 | #if HAS_pwmDriver0 |
whismanoid | 0:3edb3708c8c5 | 3164 | case '0': case 0x00: return true; |
whismanoid | 0:3edb3708c8c5 | 3165 | #endif |
whismanoid | 0:3edb3708c8c5 | 3166 | #if HAS_pwmDriver1 |
whismanoid | 0:3edb3708c8c5 | 3167 | case '1': case 0x01: return true; |
whismanoid | 0:3edb3708c8c5 | 3168 | #endif |
whismanoid | 0:3edb3708c8c5 | 3169 | #if HAS_pwmDriver2 |
whismanoid | 0:3edb3708c8c5 | 3170 | case '2': case 0x02: return true; |
whismanoid | 0:3edb3708c8c5 | 3171 | #endif |
whismanoid | 0:3edb3708c8c5 | 3172 | #if HAS_pwmDriver3 |
whismanoid | 0:3edb3708c8c5 | 3173 | case '3': case 0x03: return true; |
whismanoid | 0:3edb3708c8c5 | 3174 | #endif |
whismanoid | 0:3edb3708c8c5 | 3175 | #if HAS_pwmDriver4 |
whismanoid | 0:3edb3708c8c5 | 3176 | case '4': case 0x04: return true; |
whismanoid | 0:3edb3708c8c5 | 3177 | #endif |
whismanoid | 0:3edb3708c8c5 | 3178 | #if HAS_pwmDriver5 |
whismanoid | 0:3edb3708c8c5 | 3179 | case '5': case 0x05: return true; |
whismanoid | 0:3edb3708c8c5 | 3180 | #endif |
whismanoid | 0:3edb3708c8c5 | 3181 | #if HAS_pwmDriver6 |
whismanoid | 0:3edb3708c8c5 | 3182 | case '6': case 0x06: return true; |
whismanoid | 0:3edb3708c8c5 | 3183 | #endif |
whismanoid | 0:3edb3708c8c5 | 3184 | #if HAS_pwmDriver7 |
whismanoid | 0:3edb3708c8c5 | 3185 | case '7': case 0x07: return true; |
whismanoid | 0:3edb3708c8c5 | 3186 | #endif |
whismanoid | 0:3edb3708c8c5 | 3187 | #if HAS_pwmDriver8 |
whismanoid | 0:3edb3708c8c5 | 3188 | case '8': case 0x08: return true; |
whismanoid | 0:3edb3708c8c5 | 3189 | #endif |
whismanoid | 0:3edb3708c8c5 | 3190 | #if HAS_pwmDriver9 |
whismanoid | 0:3edb3708c8c5 | 3191 | case '9': case 0x09: return true; |
whismanoid | 0:3edb3708c8c5 | 3192 | #endif |
whismanoid | 0:3edb3708c8c5 | 3193 | #if HAS_pwmDriver10 |
whismanoid | 0:3edb3708c8c5 | 3194 | case 'a': case 0x0a: return true; |
whismanoid | 0:3edb3708c8c5 | 3195 | #endif |
whismanoid | 0:3edb3708c8c5 | 3196 | #if HAS_pwmDriver11 |
whismanoid | 0:3edb3708c8c5 | 3197 | case 'b': case 0x0b: return true; |
whismanoid | 0:3edb3708c8c5 | 3198 | #endif |
whismanoid | 0:3edb3708c8c5 | 3199 | #if HAS_pwmDriver12 |
whismanoid | 0:3edb3708c8c5 | 3200 | case 'c': case 0x0c: return true; |
whismanoid | 0:3edb3708c8c5 | 3201 | #endif |
whismanoid | 0:3edb3708c8c5 | 3202 | #if HAS_pwmDriver13 |
whismanoid | 0:3edb3708c8c5 | 3203 | case 'd': case 0x0d: return true; |
whismanoid | 0:3edb3708c8c5 | 3204 | #endif |
whismanoid | 0:3edb3708c8c5 | 3205 | #if HAS_pwmDriver14 |
whismanoid | 0:3edb3708c8c5 | 3206 | case 'e': case 0x0e: return true; |
whismanoid | 0:3edb3708c8c5 | 3207 | #endif |
whismanoid | 0:3edb3708c8c5 | 3208 | #if HAS_pwmDriver15 |
whismanoid | 0:3edb3708c8c5 | 3209 | case 'f': case 0x0f: return true; |
whismanoid | 0:3edb3708c8c5 | 3210 | #endif |
whismanoid | 0:3edb3708c8c5 | 3211 | default: |
whismanoid | 0:3edb3708c8c5 | 3212 | return false; |
whismanoid | 0:3edb3708c8c5 | 3213 | } |
whismanoid | 0:3edb3708c8c5 | 3214 | } |
whismanoid | 0:3edb3708c8c5 | 3215 | #endif |
whismanoid | 0:3edb3708c8c5 | 3216 | |
whismanoid | 0:3edb3708c8c5 | 3217 | #if HAS_I2C // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 3218 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3219 | // Search I2C device address list |
whismanoid | 0:3edb3708c8c5 | 3220 | // |
whismanoid | 0:3edb3708c8c5 | 3221 | // @param[in] deviceAddress7First = I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified. |
whismanoid | 0:3edb3708c8c5 | 3222 | // @param[in] deviceAddress7Last = I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified. |
whismanoid | 0:3edb3708c8c5 | 3223 | // @param[in] numDevicesFoundLimit = maximum number of devices to detect before halting search; in case SCL stuck low or pullups missing. |
whismanoid | 0:3edb3708c8c5 | 3224 | // @returns deviceAddress on success; 0 on failure |
whismanoid | 0:3edb3708c8c5 | 3225 | // @post g_I2C_deviceAddress7 is updated with any device that did ACK |
whismanoid | 0:3edb3708c8c5 | 3226 | // |
whismanoid | 0:3edb3708c8c5 | 3227 | void HuntAttachedI2CDevices(CmdLine& cmdLine, uint8_t deviceAddress7First, uint8_t deviceAddress7Last, |
whismanoid | 0:3edb3708c8c5 | 3228 | const uint8_t numDevicesFoundLimit = 20) |
whismanoid | 0:3edb3708c8c5 | 3229 | { |
whismanoid | 0:3edb3708c8c5 | 3230 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 0:3edb3708c8c5 | 3231 | I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 3232 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 3233 | |
whismanoid | 0:3edb3708c8c5 | 3234 | // %IP -- I2C probe |
whismanoid | 0:3edb3708c8c5 | 3235 | // TODO: i2c transfer |
whismanoid | 0:3edb3708c8c5 | 3236 | //const int addr7bit = 0x48; // 7 bit I2C address |
whismanoid | 0:3edb3708c8c5 | 3237 | //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 |
whismanoid | 0:3edb3708c8c5 | 3238 | // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 3239 | // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 3240 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 3241 | // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 3242 | // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 3243 | // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 3244 | // /* 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 | 3245 | // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... |
whismanoid | 0:3edb3708c8c5 | 3246 | |
whismanoid | 0:3edb3708c8c5 | 3247 | //const char probeWriteData[] = { 0x00 }; |
whismanoid | 0:3edb3708c8c5 | 3248 | //int probeWriteDataLength = 1; |
whismanoid | 0:3edb3708c8c5 | 3249 | //bool isRepeatedStart = false; |
whismanoid | 0:3edb3708c8c5 | 3250 | 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 | 3251 | deviceAddress7First, |
whismanoid | 0:3edb3708c8c5 | 3252 | deviceAddress7First << 1, |
whismanoid | 0:3edb3708c8c5 | 3253 | deviceAddress7Last, |
whismanoid | 0:3edb3708c8c5 | 3254 | deviceAddress7Last << 1, |
whismanoid | 0:3edb3708c8c5 | 3255 | numDevicesFoundLimit); // HuntAttachedI2CDevices |
whismanoid | 0:3edb3708c8c5 | 3256 | //~ const int i2cFileDescriptor = i2c_open_adapter(1); |
whismanoid | 0:3edb3708c8c5 | 3257 | uint8_t numDevicesFound = 0; |
whismanoid | 0:3edb3708c8c5 | 3258 | uint8_t last_valid_deviceAddress7 = 0; |
whismanoid | 0:3edb3708c8c5 | 3259 | for (uint8_t deviceAddress7 = deviceAddress7First; deviceAddress7 <= deviceAddress7Last; deviceAddress7++) |
whismanoid | 0:3edb3708c8c5 | 3260 | { |
whismanoid | 0:3edb3708c8c5 | 3261 | //cmdLine.serial().printf(" (0x%2.2X >> 1) ", (deviceAddress7 << 1)); |
whismanoid | 0:3edb3708c8c5 | 3262 | //if (i2c_ioctl_I2C_SLAVE_i2cDeviceAddress7bits(i2cFileDescriptor, deviceAddress7) == 0) |
whismanoid | 0:3edb3708c8c5 | 3263 | int addr8bit = deviceAddress7 * 2; |
whismanoid | 0:3edb3708c8c5 | 3264 | // |
whismanoid | 0:3edb3708c8c5 | 3265 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 3266 | // Returns 0 on success (ack), nonzero on failure (nack) |
whismanoid | 0:3edb3708c8c5 | 3267 | //bool gotACK = (i2cMaster.write (addr8bit, probeWriteData, probeWriteDataLength, isRepeatedStart) == 0); |
whismanoid | 0:3edb3708c8c5 | 3268 | // |
whismanoid | 0:3edb3708c8c5 | 3269 | // SMBusQuick test |
whismanoid | 0:3edb3708c8c5 | 3270 | i2cMaster.start(); |
whismanoid | 0:3edb3708c8c5 | 3271 | // /** Write single byte out on the I2C bus |
whismanoid | 0:3edb3708c8c5 | 3272 | // * |
whismanoid | 0:3edb3708c8c5 | 3273 | // * @param data data to write out on bus |
whismanoid | 0:3edb3708c8c5 | 3274 | // * |
whismanoid | 0:3edb3708c8c5 | 3275 | // * @returns |
whismanoid | 0:3edb3708c8c5 | 3276 | // * '0' - NAK was received |
whismanoid | 0:3edb3708c8c5 | 3277 | // * '1' - ACK was received, |
whismanoid | 0:3edb3708c8c5 | 3278 | // * '2' - timeout |
whismanoid | 0:3edb3708c8c5 | 3279 | // */ |
whismanoid | 0:3edb3708c8c5 | 3280 | // int write(int data); |
whismanoid | 0:3edb3708c8c5 | 3281 | int writeStatus = i2cMaster.write(addr8bit); |
whismanoid | 0:3edb3708c8c5 | 3282 | i2cMaster.stop(); |
whismanoid | 0:3edb3708c8c5 | 3283 | bool gotACK = (writeStatus == 1); // ACK was received |
whismanoid | 0:3edb3708c8c5 | 3284 | if (writeStatus == 2) // timeout |
whismanoid | 0:3edb3708c8c5 | 3285 | { |
whismanoid | 0:3edb3708c8c5 | 3286 | cmdLine.serial().printf("- timeout\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3287 | } |
whismanoid | 0:3edb3708c8c5 | 3288 | // |
whismanoid | 0:3edb3708c8c5 | 3289 | if (gotACK) |
whismanoid | 0:3edb3708c8c5 | 3290 | { |
whismanoid | 0:3edb3708c8c5 | 3291 | // @return status; error if (fileDescriptor < 0) |
whismanoid | 0:3edb3708c8c5 | 3292 | cmdLine.serial().printf("+ ADDR=0x%2.2X (0x%2.2X >> 1) ACK\r\n", deviceAddress7, (deviceAddress7 << 1)); |
whismanoid | 0:3edb3708c8c5 | 3293 | numDevicesFound++; |
whismanoid | 0:3edb3708c8c5 | 3294 | last_valid_deviceAddress7 = deviceAddress7; |
whismanoid | 0:3edb3708c8c5 | 3295 | if (numDevicesFound > numDevicesFoundLimit) |
whismanoid | 0:3edb3708c8c5 | 3296 | { |
whismanoid | 0:3edb3708c8c5 | 3297 | break; |
whismanoid | 0:3edb3708c8c5 | 3298 | } |
whismanoid | 0:3edb3708c8c5 | 3299 | continue; |
whismanoid | 0:3edb3708c8c5 | 3300 | } |
whismanoid | 0:3edb3708c8c5 | 3301 | } |
whismanoid | 0:3edb3708c8c5 | 3302 | if (numDevicesFound == 0) |
whismanoid | 0:3edb3708c8c5 | 3303 | { |
whismanoid | 0:3edb3708c8c5 | 3304 | cmdLine.serial().printf("- No I2C devices found. Maybe SCL/SDA are swapped?\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3305 | } |
whismanoid | 0:3edb3708c8c5 | 3306 | else if (numDevicesFound > numDevicesFoundLimit) |
whismanoid | 0:3edb3708c8c5 | 3307 | { |
whismanoid | 0:3edb3708c8c5 | 3308 | cmdLine.serial().printf("- Many I2C devices found. SCL/SDA missing pullup resistors? SCL stuck low?\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3309 | } |
whismanoid | 0:3edb3708c8c5 | 3310 | else |
whismanoid | 0:3edb3708c8c5 | 3311 | { |
whismanoid | 0:3edb3708c8c5 | 3312 | //~ i2c_ioctl_I2C_SLAVE_i2cDeviceAddress7bits(i2cFileDescriptor, last_valid_deviceAddress7); |
whismanoid | 0:3edb3708c8c5 | 3313 | g_I2C_deviceAddress7 = last_valid_deviceAddress7; |
whismanoid | 0:3edb3708c8c5 | 3314 | } |
whismanoid | 0:3edb3708c8c5 | 3315 | //~ i2c_close(i2cFileDescriptor); |
whismanoid | 0:3edb3708c8c5 | 3316 | } |
whismanoid | 0:3edb3708c8c5 | 3317 | #endif // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 3318 | |
whismanoid | 0:3edb3708c8c5 | 3319 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3320 | // periodic interrupt timer onTimerTick handler triggered by Ticker |
whismanoid | 0:3edb3708c8c5 | 3321 | // analogIn0 (MAX32630:AIN_4 = AIN0 / 5.0) controls angular speed |
whismanoid | 0:3edb3708c8c5 | 3322 | // analogIn1 (MAX32630:AIN_5 = AIN1 / 5.0) controls PWM duty cycle |
whismanoid | 0:3edb3708c8c5 | 3323 | // note: measured 500ns overhead for MAX32630FTHR digitalInOut1.write(0); digitalInOut1.write(1); |
whismanoid | 0:3edb3708c8c5 | 3324 | #if USE_PERIODIC_TIMER |
whismanoid | 0:3edb3708c8c5 | 3325 | void onTimerTick() { |
whismanoid | 0:3edb3708c8c5 | 3326 | } // onTimerTick |
whismanoid | 0:3edb3708c8c5 | 3327 | #endif |
whismanoid | 0:3edb3708c8c5 | 3328 | |
whismanoid | 0:3edb3708c8c5 | 3329 | #if USE_PERIODIC_TIMER |
whismanoid | 0:3edb3708c8c5 | 3330 | // periodic interrupt timer command handlers -- enable timer |
whismanoid | 0:3edb3708c8c5 | 3331 | void cmd_TE() |
whismanoid | 0:3edb3708c8c5 | 3332 | { |
whismanoid | 0:3edb3708c8c5 | 3333 | //us_timestamp_t interval_usec = 100000; // 100ms |
whismanoid | 0:3edb3708c8c5 | 3334 | periodicInterruptTimer_interval_usec = 100000; // 100ms |
whismanoid | 0:3edb3708c8c5 | 3335 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 3336 | DAPLINKserial.printf(" Timer Enable %d us\r\n", periodicInterruptTimer_interval_usec); |
whismanoid | 0:3edb3708c8c5 | 3337 | # endif |
whismanoid | 0:3edb3708c8c5 | 3338 | microUSBserial.printf(" Timer Enable %d us", periodicInterruptTimer_interval_usec); |
whismanoid | 0:3edb3708c8c5 | 3339 | periodicInterruptTimer.attach_us(&onTimerTick, periodicInterruptTimer_interval_usec); |
whismanoid | 0:3edb3708c8c5 | 3340 | // -- periodicInterruptTimer.attach(&onTimerTick, interval_sec); // the address of the function to be attached (onTimerTick) and the interval (2 seconds) |
whismanoid | 0:3edb3708c8c5 | 3341 | // -- periodicInterruptTimer.attach_us(&onTimerTick, interval_usec); // the address of the function to be attached (onTimerTick) and the interval (2 seconds) |
whismanoid | 0:3edb3708c8c5 | 3342 | // -- periodicInterruptTimer.attach(Callback<void()> func, float t); |
whismanoid | 0:3edb3708c8c5 | 3343 | // -- periodicInterruptTimer.attach_us(Callback<void()> func, us_timestamp_t t); |
whismanoid | 0:3edb3708c8c5 | 3344 | // TODO1: cmd_T add cSubCommand to change interval of Ticker periodic interrupt timer |
whismanoid | 0:3edb3708c8c5 | 3345 | } |
whismanoid | 0:3edb3708c8c5 | 3346 | #endif |
whismanoid | 0:3edb3708c8c5 | 3347 | |
whismanoid | 0:3edb3708c8c5 | 3348 | #if USE_PERIODIC_TIMER |
whismanoid | 0:3edb3708c8c5 | 3349 | // periodic interrupt timer command handlers -- disable timer |
whismanoid | 0:3edb3708c8c5 | 3350 | void cmd_TD() |
whismanoid | 0:3edb3708c8c5 | 3351 | { |
whismanoid | 0:3edb3708c8c5 | 3352 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 3353 | DAPLINKserial.printf(" Timer Disable\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3354 | # endif |
whismanoid | 0:3edb3708c8c5 | 3355 | microUSBserial.printf(" Timer Disable "); |
whismanoid | 0:3edb3708c8c5 | 3356 | periodicInterruptTimer.detach(); // Detach the function |
whismanoid | 0:3edb3708c8c5 | 3357 | } |
whismanoid | 0:3edb3708c8c5 | 3358 | #endif |
whismanoid | 0:3edb3708c8c5 | 3359 | |
whismanoid | 0:3edb3708c8c5 | 3360 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3361 | // When user presses button BUTTON1, perform a demo configuration |
whismanoid | 0:3edb3708c8c5 | 3362 | #if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 3363 | void onButton1FallingEdge(void) |
whismanoid | 0:3edb3708c8c5 | 3364 | { |
whismanoid | 0:3edb3708c8c5 | 3365 | void SelfTest(CmdLine & cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3366 | |
whismanoid | 0:3edb3708c8c5 | 3367 | // TODO1: BUTTON1 demo configuration LED blink |
whismanoid | 0:3edb3708c8c5 | 3368 | //~ rgb_led.red(); // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 3369 | //~ rgb_led.green(); // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 3370 | //~ rgb_led.blue(); // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 3371 | //~ rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 3372 | //~ rgb_led.cyan(); // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 3373 | //~ rgb_led.magenta(); // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 3374 | //~ rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3375 | //~ rgb_led.black(); // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 3376 | //~ led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3377 | //~ rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3378 | //~ ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 3379 | //~ led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 3380 | //~ rgb_led.black(); // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 3381 | //~ ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 3382 | //~ led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3383 | //~ rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3384 | //~ ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 3385 | //~ led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 3386 | //~ rgb_led.black(); // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 3387 | //~ ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 3388 | //~ rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3389 | |
whismanoid | 0:3edb3708c8c5 | 3390 | #if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 3391 | SelfTest(cmdLine_microUSBserial); |
whismanoid | 0:3edb3708c8c5 | 3392 | #elif HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 3393 | SelfTest(cmdLine_DAPLINKserial); |
whismanoid | 0:3edb3708c8c5 | 3394 | #endif |
whismanoid | 0:3edb3708c8c5 | 3395 | |
whismanoid | 0:3edb3708c8c5 | 3396 | #if 0 // APPLICATION_MAX5715 // onButton1FallingEdge BUTTON1 demo configuration MAX5715BOB |
whismanoid | 0:3edb3708c8c5 | 3397 | //~ cmdLine.serial().printf("MAX5715_REF(REF_AlwaysOn_2V500)"); |
whismanoid | 0:3edb3708c8c5 | 3398 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); |
whismanoid | 0:3edb3708c8c5 | 3399 | |
whismanoid | 0:3edb3708c8c5 | 3400 | uint16_t code = 4095; |
whismanoid | 0:3edb3708c8c5 | 3401 | //~ cmdLine.serial().printf("CODEallLOADall code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 3402 | g_MAX5715_device.CODEallLOADall(code); |
whismanoid | 0:3edb3708c8c5 | 3403 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 3404 | |
whismanoid | 0:3edb3708c8c5 | 3405 | } |
whismanoid | 0:3edb3708c8c5 | 3406 | #endif // HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 3407 | |
whismanoid | 0:3edb3708c8c5 | 3408 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3409 | // When user presses button BUTTON2, perform a demo configuration |
whismanoid | 0:3edb3708c8c5 | 3410 | #if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 3411 | void onButton2FallingEdge(void) |
whismanoid | 0:3edb3708c8c5 | 3412 | { |
whismanoid | 0:3edb3708c8c5 | 3413 | // TODO1: BUTTON2 demo configuration LED blink |
whismanoid | 0:3edb3708c8c5 | 3414 | //~ led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3415 | //~ rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3416 | // ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 3417 | // led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 3418 | //~ rgb_led.green(); // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 3419 | // ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 3420 | // led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3421 | //~ rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3422 | // ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 3423 | // led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 3424 | //~ rgb_led.green(); // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 3425 | // ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 3426 | |
whismanoid | 0:3edb3708c8c5 | 3427 | #if APPLICATION_MAX5715 // onButton2FallingEdge BUTTON2 demo configuration MAX5715BOB |
whismanoid | 0:3edb3708c8c5 | 3428 | //~ cmdLine.serial().printf("MAX5715_REF(REF_AlwaysOn_2V048)"); |
whismanoid | 0:3edb3708c8c5 | 3429 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048); |
whismanoid | 0:3edb3708c8c5 | 3430 | // |
whismanoid | 0:3edb3708c8c5 | 3431 | uint16_t ch = 0; |
whismanoid | 0:3edb3708c8c5 | 3432 | uint16_t code = 0xccc; |
whismanoid | 0:3edb3708c8c5 | 3433 | //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 3434 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 3435 | // |
whismanoid | 0:3edb3708c8c5 | 3436 | ch = 1; |
whismanoid | 0:3edb3708c8c5 | 3437 | code = 0x800; |
whismanoid | 0:3edb3708c8c5 | 3438 | //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 3439 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 3440 | // |
whismanoid | 0:3edb3708c8c5 | 3441 | ch = 2; |
whismanoid | 0:3edb3708c8c5 | 3442 | code = 0x666; |
whismanoid | 0:3edb3708c8c5 | 3443 | //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 3444 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 3445 | // |
whismanoid | 0:3edb3708c8c5 | 3446 | ch = 3; |
whismanoid | 0:3edb3708c8c5 | 3447 | code = 0xFFF; |
whismanoid | 0:3edb3708c8c5 | 3448 | //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 3449 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 3450 | #elif APPLICATION_MAX11131 // onButton2FallingEdge BUTTON2 demo configuration MAX11131BOB |
whismanoid | 0:3edb3708c8c5 | 3451 | // TODO1: demo |
whismanoid | 0:3edb3708c8c5 | 3452 | // MAX11131 > 4 |
whismanoid | 0:3edb3708c8c5 | 3453 | // ScanStandardExternalClock ch=9 pm=0 id=1 |
whismanoid | 0:3edb3708c8c5 | 3454 | // ScanRead_nWords_chanID nWords=10 |
whismanoid | 0:3edb3708c8c5 | 3455 | // ch=0 xu=2964 = 0x0b94 = 1.8091V |
whismanoid | 0:3edb3708c8c5 | 3456 | // ch=1 xu=2227 = 0x08b3 = 1.3593V |
whismanoid | 0:3edb3708c8c5 | 3457 | // ch=2 xu=1570 = 0x0622 = 0.9583V |
whismanoid | 0:3edb3708c8c5 | 3458 | // ch=3 xu=865 = 0x0361 = 0.5280V |
whismanoid | 0:3edb3708c8c5 | 3459 | // ch=4 xu=630 = 0x0276 = 0.3845V |
whismanoid | 0:3edb3708c8c5 | 3460 | // ch=5 xu=594 = 0x0252 = 0.3625V |
whismanoid | 0:3edb3708c8c5 | 3461 | // ch=6 xu=461 = 0x01cd = 0.2814V |
whismanoid | 0:3edb3708c8c5 | 3462 | // ch=7 xu=364 = 0x016c = 0.2222V |
whismanoid | 0:3edb3708c8c5 | 3463 | // ch=8 xu=480 = 0x01e0 = 0.2930V |
whismanoid | 0:3edb3708c8c5 | 3464 | // ch=9 xu=616 = 0x0268 = 0.3760V |
whismanoid | 0:3edb3708c8c5 | 3465 | g_MAX11131_device.channelNumber_0_15 = 9; |
whismanoid | 0:3edb3708c8c5 | 3466 | g_MAX11131_device.PowerManagement_0_2 = 0; |
whismanoid | 0:3edb3708c8c5 | 3467 | g_MAX11131_device.chan_id_0_1 = 1; |
whismanoid | 0:3edb3708c8c5 | 3468 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 3469 | // |
whismanoid | 0:3edb3708c8c5 | 3470 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 3471 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 3472 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 3473 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 3474 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 3475 | // |
whismanoid | 0:3edb3708c8c5 | 3476 | // TODO: compare with mbed/Arduino AIN0-AIN3 |
whismanoid | 0:3edb3708c8c5 | 3477 | // |
whismanoid | 0:3edb3708c8c5 | 3478 | #elif APPLICATION_MAX5171 // onButton2FallingEdge BUTTON2 demo configuration MAX5171BOB |
whismanoid | 0:3edb3708c8c5 | 3479 | // TODO: demo |
whismanoid | 0:3edb3708c8c5 | 3480 | uint16_t code = 0xccc; |
whismanoid | 0:3edb3708c8c5 | 3481 | g_MAX5171_device.CODE(code); |
whismanoid | 0:3edb3708c8c5 | 3482 | #elif APPLICATION_MAX11410 // onButton2FallingEdge BUTTON2 demo configuration MAX11410BOB |
whismanoid | 0:3edb3708c8c5 | 3483 | // TODO: demo |
whismanoid | 0:3edb3708c8c5 | 3484 | g_MAX11410_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 3485 | #elif APPLICATION_MAX12345 // onButton2FallingEdge BUTTON2 demo configuration MAX12345BOB |
whismanoid | 0:3edb3708c8c5 | 3486 | // TODO: demo |
whismanoid | 0:3edb3708c8c5 | 3487 | g_MAX12345_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 3488 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 3489 | rgb_led.blue(); // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 3490 | |
whismanoid | 0:3edb3708c8c5 | 3491 | } |
whismanoid | 0:3edb3708c8c5 | 3492 | #endif // HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 3493 | |
whismanoid | 0:3edb3708c8c5 | 3494 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3495 | // TODO1: use MaximTinyTester encapsulate SelfTest support functions |
whismanoid | 0:3edb3708c8c5 | 3496 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3497 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3498 | int g_SelfTest_nPass = 0; // PASS test counter used by SelfTest() |
whismanoid | 0:3edb3708c8c5 | 3499 | int g_SelfTest_nFail = 0; // FAIL test counter used by SelfTest() |
whismanoid | 0:3edb3708c8c5 | 3500 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3501 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3502 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3503 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3504 | void SelfTest_PASS(CmdLine& cmdLine) |
whismanoid | 0:3edb3708c8c5 | 3505 | { |
whismanoid | 0:3edb3708c8c5 | 3506 | ++g_SelfTest_nPass; |
whismanoid | 0:3edb3708c8c5 | 3507 | cmdLine.serial().printf("\r\n+PASS "); |
whismanoid | 0:3edb3708c8c5 | 3508 | } |
whismanoid | 0:3edb3708c8c5 | 3509 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3510 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3511 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3512 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3513 | void SelfTest_FAIL(CmdLine& cmdLine) |
whismanoid | 0:3edb3708c8c5 | 3514 | { |
whismanoid | 0:3edb3708c8c5 | 3515 | ++g_SelfTest_nFail; |
whismanoid | 0:3edb3708c8c5 | 3516 | cmdLine.serial().printf("\r\n-FAIL "); |
whismanoid | 0:3edb3708c8c5 | 3517 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 3518 | rgb_led.red(); // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 3519 | //~ rgb_led.green(); // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 3520 | //~ rgb_led.blue(); // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 3521 | //~ rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 3522 | //~ rgb_led.cyan(); // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 3523 | //~ rgb_led.magenta(); // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 3524 | //~ rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3525 | //~ rgb_led.black(); // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 3526 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 3527 | } |
whismanoid | 0:3edb3708c8c5 | 3528 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3529 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3530 | void SelfTest_print_DACCodeOfVoltage(CmdLine& cmdLine, double voltageV) |
whismanoid | 0:3edb3708c8c5 | 3531 | { |
whismanoid | 0:3edb3708c8c5 | 3532 | cmdLine.serial().printf("DACCodeOfVoltage(%6.4fV)", voltageV); |
whismanoid | 0:3edb3708c8c5 | 3533 | // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001 |
whismanoid | 0:3edb3708c8c5 | 3534 | // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001 |
whismanoid | 0:3edb3708c8c5 | 3535 | //~ dtostrf(voltageV, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3536 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3537 | //~ cmdLine.serial().printf("V)"); |
whismanoid | 0:3edb3708c8c5 | 3538 | } |
whismanoid | 0:3edb3708c8c5 | 3539 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3540 | #if APPLICATION_MAX5715 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 3541 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3542 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3543 | void SelfTest_DACCodeOfVoltage_Expect(CmdLine& cmdLine, double voltageV, uint16_t expect_result) |
whismanoid | 0:3edb3708c8c5 | 3544 | { |
whismanoid | 0:3edb3708c8c5 | 3545 | uint16_t actual_result = g_MAX5715_device.DACCodeOfVoltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3546 | if (actual_result != expect_result) |
whismanoid | 0:3edb3708c8c5 | 3547 | { |
whismanoid | 0:3edb3708c8c5 | 3548 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3549 | SelfTest_print_DACCodeOfVoltage(cmdLine, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3550 | cmdLine.serial().printf(" expect %d", expect_result); |
whismanoid | 0:3edb3708c8c5 | 3551 | cmdLine.serial().printf(" but got %d", actual_result); |
whismanoid | 0:3edb3708c8c5 | 3552 | } |
whismanoid | 0:3edb3708c8c5 | 3553 | else |
whismanoid | 0:3edb3708c8c5 | 3554 | { |
whismanoid | 0:3edb3708c8c5 | 3555 | SelfTest_PASS(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3556 | SelfTest_print_DACCodeOfVoltage(cmdLine, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3557 | cmdLine.serial().printf(" expect %d", expect_result); |
whismanoid | 0:3edb3708c8c5 | 3558 | } |
whismanoid | 0:3edb3708c8c5 | 3559 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3560 | } |
whismanoid | 0:3edb3708c8c5 | 3561 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 3562 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3563 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3564 | #if APPLICATION_MAX5171 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 3565 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3566 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3567 | void SelfTest_DACCodeOfVoltage_Expect(CmdLine& cmdLine, double voltageV, uint16_t expect_result) |
whismanoid | 0:3edb3708c8c5 | 3568 | { |
whismanoid | 0:3edb3708c8c5 | 3569 | uint16_t actual_result = g_MAX5171_device.DACCodeOfVoltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3570 | if (actual_result != expect_result) |
whismanoid | 0:3edb3708c8c5 | 3571 | { |
whismanoid | 0:3edb3708c8c5 | 3572 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3573 | SelfTest_print_DACCodeOfVoltage(cmdLine, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3574 | cmdLine.serial().printf(" expect %d", expect_result); |
whismanoid | 0:3edb3708c8c5 | 3575 | cmdLine.serial().printf(" but got %d", actual_result); |
whismanoid | 0:3edb3708c8c5 | 3576 | } |
whismanoid | 0:3edb3708c8c5 | 3577 | else |
whismanoid | 0:3edb3708c8c5 | 3578 | { |
whismanoid | 0:3edb3708c8c5 | 3579 | SelfTest_PASS(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3580 | SelfTest_print_DACCodeOfVoltage(cmdLine, voltageV); |
whismanoid | 0:3edb3708c8c5 | 3581 | cmdLine.serial().printf(" expect %d", expect_result); |
whismanoid | 0:3edb3708c8c5 | 3582 | } |
whismanoid | 0:3edb3708c8c5 | 3583 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3584 | } |
whismanoid | 0:3edb3708c8c5 | 3585 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3586 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 3587 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3588 | #if APPLICATION_MAX5715 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 3589 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3590 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3591 | void SelfTest_print_VoltageOfCode(CmdLine& cmdLine, uint16_t value_u12) |
whismanoid | 0:3edb3708c8c5 | 3592 | { |
whismanoid | 0:3edb3708c8c5 | 3593 | cmdLine.serial().printf("VoltageOfCode(%d)", value_u12); |
whismanoid | 0:3edb3708c8c5 | 3594 | //~ dtostrf(voltageV, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3595 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3596 | //~ cmdLine.serial().printf(")"); |
whismanoid | 0:3edb3708c8c5 | 3597 | } |
whismanoid | 0:3edb3708c8c5 | 3598 | /* SelfTest_VoltageOfCode_Expect |
whismanoid | 0:3edb3708c8c5 | 3599 | * |
whismanoid | 0:3edb3708c8c5 | 3600 | * TODO: document this function |
whismanoid | 0:3edb3708c8c5 | 3601 | * This header was inserted by uncrustify; see uncrustify_func_header.txt. |
whismanoid | 0:3edb3708c8c5 | 3602 | * |
whismanoid | 0:3edb3708c8c5 | 3603 | */ |
whismanoid | 0:3edb3708c8c5 | 3604 | void SelfTest_VoltageOfCode_Expect(CmdLine& cmdLine, uint16_t value_u12, double expect_result) |
whismanoid | 0:3edb3708c8c5 | 3605 | { |
whismanoid | 0:3edb3708c8c5 | 3606 | double actual_result = g_MAX5715_device.VoltageOfCode(value_u12); |
whismanoid | 0:3edb3708c8c5 | 3607 | double err_result = (actual_result - expect_result); |
whismanoid | 0:3edb3708c8c5 | 3608 | double one_LSB = (g_MAX5715_device.VRef / 4095); // 12-bit DAC FS |
whismanoid | 0:3edb3708c8c5 | 3609 | double err_threshold = one_LSB; |
whismanoid | 0:3edb3708c8c5 | 3610 | if (( -err_threshold < err_result) && ( err_result < err_threshold)) |
whismanoid | 0:3edb3708c8c5 | 3611 | { |
whismanoid | 0:3edb3708c8c5 | 3612 | SelfTest_PASS(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3613 | SelfTest_print_VoltageOfCode(cmdLine, value_u12); |
whismanoid | 0:3edb3708c8c5 | 3614 | cmdLine.serial().printf(" expect %6.6f", expect_result); |
whismanoid | 0:3edb3708c8c5 | 3615 | //~ dtostrf(expect_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3616 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3617 | } |
whismanoid | 0:3edb3708c8c5 | 3618 | else |
whismanoid | 0:3edb3708c8c5 | 3619 | { |
whismanoid | 0:3edb3708c8c5 | 3620 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3621 | SelfTest_print_VoltageOfCode(cmdLine, value_u12); |
whismanoid | 0:3edb3708c8c5 | 3622 | cmdLine.serial().printf(" expect %6.6f", expect_result); |
whismanoid | 0:3edb3708c8c5 | 3623 | //~ dtostrf(expect_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3624 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3625 | cmdLine.serial().printf(" but got %6.6f", actual_result); |
whismanoid | 0:3edb3708c8c5 | 3626 | //~ dtostrf(actual_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3627 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3628 | cmdLine.serial().printf(" err=%6.6f", err_result); |
whismanoid | 0:3edb3708c8c5 | 3629 | //~ dtostrf( err_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3630 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3631 | } |
whismanoid | 0:3edb3708c8c5 | 3632 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3633 | } |
whismanoid | 0:3edb3708c8c5 | 3634 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3635 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 3636 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3637 | #if APPLICATION_MAX5171 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 3638 | void SelfTest_print_VoltageOfCode(CmdLine& cmdLine, uint16_t value_u14) |
whismanoid | 0:3edb3708c8c5 | 3639 | { |
whismanoid | 0:3edb3708c8c5 | 3640 | cmdLine.serial().printf("VoltageOfCode(%d)", value_u14); |
whismanoid | 0:3edb3708c8c5 | 3641 | } |
whismanoid | 0:3edb3708c8c5 | 3642 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3643 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3644 | /* SelfTest_VoltageOfCode_Expect |
whismanoid | 0:3edb3708c8c5 | 3645 | * |
whismanoid | 0:3edb3708c8c5 | 3646 | * TODO: document this function |
whismanoid | 0:3edb3708c8c5 | 3647 | * This header was inserted by uncrustify; see uncrustify_func_header.txt. |
whismanoid | 0:3edb3708c8c5 | 3648 | * |
whismanoid | 0:3edb3708c8c5 | 3649 | */ |
whismanoid | 0:3edb3708c8c5 | 3650 | void SelfTest_VoltageOfCode_Expect(CmdLine& cmdLine, uint16_t value_u14, double expect_result) |
whismanoid | 0:3edb3708c8c5 | 3651 | { |
whismanoid | 0:3edb3708c8c5 | 3652 | double actual_result = g_MAX5171_device.VoltageOfCode(value_u14); |
whismanoid | 0:3edb3708c8c5 | 3653 | double err_result = (actual_result - expect_result); |
whismanoid | 0:3edb3708c8c5 | 3654 | double one_LSB = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS |
whismanoid | 0:3edb3708c8c5 | 3655 | double err_threshold = one_LSB; |
whismanoid | 0:3edb3708c8c5 | 3656 | if (( -err_threshold < err_result) && ( err_result < err_threshold)) |
whismanoid | 0:3edb3708c8c5 | 3657 | { |
whismanoid | 0:3edb3708c8c5 | 3658 | SelfTest_PASS(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3659 | SelfTest_print_VoltageOfCode(cmdLine, value_u14); |
whismanoid | 0:3edb3708c8c5 | 3660 | cmdLine.serial().printf(" expect %6.6f", expect_result); |
whismanoid | 0:3edb3708c8c5 | 3661 | //~ dtostrf(expect_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3662 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3663 | } |
whismanoid | 0:3edb3708c8c5 | 3664 | else |
whismanoid | 0:3edb3708c8c5 | 3665 | { |
whismanoid | 0:3edb3708c8c5 | 3666 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3667 | SelfTest_print_VoltageOfCode(cmdLine, value_u14); |
whismanoid | 0:3edb3708c8c5 | 3668 | cmdLine.serial().printf(" expect %6.6f", expect_result); |
whismanoid | 0:3edb3708c8c5 | 3669 | //~ dtostrf(expect_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3670 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3671 | cmdLine.serial().printf(" but got %6.6f", actual_result); |
whismanoid | 0:3edb3708c8c5 | 3672 | //~ dtostrf(actual_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3673 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3674 | cmdLine.serial().printf(" err=%6.6f", err_result); |
whismanoid | 0:3edb3708c8c5 | 3675 | //~ dtostrf( err_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3676 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3677 | } |
whismanoid | 0:3edb3708c8c5 | 3678 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3679 | } |
whismanoid | 0:3edb3708c8c5 | 3680 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3681 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 3682 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3683 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3684 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3685 | bool SelfTest_AnalogInput_Expect_ch_V(CmdLine& cmdLine, int pinIndex, double expect_result, |
whismanoid | 0:3edb3708c8c5 | 3686 | double err_threshold = 0.030) |
whismanoid | 0:3edb3708c8c5 | 3687 | { |
whismanoid | 0:3edb3708c8c5 | 3688 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3689 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 0:3edb3708c8c5 | 3690 | // low range channels AIN0, AIN1, AIN2, AIN3 |
whismanoid | 0:3edb3708c8c5 | 3691 | int pinIndexL = ((pinIndex >= 4) ? (pinIndex - 4) : (pinIndex + 0)); |
whismanoid | 0:3edb3708c8c5 | 3692 | // high range channels AIN4, AIN5 |
whismanoid | 0:3edb3708c8c5 | 3693 | int pinIndexH = ((pinIndex >= 4) ? (pinIndex + 0) : (pinIndex + 4)); |
whismanoid | 0:3edb3708c8c5 | 3694 | // |
whismanoid | 0:3edb3708c8c5 | 3695 | // low range channels AIN0, AIN1, AIN2, AIN3 |
whismanoid | 0:3edb3708c8c5 | 3696 | int cPinIndexL = '0' + pinIndexL; |
whismanoid | 0:3edb3708c8c5 | 3697 | AnalogIn& analogInPinL = find_analogInPin(cPinIndexL); |
whismanoid | 0:3edb3708c8c5 | 3698 | float adc_full_scale_voltageL = analogInPin_fullScaleVoltage[pinIndexL]; |
whismanoid | 0:3edb3708c8c5 | 3699 | float normValueL_0_1 = analogInPinL.read(); |
whismanoid | 0:3edb3708c8c5 | 3700 | // |
whismanoid | 0:3edb3708c8c5 | 3701 | // high range channels AIN4, AIN5 |
whismanoid | 0:3edb3708c8c5 | 3702 | int cPinIndexH = '0' + pinIndexH; |
whismanoid | 0:3edb3708c8c5 | 3703 | AnalogIn& analogInPinH = find_analogInPin(cPinIndexH); |
whismanoid | 0:3edb3708c8c5 | 3704 | float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH]; |
whismanoid | 0:3edb3708c8c5 | 3705 | float normValueH_0_1 = analogInPinH.read(); |
whismanoid | 0:3edb3708c8c5 | 3706 | // |
whismanoid | 0:3edb3708c8c5 | 3707 | double actual_result = (pinIndex >= 4) |
whismanoid | 0:3edb3708c8c5 | 3708 | ? (normValueH_0_1 * adc_full_scale_voltageH) |
whismanoid | 0:3edb3708c8c5 | 3709 | : (normValueL_0_1 * adc_full_scale_voltageL); |
whismanoid | 0:3edb3708c8c5 | 3710 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3711 | // Platform board uses simple analog inputs |
whismanoid | 0:3edb3708c8c5 | 3712 | int cPinIndex = '0' + pinIndex; |
whismanoid | 0:3edb3708c8c5 | 3713 | AnalogIn& analogInPin = find_analogInPin(cPinIndex); |
whismanoid | 0:3edb3708c8c5 | 3714 | float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; |
whismanoid | 0:3edb3708c8c5 | 3715 | float normValue_0_1 = analogInPin.read(); |
whismanoid | 0:3edb3708c8c5 | 3716 | double actual_result = normValue_0_1 * adc_full_scale_voltage; |
whismanoid | 0:3edb3708c8c5 | 3717 | #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3718 | double err_result = (actual_result - expect_result); |
whismanoid | 0:3edb3708c8c5 | 3719 | //double err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 3720 | if (( -err_threshold < err_result) && ( err_result < err_threshold)) |
whismanoid | 0:3edb3708c8c5 | 3721 | { |
whismanoid | 0:3edb3708c8c5 | 3722 | SelfTest_PASS(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3723 | //~ SelfTest_print_VoltageOfCode(cmdLine, value_u12); |
whismanoid | 0:3edb3708c8c5 | 3724 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3725 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 0:3edb3708c8c5 | 3726 | cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV ", |
whismanoid | 0:3edb3708c8c5 | 3727 | cPinIndexL, |
whismanoid | 0:3edb3708c8c5 | 3728 | normValueL_0_1 * 100.0, |
whismanoid | 0:3edb3708c8c5 | 3729 | normValueL_0_1 * adc_full_scale_voltageL, |
whismanoid | 0:3edb3708c8c5 | 3730 | cPinIndexH, |
whismanoid | 0:3edb3708c8c5 | 3731 | normValueH_0_1 * 100.0, |
whismanoid | 0:3edb3708c8c5 | 3732 | normValueH_0_1 * adc_full_scale_voltageH |
whismanoid | 0:3edb3708c8c5 | 3733 | ); |
whismanoid | 0:3edb3708c8c5 | 3734 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3735 | // Platform board uses simple analog inputs |
whismanoid | 0:3edb3708c8c5 | 3736 | cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV ", |
whismanoid | 0:3edb3708c8c5 | 3737 | cPinIndex, |
whismanoid | 0:3edb3708c8c5 | 3738 | normValue_0_1 * 100.0, |
whismanoid | 0:3edb3708c8c5 | 3739 | normValue_0_1 * adc_full_scale_voltage |
whismanoid | 0:3edb3708c8c5 | 3740 | ); |
whismanoid | 0:3edb3708c8c5 | 3741 | #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3742 | // |
whismanoid | 0:3edb3708c8c5 | 3743 | cmdLine.serial().printf(" expect %6.6f +/- %6.6f", expect_result, err_threshold); |
whismanoid | 0:3edb3708c8c5 | 3744 | //~ dtostrf(expect_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3745 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3746 | return true; |
whismanoid | 0:3edb3708c8c5 | 3747 | } |
whismanoid | 0:3edb3708c8c5 | 3748 | else |
whismanoid | 0:3edb3708c8c5 | 3749 | { |
whismanoid | 0:3edb3708c8c5 | 3750 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3751 | //~ SelfTest_print_VoltageOfCode(cmdLine, value_u12); |
whismanoid | 0:3edb3708c8c5 | 3752 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3753 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 0:3edb3708c8c5 | 3754 | cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV ", |
whismanoid | 0:3edb3708c8c5 | 3755 | cPinIndexL, |
whismanoid | 0:3edb3708c8c5 | 3756 | normValueL_0_1 * 100.0, |
whismanoid | 0:3edb3708c8c5 | 3757 | normValueL_0_1 * adc_full_scale_voltageL, |
whismanoid | 0:3edb3708c8c5 | 3758 | cPinIndexH, |
whismanoid | 0:3edb3708c8c5 | 3759 | normValueH_0_1 * 100.0, |
whismanoid | 0:3edb3708c8c5 | 3760 | normValueH_0_1 * adc_full_scale_voltageH |
whismanoid | 0:3edb3708c8c5 | 3761 | ); |
whismanoid | 0:3edb3708c8c5 | 3762 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3763 | // Platform board uses simple analog inputs |
whismanoid | 0:3edb3708c8c5 | 3764 | cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV ", |
whismanoid | 0:3edb3708c8c5 | 3765 | cPinIndex, |
whismanoid | 0:3edb3708c8c5 | 3766 | normValue_0_1 * 100.0, |
whismanoid | 0:3edb3708c8c5 | 3767 | normValue_0_1 * adc_full_scale_voltage |
whismanoid | 0:3edb3708c8c5 | 3768 | ); |
whismanoid | 0:3edb3708c8c5 | 3769 | #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3770 | // |
whismanoid | 0:3edb3708c8c5 | 3771 | cmdLine.serial().printf(" expect %6.6f +/- %6.6f", expect_result, err_threshold); |
whismanoid | 0:3edb3708c8c5 | 3772 | //~ dtostrf(expect_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3773 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3774 | cmdLine.serial().printf(" but got %6.6f", actual_result); |
whismanoid | 0:3edb3708c8c5 | 3775 | //~ dtostrf(actual_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3776 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3777 | cmdLine.serial().printf(" err=%6.6f", err_result); |
whismanoid | 0:3edb3708c8c5 | 3778 | //~ dtostrf( err_result, 6, 6, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3779 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3780 | } |
whismanoid | 0:3edb3708c8c5 | 3781 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3782 | return false; |
whismanoid | 0:3edb3708c8c5 | 3783 | } |
whismanoid | 0:3edb3708c8c5 | 3784 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3785 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3786 | #if APPLICATION_MAX5715 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 3787 | void SelfTest_print_Vref(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 3788 | { |
whismanoid | 0:3edb3708c8c5 | 3789 | cmdLine.serial().printf("VRef = %6.4fV LSB=%6.4fV", g_MAX5715_device.VRef, (g_MAX5715_device.VRef / 4095)); |
whismanoid | 0:3edb3708c8c5 | 3790 | //~ dtostrf(g_MAX5715_device.VRef, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3791 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3792 | //~ cmdLine.serial().printf("V LSB="); |
whismanoid | 0:3edb3708c8c5 | 3793 | // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001 |
whismanoid | 0:3edb3708c8c5 | 3794 | // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001 |
whismanoid | 0:3edb3708c8c5 | 3795 | //~ dtostrf( (g_MAX5715_device.VRef / 4095), 6, 4, strOutLineBuffer); // value, width, precision, char* buffer |
whismanoid | 0:3edb3708c8c5 | 3796 | //~ cmdLine.serial().printf(strOutLineBuffer); |
whismanoid | 0:3edb3708c8c5 | 3797 | //~ cmdLine.serial().printf("V"); |
whismanoid | 0:3edb3708c8c5 | 3798 | } |
whismanoid | 0:3edb3708c8c5 | 3799 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 3800 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3801 | #if APPLICATION_MAX5171 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 3802 | void SelfTest_print_Vref(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 3803 | { |
whismanoid | 0:3edb3708c8c5 | 3804 | cmdLine.serial().printf("VRef = %7.5fV LSB=%7.5fV", g_MAX5171_device.VRef, (g_MAX5171_device.VRef / 16383)); |
whismanoid | 0:3edb3708c8c5 | 3805 | // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001 |
whismanoid | 0:3edb3708c8c5 | 3806 | // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001 |
whismanoid | 0:3edb3708c8c5 | 3807 | } |
whismanoid | 0:3edb3708c8c5 | 3808 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 3809 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3810 | #if HAS_SPI2_MAX541 |
whismanoid | 0:3edb3708c8c5 | 3811 | MAX541 max541(spi2_max541, spi2_max541_cs); |
whismanoid | 0:3edb3708c8c5 | 3812 | #endif |
whismanoid | 0:3edb3708c8c5 | 3813 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3814 | bool SelfTest_MAX541_Voltage(CmdLine & cmdLine, MAX541 &max541, double voltageV) |
whismanoid | 0:3edb3708c8c5 | 3815 | { |
whismanoid | 0:3edb3708c8c5 | 3816 | max541.Set_Voltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3817 | // 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 | 3818 | cmdLine.serial().printf("\r\n Test Fixture: MAX541 set output to 0x%4.4x = %1.3fV", |
whismanoid | 0:3edb3708c8c5 | 3819 | max541.Get_Code(), max541.Get_Voltage()); |
whismanoid | 0:3edb3708c8c5 | 3820 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3821 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3822 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 0:3edb3708c8c5 | 3823 | MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4); |
whismanoid | 0:3edb3708c8c5 | 3824 | tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support |
whismanoid | 0:3edb3708c8c5 | 3825 | tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support |
whismanoid | 0:3edb3708c8c5 | 3826 | tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support |
whismanoid | 0:3edb3708c8c5 | 3827 | tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support |
whismanoid | 0:3edb3708c8c5 | 3828 | tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support |
whismanoid | 0:3edb3708c8c5 | 3829 | tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support |
whismanoid | 0:3edb3708c8c5 | 3830 | // low range channels AIN0, AIN1, AIN2, AIN3 |
whismanoid | 0:3edb3708c8c5 | 3831 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3832 | // Platform board uses simple analog inputs |
whismanoid | 0:3edb3708c8c5 | 3833 | MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5); |
whismanoid | 0:3edb3708c8c5 | 3834 | tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support |
whismanoid | 0:3edb3708c8c5 | 3835 | tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support |
whismanoid | 0:3edb3708c8c5 | 3836 | tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support |
whismanoid | 0:3edb3708c8c5 | 3837 | tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support |
whismanoid | 0:3edb3708c8c5 | 3838 | tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support |
whismanoid | 0:3edb3708c8c5 | 3839 | tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support |
whismanoid | 0:3edb3708c8c5 | 3840 | #endif |
whismanoid | 0:3edb3708c8c5 | 3841 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 3842 | tinyTester.err_threshold = 0.100; |
whismanoid | 0:3edb3708c8c5 | 3843 | return tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); |
whismanoid | 0:3edb3708c8c5 | 3844 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3845 | return SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, voltageV, 0.100); |
whismanoid | 0:3edb3708c8c5 | 3846 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3847 | } |
whismanoid | 0:3edb3708c8c5 | 3848 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3849 | #if APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 3850 | bool SelfTest_MAX11131_EOC_expect(CmdLine & cmdLine, int expect_EOC_value, const char *expect_description) |
whismanoid | 0:3edb3708c8c5 | 3851 | { |
whismanoid | 0:3edb3708c8c5 | 3852 | int actual_EOC_value = -1; |
whismanoid | 0:3edb3708c8c5 | 3853 | for (int retry_count = 0; retry_count < 10; retry_count++) { |
whismanoid | 0:3edb3708c8c5 | 3854 | actual_EOC_value = g_MAX11131_device.EOCinputValue(); |
whismanoid | 0:3edb3708c8c5 | 3855 | if (actual_EOC_value == expect_EOC_value) { |
whismanoid | 0:3edb3708c8c5 | 3856 | SelfTest_PASS(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3857 | cmdLine.serial().printf("EOC signal=%d %s", expect_EOC_value, expect_description); |
whismanoid | 0:3edb3708c8c5 | 3858 | return true; |
whismanoid | 0:3edb3708c8c5 | 3859 | } |
whismanoid | 0:3edb3708c8c5 | 3860 | // EOC condition not met, retry for a while until give up |
whismanoid | 0:3edb3708c8c5 | 3861 | wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 3862 | } |
whismanoid | 0:3edb3708c8c5 | 3863 | cmdLine.serial().printf("\r\n!WARN "); // SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3864 | cmdLine.serial().printf("expected EOC signal=%d %s", expect_EOC_value, expect_description); |
whismanoid | 0:3edb3708c8c5 | 3865 | cmdLine.serial().printf(", but got actual EOC=%d", actual_EOC_value); |
whismanoid | 0:3edb3708c8c5 | 3866 | cmdLine.serial().printf(", missing CNVST or EOC connections?"); |
whismanoid | 0:3edb3708c8c5 | 3867 | return false; |
whismanoid | 0:3edb3708c8c5 | 3868 | } |
whismanoid | 0:3edb3708c8c5 | 3869 | #endif |
whismanoid | 0:3edb3708c8c5 | 3870 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3871 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3872 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3873 | #if APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 3874 | bool SelfTest_Expect_Input_UPO_pin(CmdLine & cmdLine, int expect_UPO_value, const char *expect_description) |
whismanoid | 0:3edb3708c8c5 | 3875 | { |
whismanoid | 0:3edb3708c8c5 | 3876 | int actual_UPO_value = -1; |
whismanoid | 0:3edb3708c8c5 | 3877 | for (int retry_count = 0; retry_count < 10; retry_count++) { |
whismanoid | 0:3edb3708c8c5 | 3878 | actual_UPO_value = UPO_pin.read(); // g_MAX5171_device.UPOinputValue(); |
whismanoid | 0:3edb3708c8c5 | 3879 | if (actual_UPO_value == expect_UPO_value) { |
whismanoid | 0:3edb3708c8c5 | 3880 | SelfTest_PASS(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3881 | cmdLine.serial().printf("UPO signal=%d %s", expect_UPO_value, expect_description); |
whismanoid | 0:3edb3708c8c5 | 3882 | return true; |
whismanoid | 0:3edb3708c8c5 | 3883 | } |
whismanoid | 0:3edb3708c8c5 | 3884 | // UPO condition not met, retry for a while until give up |
whismanoid | 0:3edb3708c8c5 | 3885 | wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 3886 | } |
whismanoid | 0:3edb3708c8c5 | 3887 | cmdLine.serial().printf("\r\n!WARN "); // SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3888 | cmdLine.serial().printf("expected UPO signal=%d %s", expect_UPO_value, expect_description); |
whismanoid | 0:3edb3708c8c5 | 3889 | cmdLine.serial().printf(", but got actual UPO=%d", actual_UPO_value); |
whismanoid | 0:3edb3708c8c5 | 3890 | cmdLine.serial().printf(", missing UPO connections?"); |
whismanoid | 0:3edb3708c8c5 | 3891 | return false; |
whismanoid | 0:3edb3708c8c5 | 3892 | } |
whismanoid | 0:3edb3708c8c5 | 3893 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 3894 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3895 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3896 | void SelfTest(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 3897 | { |
whismanoid | 0:3edb3708c8c5 | 3898 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3899 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3900 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3901 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 0:3edb3708c8c5 | 3902 | // MaximTinyTester(Stream& AssociatedSerialPort, const char *Name); |
whismanoid | 0:3edb3708c8c5 | 3903 | MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4); |
whismanoid | 0:3edb3708c8c5 | 3904 | tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support |
whismanoid | 0:3edb3708c8c5 | 3905 | tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support |
whismanoid | 0:3edb3708c8c5 | 3906 | tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support |
whismanoid | 0:3edb3708c8c5 | 3907 | tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support |
whismanoid | 0:3edb3708c8c5 | 3908 | tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support |
whismanoid | 0:3edb3708c8c5 | 3909 | tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support |
whismanoid | 0:3edb3708c8c5 | 3910 | // low range channels AIN0, AIN1, AIN2, AIN3 |
whismanoid | 0:3edb3708c8c5 | 3911 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 3912 | // Platform board uses simple analog inputs |
whismanoid | 0:3edb3708c8c5 | 3913 | // MaximTinyTester(Stream& AssociatedSerialPort, const char *Name); |
whismanoid | 0:3edb3708c8c5 | 3914 | MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5); |
whismanoid | 0:3edb3708c8c5 | 3915 | tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support |
whismanoid | 0:3edb3708c8c5 | 3916 | tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support |
whismanoid | 0:3edb3708c8c5 | 3917 | tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support |
whismanoid | 0:3edb3708c8c5 | 3918 | tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support |
whismanoid | 0:3edb3708c8c5 | 3919 | tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support |
whismanoid | 0:3edb3708c8c5 | 3920 | tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support |
whismanoid | 0:3edb3708c8c5 | 3921 | #endif |
whismanoid | 0:3edb3708c8c5 | 3922 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3923 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 3924 | g_SelfTest_nPass = 0; |
whismanoid | 0:3edb3708c8c5 | 3925 | g_SelfTest_nFail = 0; |
whismanoid | 0:3edb3708c8c5 | 3926 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3927 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 3928 | //~ rgb_led.red(); // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 3929 | //~ rgb_led.green(); // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 3930 | //~ rgb_led.blue(); // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 3931 | //~ rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 3932 | //~ rgb_led.cyan(); // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 3933 | //~ rgb_led.magenta(); // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 3934 | rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 3935 | //~ rgb_led.black(); // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 3936 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 3937 | #if APPLICATION_MAX5715 // SelfTest |
whismanoid | 0:3edb3708c8c5 | 3938 | // |
whismanoid | 0:3edb3708c8c5 | 3939 | // TODO: tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 3940 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3941 | // |
whismanoid | 0:3edb3708c8c5 | 3942 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 3943 | // uint8_t MAX5715::Init(void) |
whismanoid | 0:3edb3708c8c5 | 3944 | uint8_t (*fn_MAX5715_Init)() = [](){ return g_MAX5715_device.Init(); }; |
whismanoid | 0:3edb3708c8c5 | 3945 | // |
whismanoid | 0:3edb3708c8c5 | 3946 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 3947 | // uint16_t MAX5715::DACCodeOfVoltage(double voltageV) |
whismanoid | 0:3edb3708c8c5 | 3948 | uint16_t (*fn_MAX5715_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5715_device.DACCodeOfVoltage(voltageV); }; |
whismanoid | 0:3edb3708c8c5 | 3949 | // |
whismanoid | 0:3edb3708c8c5 | 3950 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 3951 | // double MAX5715::VoltageOfCode(uint16_t value_u14) |
whismanoid | 0:3edb3708c8c5 | 3952 | double (*fn_MAX5715_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5715_device.VoltageOfCode(value_u14); }; |
whismanoid | 0:3edb3708c8c5 | 3953 | // |
whismanoid | 0:3edb3708c8c5 | 3954 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 3955 | // void MAX5715::CODEnLOADn(uint8_t channel_0_3, uint16_t dacCodeLsbs) |
whismanoid | 0:3edb3708c8c5 | 3956 | 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 | 3957 | // |
whismanoid | 0:3edb3708c8c5 | 3958 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3959 | // |
whismanoid | 0:3edb3708c8c5 | 3960 | // VERIFY: self-test uint16_t MAX5715_DACCodeOfVoltage(double voltageV) |
whismanoid | 0:3edb3708c8c5 | 3961 | // @pre g_MAX5715_device.VRef = Voltage of REF input, in Volts |
whismanoid | 0:3edb3708c8c5 | 3962 | // @param[in] voltage = physical voltage in Volts |
whismanoid | 0:3edb3708c8c5 | 3963 | // @returns raw 12-bit MAX5715 code (right justified). |
whismanoid | 0:3edb3708c8c5 | 3964 | // |
whismanoid | 0:3edb3708c8c5 | 3965 | // VERIFY: self-test double MAX5715_VoltageOfCode(uint16_t value_u12) |
whismanoid | 0:3edb3708c8c5 | 3966 | // @pre g_MAX5715_device.VRef = Voltage of REF input, in Volts |
whismanoid | 0:3edb3708c8c5 | 3967 | // @param[in] value_u12: raw 12-bit MAX5715 code (right justified). |
whismanoid | 0:3edb3708c8c5 | 3968 | // @Returns physical voltage corresponding to MAX5715 code. |
whismanoid | 0:3edb3708c8c5 | 3969 | // |
whismanoid | 0:3edb3708c8c5 | 3970 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3971 | // |
whismanoid | 0:3edb3708c8c5 | 3972 | // |
whismanoid | 0:3edb3708c8c5 | 3973 | // |
whismanoid | 0:3edb3708c8c5 | 3974 | // |
whismanoid | 0:3edb3708c8c5 | 3975 | //------------------------------------------------------------ |
whismanoid | 0:3edb3708c8c5 | 3976 | g_MAX5715_device.VRef = 4.096; // MAX5715 12-bit LSB = 0.0010V |
whismanoid | 0:3edb3708c8c5 | 3977 | SelfTest_print_Vref(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 3978 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 3979 | // |
whismanoid | 0:3edb3708c8c5 | 3980 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 3981 | // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 3982 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS |
whismanoid | 0:3edb3708c8c5 | 3983 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0950, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 3984 | // |
whismanoid | 0:3edb3708c8c5 | 3985 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0945, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 3986 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0944, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3987 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0943, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3988 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0942, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3989 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0941, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3990 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0940, 0x0FFE); // search for code transition |
whismanoid | 0:3edb3708c8c5 | 3991 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0939, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3992 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0938, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3993 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0937, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3994 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0936, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 3995 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0935, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 3996 | // |
whismanoid | 0:3edb3708c8c5 | 3997 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0930, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 3998 | // |
whismanoid | 0:3edb3708c8c5 | 3999 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0480, 0x0800); |
whismanoid | 0:3edb3708c8c5 | 4000 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0470, 0x07FF); |
whismanoid | 0:3edb3708c8c5 | 4001 | // |
whismanoid | 0:3edb3708c8c5 | 4002 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x03E8); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4003 | // |
whismanoid | 0:3edb3708c8c5 | 4004 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0030, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4005 | // |
whismanoid | 0:3edb3708c8c5 | 4006 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0020, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4007 | // |
whismanoid | 0:3edb3708c8c5 | 4008 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4009 | // |
whismanoid | 0:3edb3708c8c5 | 4010 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4011 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4012 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4013 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4014 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4015 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 10.0, 0x0FFF); // overrange FS |
whismanoid | 0:3edb3708c8c5 | 4016 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0950, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4017 | // |
whismanoid | 0:3edb3708c8c5 | 4018 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0945, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4019 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0944, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4020 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0943, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4021 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0942, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4022 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0941, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4023 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0940, 0x0FFE); // search for code transition |
whismanoid | 0:3edb3708c8c5 | 4024 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0939, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4025 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0938, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4026 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0937, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4027 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0936, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4028 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0935, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4029 | // |
whismanoid | 0:3edb3708c8c5 | 4030 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 4.0930, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4031 | // |
whismanoid | 0:3edb3708c8c5 | 4032 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0480, 0x0800); |
whismanoid | 0:3edb3708c8c5 | 4033 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0470, 0x07FF); |
whismanoid | 0:3edb3708c8c5 | 4034 | // |
whismanoid | 0:3edb3708c8c5 | 4035 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.0000, 0x03E8); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4036 | // |
whismanoid | 0:3edb3708c8c5 | 4037 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0030, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4038 | // |
whismanoid | 0:3edb3708c8c5 | 4039 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0020, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4040 | // |
whismanoid | 0:3edb3708c8c5 | 4041 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0010, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4042 | // |
whismanoid | 0:3edb3708c8c5 | 4043 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4044 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, -0.0001, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4045 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, -0.0002, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4046 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, -1.0, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4047 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4048 | // |
whismanoid | 0:3edb3708c8c5 | 4049 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4050 | // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect |
whismanoid | 0:3edb3708c8c5 | 4051 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 4.0950); |
whismanoid | 0:3edb3708c8c5 | 4052 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 4.0940); |
whismanoid | 0:3edb3708c8c5 | 4053 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 2.0480); |
whismanoid | 0:3edb3708c8c5 | 4054 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 2.0470); |
whismanoid | 0:3edb3708c8c5 | 4055 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x03E8, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4056 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0010); |
whismanoid | 0:3edb3708c8c5 | 4057 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 4058 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4059 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0FFF, 4.0950); |
whismanoid | 0:3edb3708c8c5 | 4060 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0FFE, 4.0940); |
whismanoid | 0:3edb3708c8c5 | 4061 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0800, 2.0480); |
whismanoid | 0:3edb3708c8c5 | 4062 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x07FF, 2.0470); |
whismanoid | 0:3edb3708c8c5 | 4063 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x03E8, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4064 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0001, 0.0010); |
whismanoid | 0:3edb3708c8c5 | 4065 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0000, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 4066 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4067 | // |
whismanoid | 0:3edb3708c8c5 | 4068 | //------------------------------------------------------------ |
whismanoid | 0:3edb3708c8c5 | 4069 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4070 | g_MAX5715_device.VRef = 2.048; // 12-bit LSB = 0.0005V |
whismanoid | 0:3edb3708c8c5 | 4071 | SelfTest_print_Vref(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 4072 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4073 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4074 | // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 4075 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS |
whismanoid | 0:3edb3708c8c5 | 4076 | // |
whismanoid | 0:3edb3708c8c5 | 4077 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0480, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4078 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0479, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4079 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0478, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4080 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0477, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4081 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0476, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4082 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0475, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4083 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0474, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4084 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0473, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4085 | // |
whismanoid | 0:3edb3708c8c5 | 4086 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0472, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4087 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0471, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4088 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0470, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4089 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0469, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4090 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0468, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4091 | // |
whismanoid | 0:3edb3708c8c5 | 4092 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0467, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4093 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0466, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4094 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0465, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4095 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0464, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4096 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0463, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4097 | // |
whismanoid | 0:3edb3708c8c5 | 4098 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0240, 0x0800); |
whismanoid | 0:3edb3708c8c5 | 4099 | // |
whismanoid | 0:3edb3708c8c5 | 4100 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0235, 0x07FF); |
whismanoid | 0:3edb3708c8c5 | 4101 | // |
whismanoid | 0:3edb3708c8c5 | 4102 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x07D0); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4103 | // |
whismanoid | 0:3edb3708c8c5 | 4104 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0017, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4105 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0016, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4106 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0015, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4107 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0014, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4108 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0013, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4109 | // |
whismanoid | 0:3edb3708c8c5 | 4110 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0012, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4111 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0011, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4112 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4113 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0009, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4114 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0008, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4115 | // |
whismanoid | 0:3edb3708c8c5 | 4116 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0007, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4117 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0006, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4118 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0005, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4119 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0004, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4120 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0003, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4121 | // |
whismanoid | 0:3edb3708c8c5 | 4122 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0002, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4123 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0001, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4124 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4125 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4126 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4127 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4128 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4129 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 10.0, 0x0FFF); // overrange FS |
whismanoid | 0:3edb3708c8c5 | 4130 | // |
whismanoid | 0:3edb3708c8c5 | 4131 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0480, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4132 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0479, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4133 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0478, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4134 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0477, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4135 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0476, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4136 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0475, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4137 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0474, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4138 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0473, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4139 | // |
whismanoid | 0:3edb3708c8c5 | 4140 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0472, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4141 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0471, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4142 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0470, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4143 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0469, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4144 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0468, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4145 | // |
whismanoid | 0:3edb3708c8c5 | 4146 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0467, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4147 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0466, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4148 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0465, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4149 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0464, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4150 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.0463, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4151 | // |
whismanoid | 0:3edb3708c8c5 | 4152 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.0240, 0x0800); |
whismanoid | 0:3edb3708c8c5 | 4153 | // |
whismanoid | 0:3edb3708c8c5 | 4154 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.0235, 0x07FF); |
whismanoid | 0:3edb3708c8c5 | 4155 | // |
whismanoid | 0:3edb3708c8c5 | 4156 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.0000, 0x07D0); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4157 | // |
whismanoid | 0:3edb3708c8c5 | 4158 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0017, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4159 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0016, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4160 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0015, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4161 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0014, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4162 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0013, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4163 | // |
whismanoid | 0:3edb3708c8c5 | 4164 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0012, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4165 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0011, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4166 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0010, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4167 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0009, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4168 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0008, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4169 | // |
whismanoid | 0:3edb3708c8c5 | 4170 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0007, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4171 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0006, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4172 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0005, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4173 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0004, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4174 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0003, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4175 | // |
whismanoid | 0:3edb3708c8c5 | 4176 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0002, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4177 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0001, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4178 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4179 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, -0.0001, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4180 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, -0.0002, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4181 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, -1.0, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4182 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4183 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4184 | // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect |
whismanoid | 0:3edb3708c8c5 | 4185 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 2.0475); |
whismanoid | 0:3edb3708c8c5 | 4186 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 2.0470); |
whismanoid | 0:3edb3708c8c5 | 4187 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFD, 2.0465); |
whismanoid | 0:3edb3708c8c5 | 4188 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 1.0240); |
whismanoid | 0:3edb3708c8c5 | 4189 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 1.0235); |
whismanoid | 0:3edb3708c8c5 | 4190 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07D0, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4191 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0002, 0.0010); |
whismanoid | 0:3edb3708c8c5 | 4192 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0005); |
whismanoid | 0:3edb3708c8c5 | 4193 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 4194 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4195 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0FFF, 2.0475); |
whismanoid | 0:3edb3708c8c5 | 4196 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0FFE, 2.0470); |
whismanoid | 0:3edb3708c8c5 | 4197 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0FFD, 2.0465); |
whismanoid | 0:3edb3708c8c5 | 4198 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0800, 1.0240); |
whismanoid | 0:3edb3708c8c5 | 4199 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x07FF, 1.0235); |
whismanoid | 0:3edb3708c8c5 | 4200 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x07D0, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4201 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0002, 0.0010); |
whismanoid | 0:3edb3708c8c5 | 4202 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0001, 0.0005); |
whismanoid | 0:3edb3708c8c5 | 4203 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0000, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 4204 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4205 | // |
whismanoid | 0:3edb3708c8c5 | 4206 | // |
whismanoid | 0:3edb3708c8c5 | 4207 | //------------------------------------------------------------ |
whismanoid | 0:3edb3708c8c5 | 4208 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4209 | g_MAX5715_device.VRef = 2.500; // 12-bit LSB = 0.0006105006105006105V |
whismanoid | 0:3edb3708c8c5 | 4210 | SelfTest_print_Vref(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 4211 | //~ cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4212 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4213 | // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 4214 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS |
whismanoid | 0:3edb3708c8c5 | 4215 | // |
whismanoid | 0:3edb3708c8c5 | 4216 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.5000, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4217 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4999, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4218 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4998, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4219 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4997, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4220 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4996, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4221 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4995, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4222 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4994, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4223 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4993, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4224 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4992, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4225 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4991, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4226 | // |
whismanoid | 0:3edb3708c8c5 | 4227 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4990, 0x0FFE); // search for code transitions |
whismanoid | 0:3edb3708c8c5 | 4228 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4989, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4229 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4988, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4230 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4987, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4231 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4986, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4232 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4985, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4233 | // |
whismanoid | 0:3edb3708c8c5 | 4234 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4984, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4235 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4983, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4236 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4982, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4237 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4981, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4238 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4980, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4239 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4979, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4240 | // |
whismanoid | 0:3edb3708c8c5 | 4241 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4978, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4242 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4977, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4243 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4976, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4244 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4975, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4245 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4974, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4246 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4973, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4247 | // |
whismanoid | 0:3edb3708c8c5 | 4248 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4972, 0x0FFB); |
whismanoid | 0:3edb3708c8c5 | 4249 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4971, 0x0FFB); |
whismanoid | 0:3edb3708c8c5 | 4250 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4970, 0x0FFB); |
whismanoid | 0:3edb3708c8c5 | 4251 | // |
whismanoid | 0:3edb3708c8c5 | 4252 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.2500, 0x0800); |
whismanoid | 0:3edb3708c8c5 | 4253 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.2494, 0x07FF); |
whismanoid | 0:3edb3708c8c5 | 4254 | // |
whismanoid | 0:3edb3708c8c5 | 4255 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x0666); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4256 | // |
whismanoid | 0:3edb3708c8c5 | 4257 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0019, 0x0003); // search for code transitions |
whismanoid | 0:3edb3708c8c5 | 4258 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0018, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4259 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0017, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4260 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0016, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4261 | // |
whismanoid | 0:3edb3708c8c5 | 4262 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0015, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4263 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0014, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4264 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0013, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4265 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0012, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4266 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0011, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4267 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4268 | // |
whismanoid | 0:3edb3708c8c5 | 4269 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0009, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4270 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0008, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4271 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0007, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4272 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0006, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4273 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0005, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4274 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0004, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4275 | // |
whismanoid | 0:3edb3708c8c5 | 4276 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0003, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4277 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0002, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4278 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0001, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4279 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4280 | // |
whismanoid | 0:3edb3708c8c5 | 4281 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4282 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4283 | tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4284 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4285 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 10.0, 0x0FFF); // overrange FS |
whismanoid | 0:3edb3708c8c5 | 4286 | // |
whismanoid | 0:3edb3708c8c5 | 4287 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.5000, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4288 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4999, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4289 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4998, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4290 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4997, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4291 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4996, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4292 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4995, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4293 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4994, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4294 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4993, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4295 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4992, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4296 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4991, 0x0FFF); |
whismanoid | 0:3edb3708c8c5 | 4297 | // |
whismanoid | 0:3edb3708c8c5 | 4298 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4990, 0x0FFE); // search for code transitions |
whismanoid | 0:3edb3708c8c5 | 4299 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4989, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4300 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4988, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4301 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4987, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4302 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4986, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4303 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4985, 0x0FFE); |
whismanoid | 0:3edb3708c8c5 | 4304 | // |
whismanoid | 0:3edb3708c8c5 | 4305 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4984, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4306 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4983, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4307 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4982, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4308 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4981, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4309 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4980, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4310 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4979, 0x0FFD); |
whismanoid | 0:3edb3708c8c5 | 4311 | // |
whismanoid | 0:3edb3708c8c5 | 4312 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4978, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4313 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4977, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4314 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4976, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4315 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4975, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4316 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4974, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4317 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4973, 0x0FFC); |
whismanoid | 0:3edb3708c8c5 | 4318 | // |
whismanoid | 0:3edb3708c8c5 | 4319 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4972, 0x0FFB); |
whismanoid | 0:3edb3708c8c5 | 4320 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4971, 0x0FFB); |
whismanoid | 0:3edb3708c8c5 | 4321 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4970, 0x0FFB); |
whismanoid | 0:3edb3708c8c5 | 4322 | // |
whismanoid | 0:3edb3708c8c5 | 4323 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.2500, 0x0800); |
whismanoid | 0:3edb3708c8c5 | 4324 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.2494, 0x07FF); |
whismanoid | 0:3edb3708c8c5 | 4325 | // |
whismanoid | 0:3edb3708c8c5 | 4326 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.0000, 0x0666); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4327 | // |
whismanoid | 0:3edb3708c8c5 | 4328 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0019, 0x0003); // search for code transitions |
whismanoid | 0:3edb3708c8c5 | 4329 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0018, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4330 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0017, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4331 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0016, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4332 | // |
whismanoid | 0:3edb3708c8c5 | 4333 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0015, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4334 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0014, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4335 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0013, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4336 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0012, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4337 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0011, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4338 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0010, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4339 | // |
whismanoid | 0:3edb3708c8c5 | 4340 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0009, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4341 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0008, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4342 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0007, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4343 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0006, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4344 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0005, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4345 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0004, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4346 | // |
whismanoid | 0:3edb3708c8c5 | 4347 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0003, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4348 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0002, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4349 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0001, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4350 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.0000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4351 | // |
whismanoid | 0:3edb3708c8c5 | 4352 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, -0.0001, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4353 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, -0.0002, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4354 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, -1.0, 0x0000); // overrange ZS |
whismanoid | 0:3edb3708c8c5 | 4355 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4356 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4357 | // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect |
whismanoid | 0:3edb3708c8c5 | 4358 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 2.5000); |
whismanoid | 0:3edb3708c8c5 | 4359 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 2.4988); |
whismanoid | 0:3edb3708c8c5 | 4360 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFD, 2.4976); |
whismanoid | 0:3edb3708c8c5 | 4361 | // |
whismanoid | 0:3edb3708c8c5 | 4362 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 1.2500); |
whismanoid | 0:3edb3708c8c5 | 4363 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 1.2494); |
whismanoid | 0:3edb3708c8c5 | 4364 | // |
whismanoid | 0:3edb3708c8c5 | 4365 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0667, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4366 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0666, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4367 | // |
whismanoid | 0:3edb3708c8c5 | 4368 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0002, 0.0012); |
whismanoid | 0:3edb3708c8c5 | 4369 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0006); |
whismanoid | 0:3edb3708c8c5 | 4370 | tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 4371 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4372 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0FFF, 2.5000); |
whismanoid | 0:3edb3708c8c5 | 4373 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0FFE, 2.4988); |
whismanoid | 0:3edb3708c8c5 | 4374 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0FFD, 2.4976); |
whismanoid | 0:3edb3708c8c5 | 4375 | // |
whismanoid | 0:3edb3708c8c5 | 4376 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0800, 1.2500); |
whismanoid | 0:3edb3708c8c5 | 4377 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x07FF, 1.2494); |
whismanoid | 0:3edb3708c8c5 | 4378 | // |
whismanoid | 0:3edb3708c8c5 | 4379 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0667, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4380 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0666, 1.0000); // 1.0 volt |
whismanoid | 0:3edb3708c8c5 | 4381 | // |
whismanoid | 0:3edb3708c8c5 | 4382 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0002, 0.0012); |
whismanoid | 0:3edb3708c8c5 | 4383 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0001, 0.0006); |
whismanoid | 0:3edb3708c8c5 | 4384 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0000, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 4385 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4386 | // |
whismanoid | 0:3edb3708c8c5 | 4387 | // |
whismanoid | 0:3edb3708c8c5 | 4388 | // Device Testing: DAC commands, verify using on-board ADC inputs |
whismanoid | 0:3edb3708c8c5 | 4389 | // |
whismanoid | 0:3edb3708c8c5 | 4390 | cmdLine.serial().printf("\r\n MAX5715.Init()"); |
whismanoid | 0:3edb3708c8c5 | 4391 | g_MAX5715_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 4392 | // |
whismanoid | 0:3edb3708c8c5 | 4393 | uint16_t ch = 0; |
whismanoid | 0:3edb3708c8c5 | 4394 | uint16_t code = 0xfff; |
whismanoid | 0:3edb3708c8c5 | 4395 | double voltageV = 0.5; |
whismanoid | 0:3edb3708c8c5 | 4396 | // |
whismanoid | 0:3edb3708c8c5 | 4397 | // full-scale output on ch0, test MAX5715 internal REF options |
whismanoid | 0:3edb3708c8c5 | 4398 | ch = 0; |
whismanoid | 0:3edb3708c8c5 | 4399 | cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 4400 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 4401 | // |
whismanoid | 0:3edb3708c8c5 | 4402 | cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_2V048)"); |
whismanoid | 0:3edb3708c8c5 | 4403 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048); |
whismanoid | 0:3edb3708c8c5 | 4404 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4405 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4406 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4407 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 4408 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 4409 | tinyTester.AnalogIn0_Read_Expect_voltageV(2.048); |
whismanoid | 0:3edb3708c8c5 | 4410 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4411 | wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 4412 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, 2.048); |
whismanoid | 0:3edb3708c8c5 | 4413 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4414 | // |
whismanoid | 0:3edb3708c8c5 | 4415 | cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_4V096)"); |
whismanoid | 0:3edb3708c8c5 | 4416 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_4V096); |
whismanoid | 0:3edb3708c8c5 | 4417 | // MAX32625MBED 4.096V may be as low as 3.3V supply |
whismanoid | 0:3edb3708c8c5 | 4418 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4419 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4420 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4421 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 4422 | tinyTester.err_threshold = 0.50; // 30mV |
whismanoid | 0:3edb3708c8c5 | 4423 | tinyTester.AnalogIn0_Read_Expect_voltageV(3.750); // accept 3.25V to 4.25V |
whismanoid | 0:3edb3708c8c5 | 4424 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4425 | wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 4426 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, 3.750, 0.50); // accept 3.25V to 4.25V |
whismanoid | 0:3edb3708c8c5 | 4427 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4428 | // |
whismanoid | 0:3edb3708c8c5 | 4429 | cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_2V500)"); |
whismanoid | 0:3edb3708c8c5 | 4430 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); |
whismanoid | 0:3edb3708c8c5 | 4431 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4432 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4433 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4434 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 4435 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 4436 | tinyTester.AnalogIn0_Read_Expect_voltageV(2.500); |
whismanoid | 0:3edb3708c8c5 | 4437 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4438 | wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 4439 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, 2.500); |
whismanoid | 0:3edb3708c8c5 | 4440 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4441 | // |
whismanoid | 0:3edb3708c8c5 | 4442 | // test the individual channel outputs |
whismanoid | 0:3edb3708c8c5 | 4443 | ch = 0; |
whismanoid | 0:3edb3708c8c5 | 4444 | voltageV = 0.5; |
whismanoid | 0:3edb3708c8c5 | 4445 | code = g_MAX5715_device.DACCodeOfVoltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 4446 | cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 4447 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 4448 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4449 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4450 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4451 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 4452 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 4453 | tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); |
whismanoid | 0:3edb3708c8c5 | 4454 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4455 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, ch, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4456 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4457 | // |
whismanoid | 0:3edb3708c8c5 | 4458 | ch = 1; |
whismanoid | 0:3edb3708c8c5 | 4459 | voltageV = 0.2; |
whismanoid | 0:3edb3708c8c5 | 4460 | code = g_MAX5715_device.DACCodeOfVoltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 4461 | cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 4462 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 4463 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4464 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4465 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4466 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 4467 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 4468 | tinyTester.AnalogIn1_Read_Expect_voltageV(voltageV); |
whismanoid | 0:3edb3708c8c5 | 4469 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4470 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, ch, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4471 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4472 | // |
whismanoid | 0:3edb3708c8c5 | 4473 | ch = 2; |
whismanoid | 0:3edb3708c8c5 | 4474 | voltageV = 0.4; |
whismanoid | 0:3edb3708c8c5 | 4475 | code = g_MAX5715_device.DACCodeOfVoltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 4476 | cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 4477 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 4478 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4479 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4480 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4481 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 4482 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 4483 | tinyTester.AnalogIn2_Read_Expect_voltageV(voltageV); |
whismanoid | 0:3edb3708c8c5 | 4484 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4485 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, ch, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4486 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4487 | // |
whismanoid | 0:3edb3708c8c5 | 4488 | ch = 3; |
whismanoid | 0:3edb3708c8c5 | 4489 | voltageV = 0.25; |
whismanoid | 0:3edb3708c8c5 | 4490 | code = g_MAX5715_device.DACCodeOfVoltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 4491 | cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 4492 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 4493 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4494 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4495 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4496 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 4497 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 4498 | tinyTester.AnalogIn3_Read_Expect_voltageV(voltageV); |
whismanoid | 0:3edb3708c8c5 | 4499 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4500 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, ch, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4501 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4502 | // |
whismanoid | 0:3edb3708c8c5 | 4503 | // test that the channels are independent |
whismanoid | 0:3edb3708c8c5 | 4504 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4505 | tinyTester.AnalogIn0_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[0])); |
whismanoid | 0:3edb3708c8c5 | 4506 | tinyTester.AnalogIn1_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[1])); |
whismanoid | 0:3edb3708c8c5 | 4507 | tinyTester.AnalogIn2_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[2])); |
whismanoid | 0:3edb3708c8c5 | 4508 | tinyTester.AnalogIn3_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[3])); |
whismanoid | 0:3edb3708c8c5 | 4509 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4510 | for (ch = 0; ch < 4; ch++) { |
whismanoid | 0:3edb3708c8c5 | 4511 | voltageV = g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[ch]); |
whismanoid | 0:3edb3708c8c5 | 4512 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, ch, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4513 | } |
whismanoid | 0:3edb3708c8c5 | 4514 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4515 | // |
whismanoid | 0:3edb3708c8c5 | 4516 | #elif APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 4517 | // |
whismanoid | 0:3edb3708c8c5 | 4518 | // MAX11131BOB self-test functions |
whismanoid | 0:3edb3708c8c5 | 4519 | //~ SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 4520 | //~ cmdLine.serial().printf("test program not implemented yet"); |
whismanoid | 0:3edb3708c8c5 | 4521 | int16_t value_u12; |
whismanoid | 0:3edb3708c8c5 | 4522 | int channelId; |
whismanoid | 0:3edb3708c8c5 | 4523 | double voltageV = 0.5; |
whismanoid | 0:3edb3708c8c5 | 4524 | // |
whismanoid | 0:3edb3708c8c5 | 4525 | //cmdLine.serial().printf("\r\n 0.0: MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 4526 | //g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 4527 | // |
whismanoid | 0:3edb3708c8c5 | 4528 | // Device Testing: ADC commands, verify with on-board ADC and SPI framing |
whismanoid | 0:3edb3708c8c5 | 4529 | // |
whismanoid | 0:3edb3708c8c5 | 4530 | // MAX11131 SelfTest: MAX11131 SPI connections (Power Supply and GND, SCLK, MOSI, MISO, CS) |
whismanoid | 0:3edb3708c8c5 | 4531 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4532 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4533 | "\r\n 1.0: Test SCAN_0100_StandardExt -- verify SPI (VDD, GND, SCLK, MOSI, MISO, CS)"); |
whismanoid | 0:3edb3708c8c5 | 4534 | cmdLine.serial().printf("\r\n MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 4535 | g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 4536 | // Send MOSI data Expect MISO data Description |
whismanoid | 0:3edb3708c8c5 | 4537 | // 1000_0000_0000_0000 xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0 |
whismanoid | 0:3edb3708c8c5 | 4538 | // 0010_0111_1010_0100 xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL SCAN_0100_StandardExt CHSEL=15 RESET=1 CHANID=1 |
whismanoid | 0:3edb3708c8c5 | 4539 | // 0000_0000_0000_0000 0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0 |
whismanoid | 0:3edb3708c8c5 | 4540 | // 0000_0000_0000_0000 0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1 |
whismanoid | 0:3edb3708c8c5 | 4541 | // 0000_0000_0000_0000 0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2 |
whismanoid | 0:3edb3708c8c5 | 4542 | // 0000_0000_0000_0000 0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3 |
whismanoid | 0:3edb3708c8c5 | 4543 | // |
whismanoid | 0:3edb3708c8c5 | 4544 | cmdLine.serial().printf("\r\n MOSI <-- 1000_0000_0000_0000 ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0"); |
whismanoid | 0:3edb3708c8c5 | 4545 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 4546 | g_MAX11131_device.SPIwrite16bits(0x8000); |
whismanoid | 0:3edb3708c8c5 | 4547 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 4548 | // |
whismanoid | 0:3edb3708c8c5 | 4549 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4550 | "\r\n MOSI <-- 0010_0111_1010_0100 ADC_MODE_CONTROL SCAN_0100_StandardExt CHSEL=15 RESET=1 CHANID=1"); |
whismanoid | 0:3edb3708c8c5 | 4551 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 4552 | g_MAX11131_device.SPIwrite16bits(0x27a4); |
whismanoid | 0:3edb3708c8c5 | 4553 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 4554 | // |
whismanoid | 0:3edb3708c8c5 | 4555 | for (int channelIndex = 0; channelIndex < 16; channelIndex++) { |
whismanoid | 0:3edb3708c8c5 | 4556 | //~ cmdLine.serial().printf("\r\n MISO --> expect 0000_xxxx_xxxx_xxxx"); |
whismanoid | 0:3edb3708c8c5 | 4557 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 4558 | g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits(); |
whismanoid | 0:3edb3708c8c5 | 4559 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 4560 | int expect_channelId = channelIndex; |
whismanoid | 0:3edb3708c8c5 | 4561 | int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F; |
whismanoid | 0:3edb3708c8c5 | 4562 | if (actual_channelId != expect_channelId) |
whismanoid | 0:3edb3708c8c5 | 4563 | { |
whismanoid | 0:3edb3708c8c5 | 4564 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 4565 | cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 4566 | cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); |
whismanoid | 0:3edb3708c8c5 | 4567 | cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId); |
whismanoid | 0:3edb3708c8c5 | 4568 | } |
whismanoid | 0:3edb3708c8c5 | 4569 | else |
whismanoid | 0:3edb3708c8c5 | 4570 | { |
whismanoid | 0:3edb3708c8c5 | 4571 | SelfTest_PASS(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 4572 | cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 4573 | cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); |
whismanoid | 0:3edb3708c8c5 | 4574 | } |
whismanoid | 0:3edb3708c8c5 | 4575 | } |
whismanoid | 0:3edb3708c8c5 | 4576 | // |
whismanoid | 0:3edb3708c8c5 | 4577 | // TODO1: MAX11131 SelfTest: MAX11131 Supports Internal Clock Modes (CNVST, EOC) |
whismanoid | 0:3edb3708c8c5 | 4578 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4579 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4580 | "\r\n 1.1: Test SCAN_0011_StandardInt -- verify Internal Clock signals (CNVST, EOC)"); |
whismanoid | 0:3edb3708c8c5 | 4581 | cmdLine.serial().printf("\r\n MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 4582 | g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 4583 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 4584 | g_MAX11131_device.RAW_misoData16[0] = g_MAX11131_device.SPIread16bits(); |
whismanoid | 0:3edb3708c8c5 | 4585 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 4586 | SelfTest_MAX11131_EOC_expect(cmdLine, 1, "initial value before sending commands"); // TODO1: MAX11131 SelfTest false failure here? |
whismanoid | 0:3edb3708c8c5 | 4587 | // Send MOSI data Expect MISO data Description |
whismanoid | 0:3edb3708c8c5 | 4588 | // 1000_0000_0000_0000 xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0 No Averaging |
whismanoid | 0:3edb3708c8c5 | 4589 | // 0001_1001_1010_0000 xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL SCAN_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0 |
whismanoid | 0:3edb3708c8c5 | 4590 | // 0000_0000_0000_0000 0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0 |
whismanoid | 0:3edb3708c8c5 | 4591 | // 0000_0000_0000_0000 0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1 |
whismanoid | 0:3edb3708c8c5 | 4592 | // 0000_0000_0000_0000 0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2 |
whismanoid | 0:3edb3708c8c5 | 4593 | // 0000_0000_0000_0000 0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3 |
whismanoid | 0:3edb3708c8c5 | 4594 | // |
whismanoid | 0:3edb3708c8c5 | 4595 | cmdLine.serial().printf("\r\n MOSI <-- 1000_0000_0000_0000 ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0"); |
whismanoid | 0:3edb3708c8c5 | 4596 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 4597 | g_MAX11131_device.SPIwrite16bits(0x8000); |
whismanoid | 0:3edb3708c8c5 | 4598 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 4599 | // |
whismanoid | 0:3edb3708c8c5 | 4600 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 4601 | "\r\n MOSI <-- 0001_1001_1010_0000 ADC_MODE_CONTROL SCAN_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0"); |
whismanoid | 0:3edb3708c8c5 | 4602 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 4603 | g_MAX11131_device.SPIwrite16bits(0x19a0); |
whismanoid | 0:3edb3708c8c5 | 4604 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 4605 | // |
whismanoid | 0:3edb3708c8c5 | 4606 | for (int channelIndex = 0; channelIndex < 4; channelIndex++) { |
whismanoid | 0:3edb3708c8c5 | 4607 | //~ cmdLine.serial().printf("\r\n MISO --> expect 0000_xxxx_xxxx_xxxx"); |
whismanoid | 0:3edb3708c8c5 | 4608 | //~ wait_ms(200); // delay |
whismanoid | 0:3edb3708c8c5 | 4609 | g_MAX11131_device.CNVSToutputPulseLow(); |
whismanoid | 0:3edb3708c8c5 | 4610 | //~ g_MAX11131_device.CNVSToutputValue(0); |
whismanoid | 0:3edb3708c8c5 | 4611 | //~ wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 4612 | //~ g_MAX11131_device.CNVSToutputValue(1); |
whismanoid | 0:3edb3708c8c5 | 4613 | // g_MAX11131_device.EOCinputWaitUntilLow(); // infinite wait hazard, need to fail if timeout exceeded |
whismanoid | 0:3edb3708c8c5 | 4614 | SelfTest_MAX11131_EOC_expect(cmdLine, 0, "after CNVST pulse"); |
whismanoid | 0:3edb3708c8c5 | 4615 | g_MAX11131_device.SPIoutputCS(0); // drive CS low |
whismanoid | 0:3edb3708c8c5 | 4616 | g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits(); |
whismanoid | 0:3edb3708c8c5 | 4617 | g_MAX11131_device.SPIoutputCS(1); // drive CS high |
whismanoid | 0:3edb3708c8c5 | 4618 | SelfTest_MAX11131_EOC_expect(cmdLine, 1, "after SPI read"); |
whismanoid | 0:3edb3708c8c5 | 4619 | int expect_channelId = channelIndex; |
whismanoid | 0:3edb3708c8c5 | 4620 | int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F; |
whismanoid | 0:3edb3708c8c5 | 4621 | if (actual_channelId != expect_channelId) |
whismanoid | 0:3edb3708c8c5 | 4622 | { |
whismanoid | 0:3edb3708c8c5 | 4623 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 4624 | cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 4625 | cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); |
whismanoid | 0:3edb3708c8c5 | 4626 | cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId); |
whismanoid | 0:3edb3708c8c5 | 4627 | } |
whismanoid | 0:3edb3708c8c5 | 4628 | else |
whismanoid | 0:3edb3708c8c5 | 4629 | { |
whismanoid | 0:3edb3708c8c5 | 4630 | SelfTest_PASS(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 4631 | cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 4632 | cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); |
whismanoid | 0:3edb3708c8c5 | 4633 | } |
whismanoid | 0:3edb3708c8c5 | 4634 | } |
whismanoid | 0:3edb3708c8c5 | 4635 | // |
whismanoid | 0:3edb3708c8c5 | 4636 | // TODO1: MAX11131 SelfTest: Test Fixture: MAX541ACPA+ to MAX32625MBED.AIN0/AIN4 |
whismanoid | 0:3edb3708c8c5 | 4637 | // Test Fixture: MAX541 connected to spi2 |
whismanoid | 0:3edb3708c8c5 | 4638 | // 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 | 4639 | // DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header |
whismanoid | 0:3edb3708c8c5 | 4640 | // Test Fixture: MAX541 spi2 init |
whismanoid | 0:3edb3708c8c5 | 4641 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4642 | cmdLine.serial().printf("\r\n 2.0: Test Fixture: MAX541 connected to spi2 (P2.4 P2.5 P2.7)?"); |
whismanoid | 0:3edb3708c8c5 | 4643 | bool SelfTest_has_max541 = false; |
whismanoid | 0:3edb3708c8c5 | 4644 | // Check actual MAX541 reference voltage |
whismanoid | 0:3edb3708c8c5 | 4645 | cmdLine.serial().printf("\r\n Test Fixture: MAX541 midscale voltage measure with MAX32625MBED AIN0/4"); |
whismanoid | 0:3edb3708c8c5 | 4646 | max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale |
whismanoid | 0:3edb3708c8c5 | 4647 | 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 | 4648 | const int average_count = 100; |
whismanoid | 0:3edb3708c8c5 | 4649 | const double average_K = 0.25; |
whismanoid | 0:3edb3708c8c5 | 4650 | for (int count = 0; count < average_count; count++) { |
whismanoid | 0:3edb3708c8c5 | 4651 | double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 4652 | max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V); |
whismanoid | 0:3edb3708c8c5 | 4653 | } |
whismanoid | 0:3edb3708c8c5 | 4654 | if (max541_midscale_V > 1.0f) { |
whismanoid | 0:3edb3708c8c5 | 4655 | max541.VRef = 2.0 * max541_midscale_V; |
whismanoid | 0:3edb3708c8c5 | 4656 | cmdLine.serial().printf("\r\n Test Fixture: MAX541 midscale = %1.3fV, so fullscale = %1.3fV", |
whismanoid | 0:3edb3708c8c5 | 4657 | max541_midscale_V, max541.VRef); |
whismanoid | 0:3edb3708c8c5 | 4658 | // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4 |
whismanoid | 0:3edb3708c8c5 | 4659 | voltageV = 1.0f; |
whismanoid | 0:3edb3708c8c5 | 4660 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4661 | } |
whismanoid | 0:3edb3708c8c5 | 4662 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 4663 | voltageV = 0.0f; |
whismanoid | 0:3edb3708c8c5 | 4664 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4665 | } |
whismanoid | 0:3edb3708c8c5 | 4666 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 4667 | voltageV = 3.0f; |
whismanoid | 0:3edb3708c8c5 | 4668 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4669 | } |
whismanoid | 0:3edb3708c8c5 | 4670 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 4671 | voltageV = 1.65f; |
whismanoid | 0:3edb3708c8c5 | 4672 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4673 | } |
whismanoid | 0:3edb3708c8c5 | 4674 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 4675 | voltageV = 2.0f; |
whismanoid | 0:3edb3708c8c5 | 4676 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4677 | } |
whismanoid | 0:3edb3708c8c5 | 4678 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 4679 | voltageV = 0.25f; |
whismanoid | 0:3edb3708c8c5 | 4680 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4681 | } |
whismanoid | 0:3edb3708c8c5 | 4682 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 4683 | voltageV = 0.5f; |
whismanoid | 0:3edb3708c8c5 | 4684 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4685 | } |
whismanoid | 0:3edb3708c8c5 | 4686 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 4687 | voltageV = 1.0f; |
whismanoid | 0:3edb3708c8c5 | 4688 | SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4689 | } |
whismanoid | 0:3edb3708c8c5 | 4690 | if (SelfTest_has_max541 == false) { |
whismanoid | 0:3edb3708c8c5 | 4691 | // don't fail just because we're missing the test fixture... |
whismanoid | 0:3edb3708c8c5 | 4692 | cmdLine.serial().printf("\r\n Test Fixture: MAX541 not present"); |
whismanoid | 0:3edb3708c8c5 | 4693 | //~ g_SelfTest_nFail--; |
whismanoid | 0:3edb3708c8c5 | 4694 | } |
whismanoid | 0:3edb3708c8c5 | 4695 | // |
whismanoid | 0:3edb3708c8c5 | 4696 | // TODO1: MAX11131 SelfTest: if Test Fixture: drive MAX541, compare MAX32625MBED.AIN0/AIN4 and MAX11131 AIN0 |
whismanoid | 0:3edb3708c8c5 | 4697 | // indirectly verify the reference voltage by reading a known input voltage |
whismanoid | 0:3edb3708c8c5 | 4698 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 4699 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4700 | cmdLine.serial().printf("\r\n 2.1: TODO1: Check MAX11131 reference voltage using SCAN_0001_Manual"); |
whismanoid | 0:3edb3708c8c5 | 4701 | voltageV = 1.0f; |
whismanoid | 0:3edb3708c8c5 | 4702 | SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4703 | cmdLine.serial().printf("\r\n MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 4704 | g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 4705 | // 1 ScanManual ch=0 pm=0 id=1 |
whismanoid | 0:3edb3708c8c5 | 4706 | g_MAX11131_device.channelNumber_0_15 = 0; |
whismanoid | 0:3edb3708c8c5 | 4707 | g_MAX11131_device.PowerManagement_0_2 = 0; |
whismanoid | 0:3edb3708c8c5 | 4708 | g_MAX11131_device.chan_id_0_1 = 1; |
whismanoid | 0:3edb3708c8c5 | 4709 | cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15); |
whismanoid | 0:3edb3708c8c5 | 4710 | cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2); |
whismanoid | 0:3edb3708c8c5 | 4711 | cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 4712 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); |
whismanoid | 0:3edb3708c8c5 | 4713 | cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d", |
whismanoid | 0:3edb3708c8c5 | 4714 | g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4715 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); |
whismanoid | 0:3edb3708c8c5 | 4716 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 4717 | cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); |
whismanoid | 0:3edb3708c8c5 | 4718 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4719 | // |
whismanoid | 0:3edb3708c8c5 | 4720 | // 2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here? |
whismanoid | 0:3edb3708c8c5 | 4721 | // |
whismanoid | 0:3edb3708c8c5 | 4722 | cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d", |
whismanoid | 0:3edb3708c8c5 | 4723 | g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4724 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 4725 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 4726 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 4727 | cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); |
whismanoid | 0:3edb3708c8c5 | 4728 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4729 | // |
whismanoid | 0:3edb3708c8c5 | 4730 | // 2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here? |
whismanoid | 0:3edb3708c8c5 | 4731 | // |
whismanoid | 0:3edb3708c8c5 | 4732 | // compare with mbed/Arduino AIN0-AIN3 |
whismanoid | 0:3edb3708c8c5 | 4733 | // MAX32625MBED.AIN4 = MAX11131.AIN0 |
whismanoid | 0:3edb3708c8c5 | 4734 | channelId = 0; |
whismanoid | 0:3edb3708c8c5 | 4735 | value_u12 = g_MAX11131_device.AINcode[channelId]; |
whismanoid | 0:3edb3708c8c5 | 4736 | voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 4737 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, voltageV, 0.100); |
whismanoid | 0:3edb3708c8c5 | 4738 | } |
whismanoid | 0:3edb3708c8c5 | 4739 | // |
whismanoid | 0:3edb3708c8c5 | 4740 | if (SelfTest_has_max541) { |
whismanoid | 0:3edb3708c8c5 | 4741 | voltageV = 1.0f; |
whismanoid | 0:3edb3708c8c5 | 4742 | SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 4743 | } |
whismanoid | 0:3edb3708c8c5 | 4744 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4745 | cmdLine.serial().printf("\r\n 3.1: Test SCAN_0001_Manual"); |
whismanoid | 0:3edb3708c8c5 | 4746 | cmdLine.serial().printf("\r\n MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 4747 | g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 4748 | // 1 ScanManual ch=0 pm=0 id=1 |
whismanoid | 0:3edb3708c8c5 | 4749 | g_MAX11131_device.channelNumber_0_15 = 0; |
whismanoid | 0:3edb3708c8c5 | 4750 | g_MAX11131_device.PowerManagement_0_2 = 0; |
whismanoid | 0:3edb3708c8c5 | 4751 | g_MAX11131_device.chan_id_0_1 = 1; |
whismanoid | 0:3edb3708c8c5 | 4752 | cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15); |
whismanoid | 0:3edb3708c8c5 | 4753 | cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2); |
whismanoid | 0:3edb3708c8c5 | 4754 | cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 4755 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); |
whismanoid | 0:3edb3708c8c5 | 4756 | cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d", |
whismanoid | 0:3edb3708c8c5 | 4757 | g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4758 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 4759 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 4760 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 4761 | cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); |
whismanoid | 0:3edb3708c8c5 | 4762 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4763 | // compare with mbed/Arduino AIN0-AIN3 |
whismanoid | 0:3edb3708c8c5 | 4764 | // MAX32625MBED.AIN4 = MAX11131.AIN0 |
whismanoid | 0:3edb3708c8c5 | 4765 | channelId = 0; |
whismanoid | 0:3edb3708c8c5 | 4766 | value_u12 = g_MAX11131_device.AINcode[channelId]; |
whismanoid | 0:3edb3708c8c5 | 4767 | voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 4768 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, voltageV, 0.100); |
whismanoid | 0:3edb3708c8c5 | 4769 | // |
whismanoid | 0:3edb3708c8c5 | 4770 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 4771 | cmdLine.serial().printf("\r\n 3.4: Test SCAN_0100_StandardExternalClock"); |
whismanoid | 0:3edb3708c8c5 | 4772 | cmdLine.serial().printf("\r\n MAX11131.Init()"); |
whismanoid | 0:3edb3708c8c5 | 4773 | g_MAX11131_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 4774 | // MAX11131 > 4 |
whismanoid | 0:3edb3708c8c5 | 4775 | // ScanStandardExternalClock ch=9 pm=0 id=1 |
whismanoid | 0:3edb3708c8c5 | 4776 | // ScanRead_nWords_chanID nWords=10 |
whismanoid | 0:3edb3708c8c5 | 4777 | // ch=0 xu=2964 = 0x0b94 = 1.8091V |
whismanoid | 0:3edb3708c8c5 | 4778 | // ch=1 xu=2227 = 0x08b3 = 1.3593V |
whismanoid | 0:3edb3708c8c5 | 4779 | // ch=2 xu=1570 = 0x0622 = 0.9583V |
whismanoid | 0:3edb3708c8c5 | 4780 | // ch=3 xu=865 = 0x0361 = 0.5280V |
whismanoid | 0:3edb3708c8c5 | 4781 | // ch=4 xu=630 = 0x0276 = 0.3845V |
whismanoid | 0:3edb3708c8c5 | 4782 | // ch=5 xu=594 = 0x0252 = 0.3625V |
whismanoid | 0:3edb3708c8c5 | 4783 | // ch=6 xu=461 = 0x01cd = 0.2814V |
whismanoid | 0:3edb3708c8c5 | 4784 | // ch=7 xu=364 = 0x016c = 0.2222V |
whismanoid | 0:3edb3708c8c5 | 4785 | // ch=8 xu=480 = 0x01e0 = 0.2930V |
whismanoid | 0:3edb3708c8c5 | 4786 | // ch=9 xu=616 = 0x0268 = 0.3760V |
whismanoid | 0:3edb3708c8c5 | 4787 | g_MAX11131_device.channelNumber_0_15 = 9; |
whismanoid | 0:3edb3708c8c5 | 4788 | g_MAX11131_device.PowerManagement_0_2 = 0; |
whismanoid | 0:3edb3708c8c5 | 4789 | g_MAX11131_device.chan_id_0_1 = 1; |
whismanoid | 0:3edb3708c8c5 | 4790 | cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15); |
whismanoid | 0:3edb3708c8c5 | 4791 | cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2); |
whismanoid | 0:3edb3708c8c5 | 4792 | cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 4793 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 4794 | cmdLine.serial().printf("\r\n MAX11131.ScanStandardExternalClock -- NumWords = %d", |
whismanoid | 0:3edb3708c8c5 | 4795 | g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4796 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 4797 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 4798 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 4799 | cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); |
whismanoid | 0:3edb3708c8c5 | 4800 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 4801 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 4802 | // TODO: expect g_MAX11131_device.NumWords == g_MAX11131_device.channelNumber_0_15 + 1; |
whismanoid | 0:3edb3708c8c5 | 4803 | // TODO: expect RAW_misoData16[index] msnybble 0,1,2,3,... |
whismanoid | 0:3edb3708c8c5 | 4804 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 4805 | // TODO: compare with mbed/Arduino AIN0-AIN3 |
whismanoid | 0:3edb3708c8c5 | 4806 | // MAX32625MBED.AIN4 = MAX11131.AIN0 |
whismanoid | 0:3edb3708c8c5 | 4807 | channelId = 0; |
whismanoid | 0:3edb3708c8c5 | 4808 | value_u12 = g_MAX11131_device.AINcode[channelId]; |
whismanoid | 0:3edb3708c8c5 | 4809 | voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 4810 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, voltageV, 0.100); |
whismanoid | 0:3edb3708c8c5 | 4811 | // TODO: compare MAX32625MBED.AIN5 = MAX11131.AIN1 |
whismanoid | 0:3edb3708c8c5 | 4812 | //channelId = 1; |
whismanoid | 0:3edb3708c8c5 | 4813 | //value_u12 = g_MAX11131_device.AINcode[channelId]; |
whismanoid | 0:3edb3708c8c5 | 4814 | //voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); |
whismanoid | 0:3edb3708c8c5 | 4815 | //SelfTest_AnalogInput_Expect_ch_V(cmdLine, 5, voltageV, 0.100); |
whismanoid | 0:3edb3708c8c5 | 4816 | // |
whismanoid | 0:3edb3708c8c5 | 4817 | #elif APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 4818 | |
whismanoid | 0:3edb3708c8c5 | 4819 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4820 | // TODO: tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 4821 | // |
whismanoid | 0:3edb3708c8c5 | 4822 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 4823 | // uint8_t MAX5171::Init(void) |
whismanoid | 0:3edb3708c8c5 | 4824 | uint8_t (*fn_MAX5171_Init)() = [](){ return g_MAX5171_device.Init(); }; |
whismanoid | 0:3edb3708c8c5 | 4825 | // |
whismanoid | 0:3edb3708c8c5 | 4826 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 4827 | // uint16_t MAX5171::DACCodeOfVoltage(double voltageV) |
whismanoid | 0:3edb3708c8c5 | 4828 | uint16_t (*fn_MAX5171_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5171_device.DACCodeOfVoltage(voltageV); }; |
whismanoid | 0:3edb3708c8c5 | 4829 | // |
whismanoid | 0:3edb3708c8c5 | 4830 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 4831 | // double MAX5171::VoltageOfCode(uint16_t value_u14) |
whismanoid | 0:3edb3708c8c5 | 4832 | double (*fn_MAX5171_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5171_device.VoltageOfCode(value_u14); }; |
whismanoid | 0:3edb3708c8c5 | 4833 | // |
whismanoid | 0:3edb3708c8c5 | 4834 | // define function under test using C++11 lambda expression [](){} |
whismanoid | 0:3edb3708c8c5 | 4835 | // uint8_t MAX5171::CODE_LOAD(uint16_t dacCodeLsbs) |
whismanoid | 0:3edb3708c8c5 | 4836 | uint8_t (*fn_MAX5171_CODE_LOAD)(uint16_t dacCodeLsbs) = [](uint16_t dacCodeLsbs){ return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); }; |
whismanoid | 0:3edb3708c8c5 | 4837 | // |
whismanoid | 0:3edb3708c8c5 | 4838 | //double one_LSB = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS |
whismanoid | 0:3edb3708c8c5 | 4839 | tinyTester.err_threshold = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS |
whismanoid | 0:3edb3708c8c5 | 4840 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4841 | tinyTester.settle_time_msec = 250; |
whismanoid | 0:3edb3708c8c5 | 4842 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4843 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4844 | |
whismanoid | 0:3edb3708c8c5 | 4845 | g_MAX5171_device.VRef = 2.500; // MAX5171 14-bit LSB = 0.00015V |
whismanoid | 0:3edb3708c8c5 | 4846 | SelfTest_print_Vref(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 4847 | // |
whismanoid | 0:3edb3708c8c5 | 4848 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4849 | // TODO: tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect |
whismanoid | 0:3edb3708c8c5 | 4850 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.499847412109375, 0x3FFF); |
whismanoid | 0:3edb3708c8c5 | 4851 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.49969482421875, 0x3FFE); |
whismanoid | 0:3edb3708c8c5 | 4852 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.499542236328125, 0x3FFD); |
whismanoid | 0:3edb3708c8c5 | 4853 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.4993896484375, 0x3FFC); |
whismanoid | 0:3edb3708c8c5 | 4854 | // |
whismanoid | 0:3edb3708c8c5 | 4855 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.250152587890625, 0x2001); |
whismanoid | 0:3edb3708c8c5 | 4856 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.25, 0x2000); |
whismanoid | 0:3edb3708c8c5 | 4857 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.249847412109375, 0x1FFF); |
whismanoid | 0:3edb3708c8c5 | 4858 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.24969482421875, 0x1FFE); |
whismanoid | 0:3edb3708c8c5 | 4859 | // |
whismanoid | 0:3edb3708c8c5 | 4860 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.000457763671875, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4861 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.00030517578125, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4862 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.000152587890625, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4863 | tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.00000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4864 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4865 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.499847412109375, 0x3FFF); |
whismanoid | 0:3edb3708c8c5 | 4866 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.49969482421875, 0x3FFE); |
whismanoid | 0:3edb3708c8c5 | 4867 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.499542236328125, 0x3FFD); |
whismanoid | 0:3edb3708c8c5 | 4868 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 2.4993896484375, 0x3FFC); |
whismanoid | 0:3edb3708c8c5 | 4869 | // |
whismanoid | 0:3edb3708c8c5 | 4870 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.250152587890625, 0x2001); |
whismanoid | 0:3edb3708c8c5 | 4871 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.25, 0x2000); |
whismanoid | 0:3edb3708c8c5 | 4872 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.249847412109375, 0x1FFF); |
whismanoid | 0:3edb3708c8c5 | 4873 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 1.24969482421875, 0x1FFE); |
whismanoid | 0:3edb3708c8c5 | 4874 | // |
whismanoid | 0:3edb3708c8c5 | 4875 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.000457763671875, 0x0003); |
whismanoid | 0:3edb3708c8c5 | 4876 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.00030517578125, 0x0002); |
whismanoid | 0:3edb3708c8c5 | 4877 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.000152587890625, 0x0001); |
whismanoid | 0:3edb3708c8c5 | 4878 | SelfTest_DACCodeOfVoltage_Expect(cmdLine, 0.00000, 0x0000); |
whismanoid | 0:3edb3708c8c5 | 4879 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4880 | // |
whismanoid | 0:3edb3708c8c5 | 4881 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4882 | // TODO: tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect |
whismanoid | 0:3edb3708c8c5 | 4883 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFF, 2.499847412109375); |
whismanoid | 0:3edb3708c8c5 | 4884 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFE, 2.49969482421875); |
whismanoid | 0:3edb3708c8c5 | 4885 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFD, 2.499542236328125); |
whismanoid | 0:3edb3708c8c5 | 4886 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFC, 2.4993896484375); |
whismanoid | 0:3edb3708c8c5 | 4887 | // |
whismanoid | 0:3edb3708c8c5 | 4888 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x2001, 1.250152587890625); |
whismanoid | 0:3edb3708c8c5 | 4889 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x2000, 1.25); |
whismanoid | 0:3edb3708c8c5 | 4890 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x1FFF, 1.249847412109375); |
whismanoid | 0:3edb3708c8c5 | 4891 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x1FFE, 1.24969482421875); |
whismanoid | 0:3edb3708c8c5 | 4892 | // |
whismanoid | 0:3edb3708c8c5 | 4893 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0003, 0.000457763671875); |
whismanoid | 0:3edb3708c8c5 | 4894 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0002, 0.00030517578125); |
whismanoid | 0:3edb3708c8c5 | 4895 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0001, 0.000152587890625); |
whismanoid | 0:3edb3708c8c5 | 4896 | tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0000, 0.00000); |
whismanoid | 0:3edb3708c8c5 | 4897 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4898 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x3FFF, 2.499847412109375); |
whismanoid | 0:3edb3708c8c5 | 4899 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x3FFE, 2.49969482421875); |
whismanoid | 0:3edb3708c8c5 | 4900 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x3FFD, 2.499542236328125); |
whismanoid | 0:3edb3708c8c5 | 4901 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x3FFC, 2.4993896484375); |
whismanoid | 0:3edb3708c8c5 | 4902 | // |
whismanoid | 0:3edb3708c8c5 | 4903 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x2001, 1.250152587890625); |
whismanoid | 0:3edb3708c8c5 | 4904 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x2000, 1.25); |
whismanoid | 0:3edb3708c8c5 | 4905 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x1FFF, 1.249847412109375); |
whismanoid | 0:3edb3708c8c5 | 4906 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x1FFE, 1.24969482421875); |
whismanoid | 0:3edb3708c8c5 | 4907 | // |
whismanoid | 0:3edb3708c8c5 | 4908 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0003, 0.000457763671875); |
whismanoid | 0:3edb3708c8c5 | 4909 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0002, 0.00030517578125); |
whismanoid | 0:3edb3708c8c5 | 4910 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0001, 0.000152587890625); |
whismanoid | 0:3edb3708c8c5 | 4911 | SelfTest_VoltageOfCode_Expect(cmdLine, 0x0000, 0.00000); |
whismanoid | 0:3edb3708c8c5 | 4912 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4913 | // |
whismanoid | 0:3edb3708c8c5 | 4914 | // Device Testing: DAC commands, verify using on-board ADC inputs |
whismanoid | 0:3edb3708c8c5 | 4915 | // |
whismanoid | 0:3edb3708c8c5 | 4916 | cmdLine.serial().printf("\r\n MAX5171.Init()"); |
whismanoid | 0:3edb3708c8c5 | 4917 | g_MAX5171_device.Init(); |
whismanoid | 0:3edb3708c8c5 | 4918 | // |
whismanoid | 0:3edb3708c8c5 | 4919 | tinyTester.err_threshold = 0.030; // 30mV |
whismanoid | 0:3edb3708c8c5 | 4920 | uint16_t code = 0x3FFF; |
whismanoid | 0:3edb3708c8c5 | 4921 | //~ double voltageV = 0.5; |
whismanoid | 0:3edb3708c8c5 | 4922 | // |
whismanoid | 0:3edb3708c8c5 | 4923 | cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 4924 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 0:3edb3708c8c5 | 4925 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4926 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4927 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4928 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 4929 | tinyTester.AnalogIn0_Read_Expect_voltageV(2.500); |
whismanoid | 0:3edb3708c8c5 | 4930 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4931 | wait_ms(250); // delay |
whismanoid | 0:3edb3708c8c5 | 4932 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 4933 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 0:3edb3708c8c5 | 4934 | // low range channels AIN0, AIN1, AIN2, AIN3 |
whismanoid | 0:3edb3708c8c5 | 4935 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, 2.500); |
whismanoid | 0:3edb3708c8c5 | 4936 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 4937 | // Platform board uses simple analog inputs |
whismanoid | 0:3edb3708c8c5 | 4938 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 0, 2.500); |
whismanoid | 0:3edb3708c8c5 | 4939 | #endif |
whismanoid | 0:3edb3708c8c5 | 4940 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4941 | // |
whismanoid | 0:3edb3708c8c5 | 4942 | code = 0x0000; |
whismanoid | 0:3edb3708c8c5 | 4943 | cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 4944 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 0:3edb3708c8c5 | 4945 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4946 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4947 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4948 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 4949 | tinyTester.AnalogIn0_Read_Expect_voltageV(0.0000); |
whismanoid | 0:3edb3708c8c5 | 4950 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4951 | wait_ms(250); // delay |
whismanoid | 0:3edb3708c8c5 | 4952 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 4953 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 0:3edb3708c8c5 | 4954 | // low range channels AIN0, AIN1, AIN2, AIN3 |
whismanoid | 0:3edb3708c8c5 | 4955 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 4956 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 4957 | // Platform board uses simple analog inputs |
whismanoid | 0:3edb3708c8c5 | 4958 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 0, 0.0000); |
whismanoid | 0:3edb3708c8c5 | 4959 | #endif |
whismanoid | 0:3edb3708c8c5 | 4960 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4961 | // |
whismanoid | 0:3edb3708c8c5 | 4962 | code = 0x1FFF; |
whismanoid | 0:3edb3708c8c5 | 4963 | cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 4964 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 0:3edb3708c8c5 | 4965 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4966 | // TODO: tinyTester.Wait_Output_Settling replaces wait_ms |
whismanoid | 0:3edb3708c8c5 | 4967 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4968 | // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V |
whismanoid | 0:3edb3708c8c5 | 4969 | tinyTester.AnalogIn0_Read_Expect_voltageV(1.2500); |
whismanoid | 0:3edb3708c8c5 | 4970 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4971 | wait_ms(250); // delay |
whismanoid | 0:3edb3708c8c5 | 4972 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 4973 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 0:3edb3708c8c5 | 4974 | // low range channels AIN0, AIN1, AIN2, AIN3 |
whismanoid | 0:3edb3708c8c5 | 4975 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, 1.2500); |
whismanoid | 0:3edb3708c8c5 | 4976 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 4977 | // Platform board uses simple analog inputs |
whismanoid | 0:3edb3708c8c5 | 4978 | SelfTest_AnalogInput_Expect_ch_V(cmdLine, 0, 1.2500); |
whismanoid | 0:3edb3708c8c5 | 4979 | #endif |
whismanoid | 0:3edb3708c8c5 | 4980 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4981 | // |
whismanoid | 0:3edb3708c8c5 | 4982 | // test UPO User Programmable Output, verify using digital input D2 |
whismanoid | 0:3edb3708c8c5 | 4983 | // |
whismanoid | 0:3edb3708c8c5 | 4984 | cmdLine.serial().printf("\r\n MAX5171.UPO_HIGH"); |
whismanoid | 0:3edb3708c8c5 | 4985 | g_MAX5171_device.UPO_HIGH(); |
whismanoid | 0:3edb3708c8c5 | 4986 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4987 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4988 | // TODO: tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin |
whismanoid | 0:3edb3708c8c5 | 4989 | tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command"); |
whismanoid | 0:3edb3708c8c5 | 4990 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4991 | wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 4992 | SelfTest_Expect_Input_UPO_pin(cmdLine, 1, "UPO_pin is high after MAX5171 UPO_HIGH command"); |
whismanoid | 0:3edb3708c8c5 | 4993 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4994 | // |
whismanoid | 0:3edb3708c8c5 | 4995 | cmdLine.serial().printf("\r\n MAX5171.UPO_LOW"); |
whismanoid | 0:3edb3708c8c5 | 4996 | g_MAX5171_device.UPO_LOW(); |
whismanoid | 0:3edb3708c8c5 | 4997 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 4998 | tinyTester.Wait_Output_Settling(); |
whismanoid | 0:3edb3708c8c5 | 4999 | // TODO: tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin |
whismanoid | 0:3edb3708c8c5 | 5000 | tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 0, "UPO_pin is low after MAX5171 UPO_LOW command"); |
whismanoid | 0:3edb3708c8c5 | 5001 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 5002 | wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 5003 | SelfTest_Expect_Input_UPO_pin(cmdLine, 0, "UPO_pin is low after MAX5171 UPO_LOW command"); |
whismanoid | 0:3edb3708c8c5 | 5004 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 5005 | // |
whismanoid | 0:3edb3708c8c5 | 5006 | cmdLine.serial().printf("\r\n MAX5171.UPO_HIGH"); |
whismanoid | 0:3edb3708c8c5 | 5007 | g_MAX5171_device.UPO_HIGH(); |
whismanoid | 0:3edb3708c8c5 | 5008 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 5009 | tinyTester.Wait_Output_Settling(); // wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 5010 | // TODO: tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin |
whismanoid | 0:3edb3708c8c5 | 5011 | tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command"); |
whismanoid | 0:3edb3708c8c5 | 5012 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 5013 | wait_ms(100); // delay |
whismanoid | 0:3edb3708c8c5 | 5014 | SelfTest_Expect_Input_UPO_pin(cmdLine, 1, "UPO_pin is high after MAX5171 UPO_HIGH command"); |
whismanoid | 0:3edb3708c8c5 | 5015 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 5016 | // |
whismanoid | 0:3edb3708c8c5 | 5017 | #elif APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 5018 | // |
whismanoid | 0:3edb3708c8c5 | 5019 | // TODO: placeholder for self-test functions |
whismanoid | 0:3edb3708c8c5 | 5020 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 5021 | cmdLine.serial().printf("test program not implemented yet"); |
whismanoid | 0:3edb3708c8c5 | 5022 | // |
whismanoid | 0:3edb3708c8c5 | 5023 | #elif APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 5024 | // |
whismanoid | 0:3edb3708c8c5 | 5025 | // TODO: placeholder for self-test functions |
whismanoid | 0:3edb3708c8c5 | 5026 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 5027 | cmdLine.serial().printf("test program not implemented yet"); |
whismanoid | 0:3edb3708c8c5 | 5028 | // |
whismanoid | 0:3edb3708c8c5 | 5029 | #else // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 5030 | // TODO: placeholder for self-test functions |
whismanoid | 0:3edb3708c8c5 | 5031 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 5032 | // |
whismanoid | 0:3edb3708c8c5 | 5033 | #if 0 |
whismanoid | 0:3edb3708c8c5 | 5034 | // Test of the pass/fail report mechanism |
whismanoid | 0:3edb3708c8c5 | 5035 | SelfTest_FAIL(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 5036 | cmdLine.serial().printf("injecting one false failure for test reporting"); |
whismanoid | 0:3edb3708c8c5 | 5037 | #endif |
whismanoid | 0:3edb3708c8c5 | 5038 | // |
whismanoid | 0:3edb3708c8c5 | 5039 | // Report number of pass and number of fail test results |
whismanoid | 0:3edb3708c8c5 | 5040 | #if USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 5041 | tinyTester.Report_Summary(); |
whismanoid | 0:3edb3708c8c5 | 5042 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 5043 | if (tinyTester.nFail == 0) { |
whismanoid | 0:3edb3708c8c5 | 5044 | rgb_led.green(); // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 5045 | } |
whismanoid | 0:3edb3708c8c5 | 5046 | else { |
whismanoid | 0:3edb3708c8c5 | 5047 | rgb_led.red(); // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 5048 | } |
whismanoid | 0:3edb3708c8c5 | 5049 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 5050 | #else // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 5051 | cmdLine.serial().printf("\r\nSummary: %d PASS %d FAIL\r\n", g_SelfTest_nPass, g_SelfTest_nFail); |
whismanoid | 0:3edb3708c8c5 | 5052 | //~ cmdLine.serial().printf(g_SelfTest_nPass); |
whismanoid | 0:3edb3708c8c5 | 5053 | //~ cmdLine.serial().printf(" PASS "); |
whismanoid | 0:3edb3708c8c5 | 5054 | //~ cmdLine.serial().printf(g_SelfTest_nFail); |
whismanoid | 0:3edb3708c8c5 | 5055 | //~ cmdLine.serial().printf(" FAIL\r\n"); |
whismanoid | 0:3edb3708c8c5 | 5056 | if (g_SelfTest_nFail == 0) { |
whismanoid | 0:3edb3708c8c5 | 5057 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 5058 | //~ rgb_led.red(); // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 5059 | rgb_led.green(); // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 5060 | //~ rgb_led.blue(); // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 5061 | //~ rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 5062 | //~ rgb_led.cyan(); // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 5063 | //~ rgb_led.magenta(); // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 5064 | //~ rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 5065 | //~ rgb_led.black(); // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 5066 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 5067 | } |
whismanoid | 0:3edb3708c8c5 | 5068 | #endif // USE_MAXIMTINYTESTER |
whismanoid | 0:3edb3708c8c5 | 5069 | } |
whismanoid | 0:3edb3708c8c5 | 5070 | |
whismanoid | 0:3edb3708c8c5 | 5071 | |
whismanoid | 0:3edb3708c8c5 | 5072 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 5073 | void main_menu_status(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 5074 | { |
whismanoid | 0:3edb3708c8c5 | 5075 | cmdLine.serial().printf("\r\nMain menu"); |
whismanoid | 0:3edb3708c8c5 | 5076 | #if APPLICATION_MAX5715 // main_menu_status banner |
whismanoid | 0:3edb3708c8c5 | 5077 | cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC"); |
whismanoid | 0:3edb3708c8c5 | 5078 | #elif APPLICATION_MAX11131 // main_menu_status banner |
whismanoid | 0:3edb3708c8c5 | 5079 | cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC"); |
whismanoid | 0:3edb3708c8c5 | 5080 | #elif APPLICATION_MAX5171 // main_menu_status banner |
whismanoid | 0:3edb3708c8c5 | 5081 | cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC"); |
whismanoid | 0:3edb3708c8c5 | 5082 | #elif APPLICATION_MAX11410 // main_menu_status banner |
whismanoid | 0:3edb3708c8c5 | 5083 | cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC"); |
whismanoid | 0:3edb3708c8c5 | 5084 | #elif APPLICATION_MAX12345 // main_menu_status banner |
whismanoid | 0:3edb3708c8c5 | 5085 | cmdLine.serial().printf(" MAX12345"); |
whismanoid | 0:3edb3708c8c5 | 5086 | #else |
whismanoid | 0:3edb3708c8c5 | 5087 | //cmdLine.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 5088 | #endif |
whismanoid | 0:3edb3708c8c5 | 5089 | cmdLine.serial().printf(" %s", TARGET_NAME); |
whismanoid | 0:3edb3708c8c5 | 5090 | if (cmdLine.nameStr()) |
whismanoid | 0:3edb3708c8c5 | 5091 | { |
whismanoid | 0:3edb3708c8c5 | 5092 | cmdLine.serial().printf(" [%s]", cmdLine.nameStr()); |
whismanoid | 0:3edb3708c8c5 | 5093 | } |
whismanoid | 0:3edb3708c8c5 | 5094 | #if USE_COMMAND_BUFFER |
whismanoid | 0:3edb3708c8c5 | 5095 | //cmdLine.serial().printf(" [USE_COMMAND_BUFFER]"); |
whismanoid | 0:3edb3708c8c5 | 5096 | #endif |
whismanoid | 0:3edb3708c8c5 | 5097 | #if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 5098 | cmdLine.serial().printf(" [Button1=DemoConfig1]"); |
whismanoid | 0:3edb3708c8c5 | 5099 | #endif |
whismanoid | 0:3edb3708c8c5 | 5100 | #if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 5101 | cmdLine.serial().printf(" [Button2=DemoConfig2]"); |
whismanoid | 0:3edb3708c8c5 | 5102 | #endif |
whismanoid | 0:3edb3708c8c5 | 5103 | #if HAS_BUTTON1_DEMO |
whismanoid | 0:3edb3708c8c5 | 5104 | // print BUTTON1 status |
whismanoid | 0:3edb3708c8c5 | 5105 | cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read()); |
whismanoid | 0:3edb3708c8c5 | 5106 | #endif |
whismanoid | 0:3edb3708c8c5 | 5107 | #if HAS_BUTTON2_DEMO |
whismanoid | 0:3edb3708c8c5 | 5108 | // print BUTTON1 status |
whismanoid | 0:3edb3708c8c5 | 5109 | cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read()); |
whismanoid | 0:3edb3708c8c5 | 5110 | #endif |
whismanoid | 0:3edb3708c8c5 | 5111 | cmdLine.serial().printf("\r\n ? -- help"); |
whismanoid | 0:3edb3708c8c5 | 5112 | } |
whismanoid | 0:3edb3708c8c5 | 5113 | |
whismanoid | 0:3edb3708c8c5 | 5114 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 5115 | void main_menu_help(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 5116 | { |
whismanoid | 0:3edb3708c8c5 | 5117 | // ? -- help |
whismanoid | 0:3edb3708c8c5 | 5118 | //~ cmdLine.serial().printf("\r\nMenu:"); |
whismanoid | 0:3edb3708c8c5 | 5119 | cmdLine.serial().printf("\r\n # -- lines beginning with # are comments"); |
whismanoid | 0:3edb3708c8c5 | 5120 | cmdLine.serial().printf("\r\n . -- SelfTest"); |
whismanoid | 0:3edb3708c8c5 | 5121 | //cmdLine.serial().printf("\r\n ! -- Initial Configuration"); |
whismanoid | 0:3edb3708c8c5 | 5122 | // |
whismanoid | 0:3edb3708c8c5 | 5123 | // % standardize diagnostic commands |
whismanoid | 0:3edb3708c8c5 | 5124 | // %Hpin -- digital output high |
whismanoid | 0:3edb3708c8c5 | 5125 | // %Lpin -- digital output low |
whismanoid | 0:3edb3708c8c5 | 5126 | // %?pin -- digital input |
whismanoid | 0:3edb3708c8c5 | 5127 | // %A %Apin -- analog input |
whismanoid | 0:3edb3708c8c5 | 5128 | // %Ppin df=xx -- pwm output |
whismanoid | 0:3edb3708c8c5 | 5129 | // %Wpin -- measure high pulsewidth input in usec |
whismanoid | 0:3edb3708c8c5 | 5130 | // %wpin -- measure low pulsewidth input in usec |
whismanoid | 0:3edb3708c8c5 | 5131 | // %I... -- I2C diagnostics |
whismanoid | 0:3edb3708c8c5 | 5132 | // %IP -- I2C probe |
whismanoid | 0:3edb3708c8c5 | 5133 | // %IC scl=100khz ADDR=? -- I2C configure |
whismanoid | 0:3edb3708c8c5 | 5134 | // %IW ADDR=? cmd=? data,data,data -- write |
whismanoid | 0:3edb3708c8c5 | 5135 | // %IR ADDR=? RD=? -- read |
whismanoid | 0:3edb3708c8c5 | 5136 | // %I^ cmd=? -- i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 5137 | // %S... -- SPI diagnostics |
whismanoid | 0:3edb3708c8c5 | 5138 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 0:3edb3708c8c5 | 5139 | // %SW -- write (write and read) |
whismanoid | 0:3edb3708c8c5 | 5140 | // %SR -- read (alias for %SW because SPI always write and read) |
whismanoid | 0:3edb3708c8c5 | 5141 | // A-Z,a-z,0-9 reserved for application use |
whismanoid | 0:3edb3708c8c5 | 5142 | // |
whismanoid | 0:3edb3708c8c5 | 5143 | #if HAS_digitalInOuts |
whismanoid | 0:3edb3708c8c5 | 5144 | // %Hpin -- digital output high |
whismanoid | 0:3edb3708c8c5 | 5145 | // %Lpin -- digital output low |
whismanoid | 0:3edb3708c8c5 | 5146 | // %?pin -- digital input |
whismanoid | 0:3edb3708c8c5 | 5147 | cmdLine.serial().printf("\r\n %%Hn {pin:"); |
whismanoid | 0:3edb3708c8c5 | 5148 | list_digitalInOutPins(cmdLine.serial()); |
whismanoid | 0:3edb3708c8c5 | 5149 | cmdLine.serial().printf("} -- High Output"); |
whismanoid | 0:3edb3708c8c5 | 5150 | cmdLine.serial().printf("\r\n %%Ln {pin:"); |
whismanoid | 0:3edb3708c8c5 | 5151 | list_digitalInOutPins(cmdLine.serial()); |
whismanoid | 0:3edb3708c8c5 | 5152 | cmdLine.serial().printf("} -- Low Output"); |
whismanoid | 0:3edb3708c8c5 | 5153 | cmdLine.serial().printf("\r\n %%?n {pin:"); |
whismanoid | 0:3edb3708c8c5 | 5154 | list_digitalInOutPins(cmdLine.serial()); |
whismanoid | 0:3edb3708c8c5 | 5155 | cmdLine.serial().printf("} -- Input"); |
whismanoid | 0:3edb3708c8c5 | 5156 | #endif |
whismanoid | 0:3edb3708c8c5 | 5157 | |
whismanoid | 0:3edb3708c8c5 | 5158 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 5159 | // Menu A) analogRead A0..7 |
whismanoid | 0:3edb3708c8c5 | 5160 | // %A %Apin -- analog input |
whismanoid | 0:3edb3708c8c5 | 5161 | // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0) |
whismanoid | 0:3edb3708c8c5 | 5162 | cmdLine.serial().printf("\r\n %%A -- analogRead"); |
whismanoid | 0:3edb3708c8c5 | 5163 | #endif |
whismanoid | 0:3edb3708c8c5 | 5164 | |
whismanoid | 0:3edb3708c8c5 | 5165 | #if HAS_SPI2_MAX541 |
whismanoid | 0:3edb3708c8c5 | 5166 | // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs); |
whismanoid | 0:3edb3708c8c5 | 5167 | cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)"); |
whismanoid | 0:3edb3708c8c5 | 5168 | #endif |
whismanoid | 0:3edb3708c8c5 | 5169 | |
whismanoid | 0:3edb3708c8c5 | 5170 | #if HAS_pwmDrivers |
whismanoid | 0:3edb3708c8c5 | 5171 | // Menu P) PWM D3|5|6|9|10|11, Output 0..255 |
whismanoid | 0:3edb3708c8c5 | 5172 | // %Ppin df=xx -- pwm output |
whismanoid | 0:3edb3708c8c5 | 5173 | cmdLine.serial().printf("\r\n %%P {High|Low|.|>|<|S|F} 0..255, {pin: *"); |
whismanoid | 0:3edb3708c8c5 | 5174 | // analogWrite(analogOutPin, outputValue_0_255) // PWM digital output 0..255: analogWrite works on digital pins 3, 5, 6, 9, 10, and 11. Frequency is 490 Hz except pins 5 and 6 are 980 Hz. |
whismanoid | 0:3edb3708c8c5 | 5175 | //cmdLine.serial().printf("\r\n P) pwmDriver {High|Low|.|>|<|S|F} {pin: *"); |
whismanoid | 0:3edb3708c8c5 | 5176 | list_pwmDriverPins(cmdLine.serial()); |
whismanoid | 0:3edb3708c8c5 | 5177 | cmdLine.serial().printf("} -- PWM Output"); |
whismanoid | 0:3edb3708c8c5 | 5178 | #endif |
whismanoid | 0:3edb3708c8c5 | 5179 | |
whismanoid | 0:3edb3708c8c5 | 5180 | #if HAS_I2C // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 5181 | // TODO: support I2C HAS_I2C // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 5182 | // VERIFY: I2C utility commands SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 5183 | // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 5184 | // %I... -- I2C diagnostics |
whismanoid | 0:3edb3708c8c5 | 5185 | // %IP -- I2C probe |
whismanoid | 0:3edb3708c8c5 | 5186 | // %IC scl=100khz ADDR=? -- I2C configure |
whismanoid | 0:3edb3708c8c5 | 5187 | // %IW byte byte ... byte RD=? ADDR=0x -- write |
whismanoid | 0:3edb3708c8c5 | 5188 | // %IR ADDR=? RD=? -- read |
whismanoid | 0:3edb3708c8c5 | 5189 | // %I^ cmd=? -- i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 5190 | //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope |
whismanoid | 0:3edb3708c8c5 | 5191 | cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config", |
whismanoid | 0:3edb3708c8c5 | 5192 | g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz, |
whismanoid | 0:3edb3708c8c5 | 5193 | (g_I2C_SCL_Hz / 1000.)); |
whismanoid | 0:3edb3708c8c5 | 5194 | cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read", |
whismanoid | 0:3edb3708c8c5 | 5195 | g_I2C_deviceAddress7); |
whismanoid | 0:3edb3708c8c5 | 5196 | // |
whismanoid | 0:3edb3708c8c5 | 5197 | #if SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 5198 | // Menu ^ cmd=?) i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 5199 | cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data"); |
whismanoid | 0:3edb3708c8c5 | 5200 | // test low-level I2C i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 5201 | #endif // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 5202 | //cmdLine.serial().printf(" H) Hunt for attached I2C devices"); |
whismanoid | 0:3edb3708c8c5 | 5203 | cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices"); |
whismanoid | 0:3edb3708c8c5 | 5204 | // cmdLine.serial().printf(" s) search i2c address"); |
whismanoid | 0:3edb3708c8c5 | 5205 | #endif // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 5206 | |
whismanoid | 0:3edb3708c8c5 | 5207 | #if HAS_SPI // SUPPORT_SPI |
whismanoid | 0:3edb3708c8c5 | 5208 | // TODO: support SPI HAS_SPI // SUPPORT_SPI |
whismanoid | 0:3edb3708c8c5 | 5209 | // SPI test command S (mosiData)+ |
whismanoid | 0:3edb3708c8c5 | 5210 | // %S... -- SPI diagnostics |
whismanoid | 0:3edb3708c8c5 | 5211 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 0:3edb3708c8c5 | 5212 | // %SW -- write (write and read) |
whismanoid | 0:3edb3708c8c5 | 5213 | // %SR -- read (alias for %SW because SPI always write and read) |
whismanoid | 0:3edb3708c8c5 | 5214 | // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 5215 | // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 5216 | // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 5217 | // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 5218 | // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default) |
whismanoid | 0:3edb3708c8c5 | 5219 | // mode | POL PHA |
whismanoid | 0:3edb3708c8c5 | 5220 | // -----+-------- |
whismanoid | 0:3edb3708c8c5 | 5221 | // 0 | 0 0 |
whismanoid | 0:3edb3708c8c5 | 5222 | // 1 | 0 1 |
whismanoid | 0:3edb3708c8c5 | 5223 | // 2 | 1 0 |
whismanoid | 0:3edb3708c8c5 | 5224 | // 3 | 1 1 |
whismanoid | 0:3edb3708c8c5 | 5225 | //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0"); |
whismanoid | 0:3edb3708c8c5 | 5226 | // 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 | 5227 | cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config", |
whismanoid | 0:3edb3708c8c5 | 5228 | g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.), |
whismanoid | 0:3edb3708c8c5 | 5229 | ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0), |
whismanoid | 0:3edb3708c8c5 | 5230 | ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0)); |
whismanoid | 0:3edb3708c8c5 | 5231 | cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes"); |
whismanoid | 0:3edb3708c8c5 | 5232 | // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0 |
whismanoid | 0:3edb3708c8c5 | 5233 | #endif // SUPPORT_SPI |
whismanoid | 0:3edb3708c8c5 | 5234 | // |
whismanoid | 0:3edb3708c8c5 | 5235 | // Application-specific commands (help text) here |
whismanoid | 0:3edb3708c8c5 | 5236 | // |
whismanoid | 0:3edb3708c8c5 | 5237 | #if APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 5238 | # if APPLICATION_MAX5715 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5239 | # elif APPLICATION_MAX11131 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5240 | # elif APPLICATION_MAX5171 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5241 | # elif APPLICATION_MAX11410 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5242 | # elif APPLICATION_MAX12345 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5243 | # else |
whismanoid | 0:3edb3708c8c5 | 5244 | cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 5245 | # endif |
whismanoid | 0:3edb3708c8c5 | 5246 | #endif // APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 5247 | // |
whismanoid | 0:3edb3708c8c5 | 5248 | #if APPLICATION_MAX5715 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5249 | cmdLine.serial().printf("\r\n 0 ch=? code=? -- CODEn"); |
whismanoid | 0:3edb3708c8c5 | 5250 | cmdLine.serial().printf("\r\n 1 ch=? -- LOADn"); |
whismanoid | 0:3edb3708c8c5 | 5251 | cmdLine.serial().printf("\r\n 2 ch=? code=? -- CODEnLOADall"); |
whismanoid | 0:3edb3708c8c5 | 5252 | cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); |
whismanoid | 0:3edb3708c8c5 | 5253 | cmdLine.serial().printf("\r\n 40 ch=? -- POWERn_Normal"); |
whismanoid | 0:3edb3708c8c5 | 5254 | cmdLine.serial().printf("\r\n 41 ch=? -- POWERn_PD1k"); |
whismanoid | 0:3edb3708c8c5 | 5255 | cmdLine.serial().printf("\r\n 42 ch=? -- POWERn_PD100k"); |
whismanoid | 0:3edb3708c8c5 | 5256 | cmdLine.serial().printf("\r\n 43 ch=? -- POWERn_PDHiZ"); |
whismanoid | 0:3edb3708c8c5 | 5257 | cmdLine.serial().printf("\r\n 50 -- SW_CLEAR"); |
whismanoid | 0:3edb3708c8c5 | 5258 | cmdLine.serial().printf("\r\n 51 -- SW_RESET"); |
whismanoid | 0:3edb3708c8c5 | 5259 | cmdLine.serial().printf("\r\n 60 ch=? -- CONFIGn_LATCHED"); |
whismanoid | 0:3edb3708c8c5 | 5260 | cmdLine.serial().printf("\r\n 61 ch=? -- CONFIGn_TRANSPARENT"); |
whismanoid | 0:3edb3708c8c5 | 5261 | cmdLine.serial().printf("\r\n 68 -- CONFIGall_LATCHED"); |
whismanoid | 0:3edb3708c8c5 | 5262 | cmdLine.serial().printf("\r\n 69 -- CONFIGall_TRANSPARENT"); |
whismanoid | 0:3edb3708c8c5 | 5263 | cmdLine.serial().printf("\r\n 70 -- REF_EXT"); |
whismanoid | 0:3edb3708c8c5 | 5264 | cmdLine.serial().printf("\r\n 71 -- REF_2V500"); |
whismanoid | 0:3edb3708c8c5 | 5265 | cmdLine.serial().printf("\r\n 72 -- REF_2V048"); |
whismanoid | 0:3edb3708c8c5 | 5266 | cmdLine.serial().printf("\r\n 73 -- REF_4V096"); |
whismanoid | 0:3edb3708c8c5 | 5267 | cmdLine.serial().printf("\r\n 74 -- REF_AlwaysOn_EXT"); |
whismanoid | 0:3edb3708c8c5 | 5268 | cmdLine.serial().printf("\r\n 75 -- REF_AlwaysOn_2V500"); |
whismanoid | 0:3edb3708c8c5 | 5269 | cmdLine.serial().printf("\r\n 76 -- REF_AlwaysOn_2V048"); |
whismanoid | 0:3edb3708c8c5 | 5270 | cmdLine.serial().printf("\r\n 77 -- REF_AlwaysOn_4V096"); |
whismanoid | 0:3edb3708c8c5 | 5271 | cmdLine.serial().printf("\r\n 80 code=? -- CODEall"); |
whismanoid | 0:3edb3708c8c5 | 5272 | cmdLine.serial().printf("\r\n 81 -- LOADall"); |
whismanoid | 0:3edb3708c8c5 | 5273 | cmdLine.serial().printf("\r\n 82 code=? -- CODEallLOADall"); |
whismanoid | 0:3edb3708c8c5 | 5274 | //cmdLine.serial().printf("\r\n 83 code=? -- CODEallLOADall"); |
whismanoid | 0:3edb3708c8c5 | 5275 | // |
whismanoid | 0:3edb3708c8c5 | 5276 | // Menu @ -- print device configuration |
whismanoid | 0:3edb3708c8c5 | 5277 | cmdLine.serial().printf("\r\n @ -- print MAX5715 configuration"); |
whismanoid | 0:3edb3708c8c5 | 5278 | // |
whismanoid | 0:3edb3708c8c5 | 5279 | // MAX5717 menu function to drive MAX5717_LDACb_Pin LDAC# |
whismanoid | 0:3edb3708c8c5 | 5280 | // Note: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 5281 | cmdLine.serial().printf("\r\n L -- LDAC# pulse LH high LL low"); |
whismanoid | 0:3edb3708c8c5 | 5282 | // MAX5717 menu function to drive MAX5717_CLRb_Pin CLR# |
whismanoid | 0:3edb3708c8c5 | 5283 | cmdLine.serial().printf("\r\n C -- CLR# pulse CH high CL low"); |
whismanoid | 0:3edb3708c8c5 | 5284 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 5285 | // |
whismanoid | 0:3edb3708c8c5 | 5286 | #if APPLICATION_MAX11131 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5287 | // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void); |
whismanoid | 0:3edb3708c8c5 | 5288 | cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead"); |
whismanoid | 0:3edb3708c8c5 | 5289 | // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 5290 | cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual"); |
whismanoid | 0:3edb3708c8c5 | 5291 | // 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 | 5292 | cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat"); |
whismanoid | 0:3edb3708c8c5 | 5293 | // 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 | 5294 | cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock"); |
whismanoid | 0:3edb3708c8c5 | 5295 | // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 5296 | cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock"); |
whismanoid | 0:3edb3708c8c5 | 5297 | // 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 | 5298 | cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock"); |
whismanoid | 0:3edb3708c8c5 | 5299 | // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 5300 | cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock"); |
whismanoid | 0:3edb3708c8c5 | 5301 | // 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 | 5302 | cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock"); |
whismanoid | 0:3edb3708c8c5 | 5303 | // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 5304 | cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock"); |
whismanoid | 0:3edb3708c8c5 | 5305 | // 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 | 5306 | cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock"); |
whismanoid | 0:3edb3708c8c5 | 5307 | cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration"); |
whismanoid | 0:3edb3708c8c5 | 5308 | cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range"); |
whismanoid | 0:3edb3708c8c5 | 5309 | // cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual"); |
whismanoid | 0:3edb3708c8c5 | 5310 | // Note: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 5311 | #endif // APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5312 | // |
whismanoid | 0:3edb3708c8c5 | 5313 | #if APPLICATION_MAX5171 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5314 | // TODO1: MAX5171 main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5315 | cmdLine.serial().printf("\r\n 0 code=? -- CODE"); |
whismanoid | 0:3edb3708c8c5 | 5316 | cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD"); |
whismanoid | 0:3edb3708c8c5 | 5317 | cmdLine.serial().printf("\r\n 8 -- LOAD"); |
whismanoid | 0:3edb3708c8c5 | 5318 | cmdLine.serial().printf("\r\n c -- NOP"); |
whismanoid | 0:3edb3708c8c5 | 5319 | cmdLine.serial().printf("\r\n d -- SHUTDOWN"); |
whismanoid | 0:3edb3708c8c5 | 5320 | cmdLine.serial().printf("\r\n e0 -- UPO_LOW"); |
whismanoid | 0:3edb3708c8c5 | 5321 | cmdLine.serial().printf("\r\n e8 -- UPO_HIGH"); |
whismanoid | 0:3edb3708c8c5 | 5322 | cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 5323 | cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 5324 | // Note: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 5325 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5326 | // |
whismanoid | 0:3edb3708c8c5 | 5327 | #if APPLICATION_MAX11410 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5328 | // TODO1: MAX11410 main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5329 | cmdLine.serial().printf("\r\n w reg=? data=? -- write register"); |
whismanoid | 0:3edb3708c8c5 | 5330 | cmdLine.serial().printf("\r\n r reg=? -- read register"); |
whismanoid | 0:3edb3708c8c5 | 5331 | cmdLine.serial().printf("\r\n TC -- thermocouple config"); |
whismanoid | 0:3edb3708c8c5 | 5332 | cmdLine.serial().printf("\r\n T -- RTD measurement"); |
whismanoid | 0:3edb3708c8c5 | 5333 | cmdLine.serial().printf("\r\n RC -- thermocouple config"); |
whismanoid | 0:3edb3708c8c5 | 5334 | cmdLine.serial().printf("\r\n R -- RTD measurement"); |
whismanoid | 0:3edb3708c8c5 | 5335 | // Note: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 5336 | #endif // APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 5337 | // |
whismanoid | 0:3edb3708c8c5 | 5338 | #if APPLICATION_MAX12345 // main_menu_help |
whismanoid | 0:3edb3708c8c5 | 5339 | cmdLine.serial().printf("\r\n 0 -- something"); |
whismanoid | 0:3edb3708c8c5 | 5340 | cmdLine.serial().printf("\r\n 1 -- something"); |
whismanoid | 0:3edb3708c8c5 | 5341 | cmdLine.serial().printf("\r\n 2 -- something"); |
whismanoid | 0:3edb3708c8c5 | 5342 | cmdLine.serial().printf("\r\n A -- something"); |
whismanoid | 0:3edb3708c8c5 | 5343 | cmdLine.serial().printf("\r\n B -- something"); |
whismanoid | 0:3edb3708c8c5 | 5344 | cmdLine.serial().printf("\r\n C -- something"); |
whismanoid | 0:3edb3708c8c5 | 5345 | // Note: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 5346 | #endif // APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 5347 | // |
whismanoid | 0:3edb3708c8c5 | 5348 | } |
whismanoid | 0:3edb3708c8c5 | 5349 | |
whismanoid | 0:3edb3708c8c5 | 5350 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 5351 | // main menu command-line parser |
whismanoid | 0:3edb3708c8c5 | 5352 | // invoked by CmdLine::append(char ch) or CmdLine::idleAppendIfReadable() |
whismanoid | 0:3edb3708c8c5 | 5353 | #if USE_COMMAND_BUFFER |
whismanoid | 0:3edb3708c8c5 | 5354 | void main_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 0:3edb3708c8c5 | 5355 | { |
whismanoid | 0:3edb3708c8c5 | 5356 | // DIAGNOSTIC: print line buffer |
whismanoid | 0:3edb3708c8c5 | 5357 | //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 5358 | // |
whismanoid | 0:3edb3708c8c5 | 5359 | switch (cmdLine[0]) |
whismanoid | 0:3edb3708c8c5 | 5360 | { |
whismanoid | 0:3edb3708c8c5 | 5361 | case '?': |
whismanoid | 0:3edb3708c8c5 | 5362 | main_menu_status(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 5363 | main_menu_help(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 5364 | // print command prompt |
whismanoid | 0:3edb3708c8c5 | 5365 | //cmdLine.serial().printf("\r\n>"); |
whismanoid | 0:3edb3708c8c5 | 5366 | break; |
whismanoid | 0:3edb3708c8c5 | 5367 | case '\r': case '\n': // ignore blank line |
whismanoid | 0:3edb3708c8c5 | 5368 | case '\0': // ignore empty line |
whismanoid | 0:3edb3708c8c5 | 5369 | case '#': // ignore comment line |
whismanoid | 0:3edb3708c8c5 | 5370 | // # -- lines beginning with # are comments |
whismanoid | 0:3edb3708c8c5 | 5371 | main_menu_status(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 5372 | //~ main_menu_help(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 5373 | // print command prompt |
whismanoid | 0:3edb3708c8c5 | 5374 | //cmdLine.serial().printf("\r\n>"); |
whismanoid | 0:3edb3708c8c5 | 5375 | break; |
whismanoid | 0:3edb3708c8c5 | 5376 | #if ECHO_EOF_ON_EOL |
whismanoid | 0:3edb3708c8c5 | 5377 | case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file |
whismanoid | 0:3edb3708c8c5 | 5378 | cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting |
whismanoid | 0:3edb3708c8c5 | 5379 | diagnostic_led_EOF(); |
whismanoid | 0:3edb3708c8c5 | 5380 | break; |
whismanoid | 0:3edb3708c8c5 | 5381 | case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file |
whismanoid | 0:3edb3708c8c5 | 5382 | cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting |
whismanoid | 0:3edb3708c8c5 | 5383 | diagnostic_led_EOF(); |
whismanoid | 0:3edb3708c8c5 | 5384 | break; |
whismanoid | 0:3edb3708c8c5 | 5385 | #endif |
whismanoid | 0:3edb3708c8c5 | 5386 | #if APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 5387 | case '.': |
whismanoid | 0:3edb3708c8c5 | 5388 | { |
whismanoid | 0:3edb3708c8c5 | 5389 | // . -- SelfTest |
whismanoid | 0:3edb3708c8c5 | 5390 | cmdLine.serial().printf("SelfTest()"); |
whismanoid | 0:3edb3708c8c5 | 5391 | SelfTest(cmdLine); |
whismanoid | 0:3edb3708c8c5 | 5392 | } |
whismanoid | 0:3edb3708c8c5 | 5393 | break; |
whismanoid | 0:3edb3708c8c5 | 5394 | case '%': |
whismanoid | 0:3edb3708c8c5 | 5395 | { |
whismanoid | 0:3edb3708c8c5 | 5396 | // TODO: consolidate "Arduino Pins Monitor" under '%' submenu -- APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 5397 | // % standardize diagnostic commands |
whismanoid | 0:3edb3708c8c5 | 5398 | // %Hpin -- digital output high |
whismanoid | 0:3edb3708c8c5 | 5399 | // %Lpin -- digital output low |
whismanoid | 0:3edb3708c8c5 | 5400 | // %?pin -- digital input |
whismanoid | 0:3edb3708c8c5 | 5401 | // %A %Apin -- analog input |
whismanoid | 0:3edb3708c8c5 | 5402 | // %Ppin df=xx -- pwm output |
whismanoid | 0:3edb3708c8c5 | 5403 | // %Wpin -- measure high pulsewidth input in usec |
whismanoid | 0:3edb3708c8c5 | 5404 | // %wpin -- measure low pulsewidth input in usec |
whismanoid | 0:3edb3708c8c5 | 5405 | // %I... -- I2C diagnostics |
whismanoid | 0:3edb3708c8c5 | 5406 | // %IP -- I2C probe |
whismanoid | 0:3edb3708c8c5 | 5407 | // %IC scl=100khz ADDR=? -- I2C configure |
whismanoid | 0:3edb3708c8c5 | 5408 | // %IW byte byte ... byte RD=? ADDR=0x -- write |
whismanoid | 0:3edb3708c8c5 | 5409 | // %IR ADDR=? RD=? -- read |
whismanoid | 0:3edb3708c8c5 | 5410 | // %I^ cmd=? -- i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 5411 | // %S... -- SPI diagnostics |
whismanoid | 0:3edb3708c8c5 | 5412 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 0:3edb3708c8c5 | 5413 | // %SW -- write (write and read) |
whismanoid | 0:3edb3708c8c5 | 5414 | // %SR -- read (alias for %SW because SPI always write and read) |
whismanoid | 0:3edb3708c8c5 | 5415 | // A-Z,a-z,0-9 reserved for application use |
whismanoid | 0:3edb3708c8c5 | 5416 | // |
whismanoid | 0:3edb3708c8c5 | 5417 | // get pinIndex from cmdLine[2] |
whismanoid | 0:3edb3708c8c5 | 5418 | //int pinIndex = cmdLine[2]; |
whismanoid | 0:3edb3708c8c5 | 5419 | // *** warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith] |
whismanoid | 0:3edb3708c8c5 | 5420 | //int pinIndex = strtoul((char *)((void *)(cmdLine.str()) + 2), NULL, 10); // strtol(str, NULL, 10): get decimal value |
whismanoid | 0:3edb3708c8c5 | 5421 | // ^ |
whismanoid | 0:3edb3708c8c5 | 5422 | char strPinIndex[3]; |
whismanoid | 0:3edb3708c8c5 | 5423 | strPinIndex[0] = cmdLine[2]; |
whismanoid | 0:3edb3708c8c5 | 5424 | strPinIndex[1] = cmdLine[3]; |
whismanoid | 0:3edb3708c8c5 | 5425 | strPinIndex[2] = '\0'; |
whismanoid | 0:3edb3708c8c5 | 5426 | int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value |
whismanoid | 0:3edb3708c8c5 | 5427 | //cmdLine.serial().printf(" pinIndex=%d ", pinIndex); |
whismanoid | 0:3edb3708c8c5 | 5428 | // |
whismanoid | 0:3edb3708c8c5 | 5429 | // get next character |
whismanoid | 0:3edb3708c8c5 | 5430 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 5431 | { |
whismanoid | 0:3edb3708c8c5 | 5432 | #if HAS_digitalInOuts |
whismanoid | 0:3edb3708c8c5 | 5433 | case 'H': case 'h': |
whismanoid | 0:3edb3708c8c5 | 5434 | { |
whismanoid | 0:3edb3708c8c5 | 5435 | // %Hpin -- digital output high |
whismanoid | 0:3edb3708c8c5 | 5436 | #if ARDUINO_STYLE |
whismanoid | 0:3edb3708c8c5 | 5437 | pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 |
whismanoid | 0:3edb3708c8c5 | 5438 | digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 |
whismanoid | 0:3edb3708c8c5 | 5439 | #else |
whismanoid | 0:3edb3708c8c5 | 5440 | DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); |
whismanoid | 0:3edb3708c8c5 | 5441 | digitalInOutPin.output(); |
whismanoid | 0:3edb3708c8c5 | 5442 | digitalInOutPin.write(1); |
whismanoid | 0:3edb3708c8c5 | 5443 | #endif |
whismanoid | 0:3edb3708c8c5 | 5444 | cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex); |
whismanoid | 0:3edb3708c8c5 | 5445 | } |
whismanoid | 0:3edb3708c8c5 | 5446 | break; |
whismanoid | 0:3edb3708c8c5 | 5447 | case 'L': case 'l': |
whismanoid | 0:3edb3708c8c5 | 5448 | { |
whismanoid | 0:3edb3708c8c5 | 5449 | // %Lpin -- digital output low |
whismanoid | 0:3edb3708c8c5 | 5450 | #if ARDUINO_STYLE |
whismanoid | 0:3edb3708c8c5 | 5451 | pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 |
whismanoid | 0:3edb3708c8c5 | 5452 | digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 |
whismanoid | 0:3edb3708c8c5 | 5453 | #else |
whismanoid | 0:3edb3708c8c5 | 5454 | DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); |
whismanoid | 0:3edb3708c8c5 | 5455 | digitalInOutPin.output(); |
whismanoid | 0:3edb3708c8c5 | 5456 | digitalInOutPin.write(0); |
whismanoid | 0:3edb3708c8c5 | 5457 | #endif |
whismanoid | 0:3edb3708c8c5 | 5458 | cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex); |
whismanoid | 0:3edb3708c8c5 | 5459 | } |
whismanoid | 0:3edb3708c8c5 | 5460 | break; |
whismanoid | 0:3edb3708c8c5 | 5461 | case '?': |
whismanoid | 0:3edb3708c8c5 | 5462 | { |
whismanoid | 0:3edb3708c8c5 | 5463 | // %?pin -- digital input |
whismanoid | 0:3edb3708c8c5 | 5464 | #if ARDUINO_STYLE |
whismanoid | 0:3edb3708c8c5 | 5465 | pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 |
whismanoid | 0:3edb3708c8c5 | 5466 | #else |
whismanoid | 0:3edb3708c8c5 | 5467 | DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); |
whismanoid | 0:3edb3708c8c5 | 5468 | digitalInOutPin.input(); |
whismanoid | 0:3edb3708c8c5 | 5469 | #endif |
whismanoid | 0:3edb3708c8c5 | 5470 | microUSBserial.printf(" digitalInOutPin %d Input ", pinIndex); |
whismanoid | 0:3edb3708c8c5 | 5471 | #if ARDUINO_STYLE |
whismanoid | 0:3edb3708c8c5 | 5472 | int value = digitalRead(pinIndex); |
whismanoid | 0:3edb3708c8c5 | 5473 | #else |
whismanoid | 0:3edb3708c8c5 | 5474 | int value = digitalInOutPin.read(); |
whismanoid | 0:3edb3708c8c5 | 5475 | #endif |
whismanoid | 0:3edb3708c8c5 | 5476 | cmdLine.serial().printf("%d ", value); |
whismanoid | 0:3edb3708c8c5 | 5477 | } |
whismanoid | 0:3edb3708c8c5 | 5478 | break; |
whismanoid | 0:3edb3708c8c5 | 5479 | #endif |
whismanoid | 0:3edb3708c8c5 | 5480 | // |
whismanoid | 0:3edb3708c8c5 | 5481 | #if HAS_analogIns |
whismanoid | 0:3edb3708c8c5 | 5482 | case 'A': case 'a': |
whismanoid | 0:3edb3708c8c5 | 5483 | { |
whismanoid | 0:3edb3708c8c5 | 5484 | // %A %Apin -- analog input |
whismanoid | 0:3edb3708c8c5 | 5485 | #if analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 5486 | // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. |
whismanoid | 0:3edb3708c8c5 | 5487 | for (int pinIndex = 0; pinIndex < 2; pinIndex++) |
whismanoid | 0:3edb3708c8c5 | 5488 | { |
whismanoid | 0:3edb3708c8c5 | 5489 | int cPinIndex = '0' + pinIndex; |
whismanoid | 0:3edb3708c8c5 | 5490 | AnalogIn& analogInPin = find_analogInPin(cPinIndex); |
whismanoid | 0:3edb3708c8c5 | 5491 | float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; |
whismanoid | 0:3edb3708c8c5 | 5492 | float normValue_0_1 = analogInPin.read(); |
whismanoid | 0:3edb3708c8c5 | 5493 | // |
whismanoid | 0:3edb3708c8c5 | 5494 | int pinIndexH = pinIndex + 4; |
whismanoid | 0:3edb3708c8c5 | 5495 | int cPinIndexH = '0' + pinIndexH; |
whismanoid | 0:3edb3708c8c5 | 5496 | AnalogIn& analogInPinH = find_analogInPin(cPinIndexH); |
whismanoid | 0:3edb3708c8c5 | 5497 | float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH]; |
whismanoid | 0:3edb3708c8c5 | 5498 | float normValueH_0_1 = analogInPinH.read(); |
whismanoid | 0:3edb3708c8c5 | 5499 | // |
whismanoid | 0:3edb3708c8c5 | 5500 | cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV \r\n", |
whismanoid | 0:3edb3708c8c5 | 5501 | cPinIndex, |
whismanoid | 0:3edb3708c8c5 | 5502 | normValue_0_1 * 100.0, |
whismanoid | 0:3edb3708c8c5 | 5503 | normValue_0_1 * adc_full_scale_voltage, |
whismanoid | 0:3edb3708c8c5 | 5504 | cPinIndexH, |
whismanoid | 0:3edb3708c8c5 | 5505 | normValueH_0_1 * 100.0, |
whismanoid | 0:3edb3708c8c5 | 5506 | normValueH_0_1 * adc_full_scale_voltageH |
whismanoid | 0:3edb3708c8c5 | 5507 | ); |
whismanoid | 0:3edb3708c8c5 | 5508 | } |
whismanoid | 0:3edb3708c8c5 | 5509 | for (int pinIndex = 2; pinIndex < 4; pinIndex++) |
whismanoid | 0:3edb3708c8c5 | 5510 | { |
whismanoid | 0:3edb3708c8c5 | 5511 | int cPinIndex = '0' + pinIndex; |
whismanoid | 0:3edb3708c8c5 | 5512 | AnalogIn& analogInPin = find_analogInPin(cPinIndex); |
whismanoid | 0:3edb3708c8c5 | 5513 | float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; |
whismanoid | 0:3edb3708c8c5 | 5514 | float normValue_0_1 = analogInPin.read(); |
whismanoid | 0:3edb3708c8c5 | 5515 | // |
whismanoid | 0:3edb3708c8c5 | 5516 | cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n", |
whismanoid | 0:3edb3708c8c5 | 5517 | cPinIndex, |
whismanoid | 0:3edb3708c8c5 | 5518 | normValue_0_1 * 100.0, |
whismanoid | 0:3edb3708c8c5 | 5519 | normValue_0_1 * adc_full_scale_voltage |
whismanoid | 0:3edb3708c8c5 | 5520 | ); |
whismanoid | 0:3edb3708c8c5 | 5521 | } |
whismanoid | 0:3edb3708c8c5 | 5522 | #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 5523 | // Platform board uses simple analog inputs |
whismanoid | 0:3edb3708c8c5 | 5524 | // assume standard Arduino analog inputs A0-A5 |
whismanoid | 0:3edb3708c8c5 | 5525 | for (int pinIndex = 0; pinIndex < 6; pinIndex++) |
whismanoid | 0:3edb3708c8c5 | 5526 | { |
whismanoid | 0:3edb3708c8c5 | 5527 | int cPinIndex = '0' + pinIndex; |
whismanoid | 0:3edb3708c8c5 | 5528 | AnalogIn& analogInPin = find_analogInPin(cPinIndex); |
whismanoid | 0:3edb3708c8c5 | 5529 | float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; |
whismanoid | 0:3edb3708c8c5 | 5530 | float normValue_0_1 = analogInPin.read(); |
whismanoid | 0:3edb3708c8c5 | 5531 | // |
whismanoid | 0:3edb3708c8c5 | 5532 | cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n", |
whismanoid | 0:3edb3708c8c5 | 5533 | cPinIndex, |
whismanoid | 0:3edb3708c8c5 | 5534 | normValue_0_1 * 100.0, |
whismanoid | 0:3edb3708c8c5 | 5535 | normValue_0_1 * adc_full_scale_voltage |
whismanoid | 0:3edb3708c8c5 | 5536 | ); |
whismanoid | 0:3edb3708c8c5 | 5537 | } |
whismanoid | 0:3edb3708c8c5 | 5538 | #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0 |
whismanoid | 0:3edb3708c8c5 | 5539 | } |
whismanoid | 0:3edb3708c8c5 | 5540 | break; |
whismanoid | 0:3edb3708c8c5 | 5541 | #endif |
whismanoid | 0:3edb3708c8c5 | 5542 | // |
whismanoid | 0:3edb3708c8c5 | 5543 | #if HAS_SPI2_MAX541 |
whismanoid | 0:3edb3708c8c5 | 5544 | case 'D': case 'd': |
whismanoid | 0:3edb3708c8c5 | 5545 | { |
whismanoid | 0:3edb3708c8c5 | 5546 | // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV) |
whismanoid | 0:3edb3708c8c5 | 5547 | // MAX541 max541(spi2_max541, spi2_max541_cs); |
whismanoid | 0:3edb3708c8c5 | 5548 | float voltageV = max541.Get_Voltage(); |
whismanoid | 0:3edb3708c8c5 | 5549 | // if (cmdLine[2] == '+') { |
whismanoid | 0:3edb3708c8c5 | 5550 | // // %D+ |
whismanoid | 0:3edb3708c8c5 | 5551 | // voltageV = voltageV * 1.25f; |
whismanoid | 0:3edb3708c8c5 | 5552 | // if (voltageV >= max541.VRef) voltageV = max541.VRef; |
whismanoid | 0:3edb3708c8c5 | 5553 | // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 5554 | // } |
whismanoid | 0:3edb3708c8c5 | 5555 | // else if (cmdLine[2] == '-') { |
whismanoid | 0:3edb3708c8c5 | 5556 | // // %D- |
whismanoid | 0:3edb3708c8c5 | 5557 | // voltageV = voltageV * 0.75f; |
whismanoid | 0:3edb3708c8c5 | 5558 | // if (voltageV < 0.1f) voltageV = 0.1f; |
whismanoid | 0:3edb3708c8c5 | 5559 | // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 5560 | // } |
whismanoid | 0:3edb3708c8c5 | 5561 | if (cmdLine.parse_float("V", voltageV)) |
whismanoid | 0:3edb3708c8c5 | 5562 | { |
whismanoid | 0:3edb3708c8c5 | 5563 | // %D V=1.234 -- set voltage |
whismanoid | 0:3edb3708c8c5 | 5564 | max541.Set_Voltage(voltageV); |
whismanoid | 0:3edb3708c8c5 | 5565 | } |
whismanoid | 0:3edb3708c8c5 | 5566 | else if (cmdLine.parse_float("TEST", voltageV)) |
whismanoid | 0:3edb3708c8c5 | 5567 | { |
whismanoid | 0:3edb3708c8c5 | 5568 | // %D TEST=1.234 -- set voltage and compare with AIN0 |
whismanoid | 0:3edb3708c8c5 | 5569 | SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 5570 | } |
whismanoid | 0:3edb3708c8c5 | 5571 | else if (cmdLine.parse_float("CAL", voltageV)) |
whismanoid | 0:3edb3708c8c5 | 5572 | { |
whismanoid | 0:3edb3708c8c5 | 5573 | // %D CAL=1.234 -- calibrate VRef and compare with AIN0 |
whismanoid | 0:3edb3708c8c5 | 5574 | |
whismanoid | 0:3edb3708c8c5 | 5575 | max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale |
whismanoid | 0:3edb3708c8c5 | 5576 | 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 | 5577 | const int average_count = 100; |
whismanoid | 0:3edb3708c8c5 | 5578 | const double average_K = 0.25; |
whismanoid | 0:3edb3708c8c5 | 5579 | for (int count = 0; count < average_count; count++) { |
whismanoid | 0:3edb3708c8c5 | 5580 | double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V |
whismanoid | 0:3edb3708c8c5 | 5581 | max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V); |
whismanoid | 0:3edb3708c8c5 | 5582 | } |
whismanoid | 0:3edb3708c8c5 | 5583 | max541.VRef = 2.0 * max541_midscale_V; |
whismanoid | 0:3edb3708c8c5 | 5584 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 5585 | "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV", |
whismanoid | 0:3edb3708c8c5 | 5586 | max541_midscale_V, max541.VRef); |
whismanoid | 0:3edb3708c8c5 | 5587 | // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4 |
whismanoid | 0:3edb3708c8c5 | 5588 | voltageV = 1.0f; |
whismanoid | 0:3edb3708c8c5 | 5589 | SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); |
whismanoid | 0:3edb3708c8c5 | 5590 | } |
whismanoid | 0:3edb3708c8c5 | 5591 | else { |
whismanoid | 0:3edb3708c8c5 | 5592 | // %D -- print MAX541 DAC status |
whismanoid | 0:3edb3708c8c5 | 5593 | cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n", |
whismanoid | 0:3edb3708c8c5 | 5594 | max541.Get_Code(), max541.Get_Voltage(), max541.VRef); |
whismanoid | 0:3edb3708c8c5 | 5595 | } |
whismanoid | 0:3edb3708c8c5 | 5596 | } |
whismanoid | 0:3edb3708c8c5 | 5597 | break; |
whismanoid | 0:3edb3708c8c5 | 5598 | #endif |
whismanoid | 0:3edb3708c8c5 | 5599 | |
whismanoid | 0:3edb3708c8c5 | 5600 | // |
whismanoid | 0:3edb3708c8c5 | 5601 | #if HAS_pwmDrivers |
whismanoid | 0:3edb3708c8c5 | 5602 | case 'P': case 'p': |
whismanoid | 0:3edb3708c8c5 | 5603 | { |
whismanoid | 0:3edb3708c8c5 | 5604 | // %Ppin df=xx -- pwm output |
whismanoid | 0:3edb3708c8c5 | 5605 | } |
whismanoid | 0:3edb3708c8c5 | 5606 | break; |
whismanoid | 0:3edb3708c8c5 | 5607 | #endif |
whismanoid | 0:3edb3708c8c5 | 5608 | // |
whismanoid | 0:3edb3708c8c5 | 5609 | #if 0 // HAS_pwmDrivers |
whismanoid | 0:3edb3708c8c5 | 5610 | case 'W': |
whismanoid | 0:3edb3708c8c5 | 5611 | case 'w': |
whismanoid | 0:3edb3708c8c5 | 5612 | // %Wpin -- measure high pulsewidth input in usec |
whismanoid | 0:3edb3708c8c5 | 5613 | // %wpin -- measure low pulsewidth input in usec |
whismanoid | 0:3edb3708c8c5 | 5614 | break; |
whismanoid | 0:3edb3708c8c5 | 5615 | #endif |
whismanoid | 0:3edb3708c8c5 | 5616 | // |
whismanoid | 0:3edb3708c8c5 | 5617 | #if HAS_I2C // SUPPORT_I2C |
whismanoid | 0:3edb3708c8c5 | 5618 | case 'I': case 'i': |
whismanoid | 0:3edb3708c8c5 | 5619 | // %I... -- I2C diagnostics |
whismanoid | 0:3edb3708c8c5 | 5620 | // %IP -- I2C probe |
whismanoid | 0:3edb3708c8c5 | 5621 | // %IC scl=100khz ADDR=? -- I2C configure |
whismanoid | 0:3edb3708c8c5 | 5622 | // %IW byte byte ... byte RD=? ADDR=0x -- write |
whismanoid | 0:3edb3708c8c5 | 5623 | // %IR ADDR=? RD=? -- read |
whismanoid | 0:3edb3708c8c5 | 5624 | // %I^ cmd=? -- i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 5625 | // get next character |
whismanoid | 0:3edb3708c8c5 | 5626 | // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7 |
whismanoid | 0:3edb3708c8c5 | 5627 | cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7); |
whismanoid | 0:3edb3708c8c5 | 5628 | // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count |
whismanoid | 0:3edb3708c8c5 | 5629 | g_I2C_read_count = 0; // read count must be reset every command |
whismanoid | 0:3edb3708c8c5 | 5630 | cmdLine.parse_byte_dec("RD", g_I2C_read_count); |
whismanoid | 0:3edb3708c8c5 | 5631 | // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress |
whismanoid | 0:3edb3708c8c5 | 5632 | cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress); |
whismanoid | 0:3edb3708c8c5 | 5633 | switch (cmdLine[2]) |
whismanoid | 0:3edb3708c8c5 | 5634 | { |
whismanoid | 0:3edb3708c8c5 | 5635 | case 'P': case 'p': |
whismanoid | 0:3edb3708c8c5 | 5636 | { |
whismanoid | 0:3edb3708c8c5 | 5637 | // %IP -- I2C probe |
whismanoid | 0:3edb3708c8c5 | 5638 | HuntAttachedI2CDevices(cmdLine, 0x03, 0x77); |
whismanoid | 0:3edb3708c8c5 | 5639 | } |
whismanoid | 0:3edb3708c8c5 | 5640 | break; |
whismanoid | 0:3edb3708c8c5 | 5641 | case 'C': case 'c': |
whismanoid | 0:3edb3708c8c5 | 5642 | { |
whismanoid | 0:3edb3708c8c5 | 5643 | bool isUpdatedI2CConfig = false; |
whismanoid | 0:3edb3708c8c5 | 5644 | // %IC scl=100khz ADDR=? -- I2C configure |
whismanoid | 0:3edb3708c8c5 | 5645 | // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz |
whismanoid | 0:3edb3708c8c5 | 5646 | if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz)) |
whismanoid | 0:3edb3708c8c5 | 5647 | { |
whismanoid | 0:3edb3708c8c5 | 5648 | isUpdatedI2CConfig = true; |
whismanoid | 0:3edb3708c8c5 | 5649 | // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU |
whismanoid | 0:3edb3708c8c5 | 5650 | if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz) |
whismanoid | 0:3edb3708c8c5 | 5651 | { |
whismanoid | 0:3edb3708c8c5 | 5652 | g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz; |
whismanoid | 0:3edb3708c8c5 | 5653 | } |
whismanoid | 0:3edb3708c8c5 | 5654 | if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz) |
whismanoid | 0:3edb3708c8c5 | 5655 | { |
whismanoid | 0:3edb3708c8c5 | 5656 | g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz; |
whismanoid | 0:3edb3708c8c5 | 5657 | } |
whismanoid | 0:3edb3708c8c5 | 5658 | } |
whismanoid | 0:3edb3708c8c5 | 5659 | if (isUpdatedI2CConfig) |
whismanoid | 0:3edb3708c8c5 | 5660 | { |
whismanoid | 0:3edb3708c8c5 | 5661 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 0:3edb3708c8c5 | 5662 | I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 5663 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 5664 | i2cMaster.start(); |
whismanoid | 0:3edb3708c8c5 | 5665 | i2cMaster.stop(); |
whismanoid | 0:3edb3708c8c5 | 5666 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 5667 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 5668 | "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config", |
whismanoid | 0:3edb3708c8c5 | 5669 | g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz, |
whismanoid | 0:3edb3708c8c5 | 5670 | (g_I2C_SCL_Hz / 1000.)); |
whismanoid | 0:3edb3708c8c5 | 5671 | i2cMaster.start(); |
whismanoid | 0:3edb3708c8c5 | 5672 | i2cMaster.stop(); |
whismanoid | 0:3edb3708c8c5 | 5673 | } |
whismanoid | 0:3edb3708c8c5 | 5674 | } |
whismanoid | 0:3edb3708c8c5 | 5675 | break; |
whismanoid | 0:3edb3708c8c5 | 5676 | case 'W': case 'w': |
whismanoid | 0:3edb3708c8c5 | 5677 | { |
whismanoid | 0:3edb3708c8c5 | 5678 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 0:3edb3708c8c5 | 5679 | I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 5680 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 5681 | // %IW byte byte ... byte RD=? ADDR=0x -- write |
whismanoid | 0:3edb3708c8c5 | 5682 | // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; |
whismanoid | 0:3edb3708c8c5 | 5683 | #define MAX_I2C_BYTE_COUNT 32 |
whismanoid | 0:3edb3708c8c5 | 5684 | size_t byteCount = byteCount; |
whismanoid | 0:3edb3708c8c5 | 5685 | static char mosiData[MAX_I2C_BYTE_COUNT]; |
whismanoid | 0:3edb3708c8c5 | 5686 | static char misoData[MAX_I2C_BYTE_COUNT]; |
whismanoid | 0:3edb3708c8c5 | 5687 | if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, |
whismanoid | 0:3edb3708c8c5 | 5688 | MAX_I2C_BYTE_COUNT)) |
whismanoid | 0:3edb3708c8c5 | 5689 | { |
whismanoid | 0:3edb3708c8c5 | 5690 | // hex dump mosiData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 5691 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 5692 | "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->", |
whismanoid | 0:3edb3708c8c5 | 5693 | g_I2C_deviceAddress7, |
whismanoid | 0:3edb3708c8c5 | 5694 | (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count); |
whismanoid | 0:3edb3708c8c5 | 5695 | for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 5696 | { |
whismanoid | 0:3edb3708c8c5 | 5697 | cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 5698 | } |
whismanoid | 0:3edb3708c8c5 | 5699 | // |
whismanoid | 0:3edb3708c8c5 | 5700 | // TODO: i2c transfer |
whismanoid | 0:3edb3708c8c5 | 5701 | //const int addr7bit = 0x48; // 7 bit I2C address |
whismanoid | 0:3edb3708c8c5 | 5702 | //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 |
whismanoid | 0:3edb3708c8c5 | 5703 | // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 5704 | // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5705 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 5706 | // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5707 | // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5708 | // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5709 | // /* 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 | 5710 | // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... |
whismanoid | 0:3edb3708c8c5 | 5711 | const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90 |
whismanoid | 0:3edb3708c8c5 | 5712 | unsigned int misoLength = 0; |
whismanoid | 0:3edb3708c8c5 | 5713 | bool repeated = (g_I2C_read_count > 0); |
whismanoid | 0:3edb3708c8c5 | 5714 | // |
whismanoid | 0:3edb3708c8c5 | 5715 | int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated); |
whismanoid | 0:3edb3708c8c5 | 5716 | switch (writeStatus) |
whismanoid | 0:3edb3708c8c5 | 5717 | { |
whismanoid | 0:3edb3708c8c5 | 5718 | case 0: cmdLine.serial().printf(" ack "); break; |
whismanoid | 0:3edb3708c8c5 | 5719 | case 1: cmdLine.serial().printf(" nack "); break; |
whismanoid | 0:3edb3708c8c5 | 5720 | default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ", |
whismanoid | 0:3edb3708c8c5 | 5721 | writeStatus); |
whismanoid | 0:3edb3708c8c5 | 5722 | } |
whismanoid | 0:3edb3708c8c5 | 5723 | if (repeated) |
whismanoid | 0:3edb3708c8c5 | 5724 | { |
whismanoid | 0:3edb3708c8c5 | 5725 | int readStatus = |
whismanoid | 0:3edb3708c8c5 | 5726 | i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false); |
whismanoid | 0:3edb3708c8c5 | 5727 | switch (readStatus) |
whismanoid | 0:3edb3708c8c5 | 5728 | { |
whismanoid | 0:3edb3708c8c5 | 5729 | case 1: cmdLine.serial().printf(" nack "); break; |
whismanoid | 0:3edb3708c8c5 | 5730 | case 0: cmdLine.serial().printf(" ack "); break; |
whismanoid | 0:3edb3708c8c5 | 5731 | default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ", |
whismanoid | 0:3edb3708c8c5 | 5732 | readStatus); |
whismanoid | 0:3edb3708c8c5 | 5733 | } |
whismanoid | 0:3edb3708c8c5 | 5734 | } |
whismanoid | 0:3edb3708c8c5 | 5735 | // |
whismanoid | 0:3edb3708c8c5 | 5736 | if (misoLength > 0) |
whismanoid | 0:3edb3708c8c5 | 5737 | { |
whismanoid | 0:3edb3708c8c5 | 5738 | // hex dump misoData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 5739 | cmdLine.serial().printf(" MISO<-"); |
whismanoid | 0:3edb3708c8c5 | 5740 | for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count; |
whismanoid | 0:3edb3708c8c5 | 5741 | byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 5742 | { |
whismanoid | 0:3edb3708c8c5 | 5743 | cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 5744 | } |
whismanoid | 0:3edb3708c8c5 | 5745 | } |
whismanoid | 0:3edb3708c8c5 | 5746 | cmdLine.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 5747 | } |
whismanoid | 0:3edb3708c8c5 | 5748 | } |
whismanoid | 0:3edb3708c8c5 | 5749 | break; |
whismanoid | 0:3edb3708c8c5 | 5750 | case 'R': case 'r': |
whismanoid | 0:3edb3708c8c5 | 5751 | { |
whismanoid | 0:3edb3708c8c5 | 5752 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 0:3edb3708c8c5 | 5753 | I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 5754 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 5755 | // %IR ADDR=? RD=? -- read |
whismanoid | 0:3edb3708c8c5 | 5756 | // TODO: i2c transfer |
whismanoid | 0:3edb3708c8c5 | 5757 | //const int addr7bit = 0x48; // 7 bit I2C address |
whismanoid | 0:3edb3708c8c5 | 5758 | //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 |
whismanoid | 0:3edb3708c8c5 | 5759 | // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 5760 | // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5761 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 5762 | // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5763 | // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5764 | // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5765 | // /* 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 | 5766 | // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... |
whismanoid | 0:3edb3708c8c5 | 5767 | } |
whismanoid | 0:3edb3708c8c5 | 5768 | break; |
whismanoid | 0:3edb3708c8c5 | 5769 | case '^': |
whismanoid | 0:3edb3708c8c5 | 5770 | { |
whismanoid | 0:3edb3708c8c5 | 5771 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 0:3edb3708c8c5 | 5772 | I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header |
whismanoid | 0:3edb3708c8c5 | 5773 | i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 5774 | // %I^ cmd=? -- i2c_smbus_read_word_data |
whismanoid | 0:3edb3708c8c5 | 5775 | // TODO: i2c transfer |
whismanoid | 0:3edb3708c8c5 | 5776 | //const int addr7bit = 0x48; // 7 bit I2C address |
whismanoid | 0:3edb3708c8c5 | 5777 | //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 |
whismanoid | 0:3edb3708c8c5 | 5778 | // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 5779 | // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5780 | // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. |
whismanoid | 0:3edb3708c8c5 | 5781 | // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5782 | // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5783 | // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. |
whismanoid | 0:3edb3708c8c5 | 5784 | // /* 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 | 5785 | // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... |
whismanoid | 0:3edb3708c8c5 | 5786 | } |
whismanoid | 0:3edb3708c8c5 | 5787 | break; |
whismanoid | 0:3edb3708c8c5 | 5788 | } // switch(cmdLine[2]) |
whismanoid | 0:3edb3708c8c5 | 5789 | break; |
whismanoid | 0:3edb3708c8c5 | 5790 | #endif |
whismanoid | 0:3edb3708c8c5 | 5791 | // |
whismanoid | 0:3edb3708c8c5 | 5792 | #if HAS_SPI // SUPPORT_SPI |
whismanoid | 0:3edb3708c8c5 | 5793 | case 'S': case 's': |
whismanoid | 0:3edb3708c8c5 | 5794 | { |
whismanoid | 0:3edb3708c8c5 | 5795 | // %S... -- SPI diagnostics |
whismanoid | 0:3edb3708c8c5 | 5796 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 0:3edb3708c8c5 | 5797 | // %SW -- write (write and read) |
whismanoid | 0:3edb3708c8c5 | 5798 | // %SR -- read (alias for %SW because SPI always write and read) |
whismanoid | 0:3edb3708c8c5 | 5799 | // |
whismanoid | 0:3edb3708c8c5 | 5800 | // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d |
whismanoid | 0:3edb3708c8c5 | 5801 | bool isUpdatedSPIConfig = false; |
whismanoid | 0:3edb3708c8c5 | 5802 | // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2 |
whismanoid | 0:3edb3708c8c5 | 5803 | // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1 |
whismanoid | 0:3edb3708c8c5 | 5804 | if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2)) |
whismanoid | 0:3edb3708c8c5 | 5805 | { |
whismanoid | 0:3edb3708c8c5 | 5806 | isUpdatedSPIConfig = true; |
whismanoid | 0:3edb3708c8c5 | 5807 | } |
whismanoid | 0:3edb3708c8c5 | 5808 | if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1)) |
whismanoid | 0:3edb3708c8c5 | 5809 | { |
whismanoid | 0:3edb3708c8c5 | 5810 | isUpdatedSPIConfig = true; |
whismanoid | 0:3edb3708c8c5 | 5811 | } |
whismanoid | 0:3edb3708c8c5 | 5812 | if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1)) |
whismanoid | 0:3edb3708c8c5 | 5813 | { |
whismanoid | 0:3edb3708c8c5 | 5814 | isUpdatedSPIConfig = true; |
whismanoid | 0:3edb3708c8c5 | 5815 | } |
whismanoid | 0:3edb3708c8c5 | 5816 | // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz |
whismanoid | 0:3edb3708c8c5 | 5817 | if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz)) |
whismanoid | 0:3edb3708c8c5 | 5818 | { |
whismanoid | 0:3edb3708c8c5 | 5819 | isUpdatedSPIConfig = true; |
whismanoid | 0:3edb3708c8c5 | 5820 | // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU |
whismanoid | 0:3edb3708c8c5 | 5821 | if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz) |
whismanoid | 0:3edb3708c8c5 | 5822 | { |
whismanoid | 0:3edb3708c8c5 | 5823 | g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz; |
whismanoid | 0:3edb3708c8c5 | 5824 | } |
whismanoid | 0:3edb3708c8c5 | 5825 | if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz) |
whismanoid | 0:3edb3708c8c5 | 5826 | { |
whismanoid | 0:3edb3708c8c5 | 5827 | g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz; |
whismanoid | 0:3edb3708c8c5 | 5828 | } |
whismanoid | 0:3edb3708c8c5 | 5829 | } |
whismanoid | 0:3edb3708c8c5 | 5830 | // Update SPI configuration |
whismanoid | 0:3edb3708c8c5 | 5831 | if (isUpdatedSPIConfig) |
whismanoid | 0:3edb3708c8c5 | 5832 | { |
whismanoid | 0:3edb3708c8c5 | 5833 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 0:3edb3708c8c5 | 5834 | spi_cs = g_SPI_cs_state; |
whismanoid | 0:3edb3708c8c5 | 5835 | spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 |
whismanoid | 0:3edb3708c8c5 | 5836 | #if APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 5837 | g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz); |
whismanoid | 0:3edb3708c8c5 | 5838 | #elif APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 5839 | g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz); |
whismanoid | 0:3edb3708c8c5 | 5840 | #elif APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 5841 | g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz); |
whismanoid | 0:3edb3708c8c5 | 5842 | #elif APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 5843 | g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz); |
whismanoid | 0:3edb3708c8c5 | 5844 | #elif APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 5845 | g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz); |
whismanoid | 0:3edb3708c8c5 | 5846 | #else |
whismanoid | 0:3edb3708c8c5 | 5847 | spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default) |
whismanoid | 0:3edb3708c8c5 | 5848 | #endif |
whismanoid | 0:3edb3708c8c5 | 5849 | // |
whismanoid | 0:3edb3708c8c5 | 5850 | double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz; |
whismanoid | 0:3edb3708c8c5 | 5851 | int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate |
whismanoid | 0:3edb3708c8c5 | 5852 | double actual_SCLK_Hz = SystemCoreClock / actual_divisor; |
whismanoid | 0:3edb3708c8c5 | 5853 | // |
whismanoid | 0:3edb3708c8c5 | 5854 | // 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 | 0:3edb3708c8c5 | 5855 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 5856 | "\r\n %%SC CPOL=%d CPHA=%d CS=%d SCLK=%ld=%1.3fMHz (%1.1fMHz/%1.2f = actual %1.3fMHz) -- SPI config", |
whismanoid | 0:3edb3708c8c5 | 5857 | ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0), |
whismanoid | 0:3edb3708c8c5 | 5858 | ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0), |
whismanoid | 0:3edb3708c8c5 | 5859 | g_SPI_cs_state, |
whismanoid | 0:3edb3708c8c5 | 5860 | g_SPI_SCLK_Hz, |
whismanoid | 0:3edb3708c8c5 | 5861 | (g_SPI_SCLK_Hz / 1000000.), |
whismanoid | 0:3edb3708c8c5 | 5862 | ((double)(SystemCoreClock / 1000000.)), |
whismanoid | 0:3edb3708c8c5 | 5863 | ideal_divisor, |
whismanoid | 0:3edb3708c8c5 | 5864 | (actual_SCLK_Hz / 1000000.) |
whismanoid | 0:3edb3708c8c5 | 5865 | ); |
whismanoid | 0:3edb3708c8c5 | 5866 | } |
whismanoid | 0:3edb3708c8c5 | 5867 | // get next character |
whismanoid | 0:3edb3708c8c5 | 5868 | switch (cmdLine[2]) |
whismanoid | 0:3edb3708c8c5 | 5869 | { |
whismanoid | 0:3edb3708c8c5 | 5870 | case 'C': case 's': |
whismanoid | 0:3edb3708c8c5 | 5871 | // %SC sclk=1Mhz -- SPI configure |
whismanoid | 0:3edb3708c8c5 | 5872 | break; |
whismanoid | 0:3edb3708c8c5 | 5873 | case 'W': case 'R': case 'w': case 'r': |
whismanoid | 0:3edb3708c8c5 | 5874 | { |
whismanoid | 0:3edb3708c8c5 | 5875 | // %SW -- write (write and read) |
whismanoid | 0:3edb3708c8c5 | 5876 | // %SR -- read (alias for %SW because SPI always write and read) |
whismanoid | 0:3edb3708c8c5 | 5877 | // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; |
whismanoid | 0:3edb3708c8c5 | 5878 | #define MAX_SPI_BYTE_COUNT 32 |
whismanoid | 0:3edb3708c8c5 | 5879 | size_t byteCount = byteCount; |
whismanoid | 0:3edb3708c8c5 | 5880 | static char mosiData[MAX_SPI_BYTE_COUNT]; |
whismanoid | 0:3edb3708c8c5 | 5881 | static char misoData[MAX_SPI_BYTE_COUNT]; |
whismanoid | 0:3edb3708c8c5 | 5882 | if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, |
whismanoid | 0:3edb3708c8c5 | 5883 | MAX_SPI_BYTE_COUNT)) |
whismanoid | 0:3edb3708c8c5 | 5884 | { |
whismanoid | 0:3edb3708c8c5 | 5885 | // hex dump mosiData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 5886 | cmdLine.serial().printf("\r\nSPI"); |
whismanoid | 0:3edb3708c8c5 | 5887 | if (byteCount > 7) { |
whismanoid | 0:3edb3708c8c5 | 5888 | cmdLine.serial().printf(" byteCount:%d", byteCount); |
whismanoid | 0:3edb3708c8c5 | 5889 | } |
whismanoid | 0:3edb3708c8c5 | 5890 | cmdLine.serial().printf(" MOSI->"); |
whismanoid | 0:3edb3708c8c5 | 5891 | for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 5892 | { |
whismanoid | 0:3edb3708c8c5 | 5893 | cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 5894 | } |
whismanoid | 0:3edb3708c8c5 | 5895 | spi_cs = 0; |
whismanoid | 0:3edb3708c8c5 | 5896 | unsigned int numBytesTransferred = |
whismanoid | 0:3edb3708c8c5 | 5897 | spi.write(mosiData, byteCount, misoData, byteCount); |
whismanoid | 0:3edb3708c8c5 | 5898 | spi_cs = 1; |
whismanoid | 0:3edb3708c8c5 | 5899 | // hex dump misoData[0..byteCount-1] |
whismanoid | 0:3edb3708c8c5 | 5900 | cmdLine.serial().printf(" MISO<-"); |
whismanoid | 0:3edb3708c8c5 | 5901 | for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; |
whismanoid | 0:3edb3708c8c5 | 5902 | byteIndex++) |
whismanoid | 0:3edb3708c8c5 | 5903 | { |
whismanoid | 0:3edb3708c8c5 | 5904 | cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 0:3edb3708c8c5 | 5905 | } |
whismanoid | 0:3edb3708c8c5 | 5906 | cmdLine.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 5907 | } |
whismanoid | 0:3edb3708c8c5 | 5908 | } |
whismanoid | 0:3edb3708c8c5 | 5909 | break; |
whismanoid | 0:3edb3708c8c5 | 5910 | } // switch(cmdLine[2]) |
whismanoid | 0:3edb3708c8c5 | 5911 | } // case 'S': // %S... -- SPI diagnostics |
whismanoid | 0:3edb3708c8c5 | 5912 | break; |
whismanoid | 0:3edb3708c8c5 | 5913 | #endif |
whismanoid | 0:3edb3708c8c5 | 5914 | // |
whismanoid | 0:3edb3708c8c5 | 5915 | // A-Z,a-z,0-9 reserved for application use |
whismanoid | 0:3edb3708c8c5 | 5916 | } // switch(cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 5917 | } |
whismanoid | 0:3edb3708c8c5 | 5918 | break; // case '%' |
whismanoid | 0:3edb3708c8c5 | 5919 | #endif // APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 5920 | // |
whismanoid | 0:3edb3708c8c5 | 5921 | // Application-specific commands here |
whismanoid | 0:3edb3708c8c5 | 5922 | // alphanumeric command codes A-Z,a-z,0-9 reserved for application use |
whismanoid | 0:3edb3708c8c5 | 5923 | // |
whismanoid | 0:3edb3708c8c5 | 5924 | #if APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 5925 | #endif // APPLICATION_ArduinoPinsMonitor |
whismanoid | 0:3edb3708c8c5 | 5926 | |
whismanoid | 0:3edb3708c8c5 | 5927 | #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser |
whismanoid | 0:3edb3708c8c5 | 5928 | case '0': |
whismanoid | 0:3edb3708c8c5 | 5929 | { |
whismanoid | 0:3edb3708c8c5 | 5930 | // recommended for hex command codes 00..0F |
whismanoid | 0:3edb3708c8c5 | 5931 | // TODO: cmdLine.serial().printf("\r\n 0 ch=? code=? -- CODEn"); |
whismanoid | 0:3edb3708c8c5 | 5932 | // Menu 0 ch=? code=?) CODEn |
whismanoid | 0:3edb3708c8c5 | 5933 | // MAX5715_CODEn(uint8_t channel, uint16_t dacCodeLsbs); |
whismanoid | 0:3edb3708c8c5 | 5934 | // VERIFY: parse strCommandArgs for additional arguments including key=value pairs |
whismanoid | 0:3edb3708c8c5 | 5935 | // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 5936 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 5937 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 5938 | { |
whismanoid | 0:3edb3708c8c5 | 5939 | } |
whismanoid | 0:3edb3708c8c5 | 5940 | uint16_t code = g_MAX5715_device.CODE[ch]; |
whismanoid | 0:3edb3708c8c5 | 5941 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 5942 | { |
whismanoid | 0:3edb3708c8c5 | 5943 | } |
whismanoid | 0:3edb3708c8c5 | 5944 | cmdLine.serial().printf("CODEn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 5945 | g_MAX5715_device.CODEn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 5946 | } |
whismanoid | 0:3edb3708c8c5 | 5947 | break; |
whismanoid | 0:3edb3708c8c5 | 5948 | case '1': |
whismanoid | 0:3edb3708c8c5 | 5949 | { |
whismanoid | 0:3edb3708c8c5 | 5950 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 5951 | // TODO: cmdLine.serial().printf("\r\n 1 ch=? -- LOADn"); |
whismanoid | 0:3edb3708c8c5 | 5952 | // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 5953 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 5954 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 5955 | { |
whismanoid | 0:3edb3708c8c5 | 5956 | } |
whismanoid | 0:3edb3708c8c5 | 5957 | cmdLine.serial().printf("LOADn ch=%d", ch); |
whismanoid | 0:3edb3708c8c5 | 5958 | g_MAX5715_device.LOADn(ch); |
whismanoid | 0:3edb3708c8c5 | 5959 | } |
whismanoid | 0:3edb3708c8c5 | 5960 | break; |
whismanoid | 0:3edb3708c8c5 | 5961 | case '2': |
whismanoid | 0:3edb3708c8c5 | 5962 | { |
whismanoid | 0:3edb3708c8c5 | 5963 | // recommended for hex command codes 20..2F |
whismanoid | 0:3edb3708c8c5 | 5964 | // TODO: cmdLine.serial().printf("\r\n 2 ch=? code=? -- CODEnLOADall"); |
whismanoid | 0:3edb3708c8c5 | 5965 | // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 5966 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 5967 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 5968 | { |
whismanoid | 0:3edb3708c8c5 | 5969 | } |
whismanoid | 0:3edb3708c8c5 | 5970 | uint16_t code = g_MAX5715_device.CODE[ch]; |
whismanoid | 0:3edb3708c8c5 | 5971 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 5972 | { |
whismanoid | 0:3edb3708c8c5 | 5973 | } |
whismanoid | 0:3edb3708c8c5 | 5974 | cmdLine.serial().printf("CODEnLOADall ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 5975 | g_MAX5715_device.CODEnLOADall(ch, code); |
whismanoid | 0:3edb3708c8c5 | 5976 | } |
whismanoid | 0:3edb3708c8c5 | 5977 | break; |
whismanoid | 0:3edb3708c8c5 | 5978 | case '3': |
whismanoid | 0:3edb3708c8c5 | 5979 | { |
whismanoid | 0:3edb3708c8c5 | 5980 | // recommended for hex command codes 30..3F |
whismanoid | 0:3edb3708c8c5 | 5981 | // TODO: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); |
whismanoid | 0:3edb3708c8c5 | 5982 | // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 5983 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 5984 | uint16_t code; |
whismanoid | 0:3edb3708c8c5 | 5985 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 5986 | { |
whismanoid | 0:3edb3708c8c5 | 5987 | } |
whismanoid | 0:3edb3708c8c5 | 5988 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 5989 | { |
whismanoid | 0:3edb3708c8c5 | 5990 | } |
whismanoid | 0:3edb3708c8c5 | 5991 | cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 5992 | g_MAX5715_device.CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 5993 | } |
whismanoid | 0:3edb3708c8c5 | 5994 | break; |
whismanoid | 0:3edb3708c8c5 | 5995 | case '4': |
whismanoid | 0:3edb3708c8c5 | 5996 | { |
whismanoid | 0:3edb3708c8c5 | 5997 | // recommended for hex command codes 40..4F |
whismanoid | 0:3edb3708c8c5 | 5998 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 5999 | { |
whismanoid | 0:3edb3708c8c5 | 6000 | case '0': |
whismanoid | 0:3edb3708c8c5 | 6001 | { |
whismanoid | 0:3edb3708c8c5 | 6002 | // cmdLine.serial().printf("\r\n 40 ch=? -- POWERn_Normal"); |
whismanoid | 0:3edb3708c8c5 | 6003 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6004 | "channel_dcba=%d, POWERn_Normal)", |
whismanoid | 0:3edb3708c8c5 | 6005 | g_MAX5715_device.channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 6006 | g_MAX5715_device.POWER(g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 6007 | channels_bitmask_DCBA, |
whismanoid | 0:3edb3708c8c5 | 6008 | MAX5715::POWERn_Normal); |
whismanoid | 0:3edb3708c8c5 | 6009 | } |
whismanoid | 0:3edb3708c8c5 | 6010 | break; |
whismanoid | 0:3edb3708c8c5 | 6011 | case '1': |
whismanoid | 0:3edb3708c8c5 | 6012 | { |
whismanoid | 0:3edb3708c8c5 | 6013 | // cmdLine.serial().printf("\r\n 41 ch=? -- POWERn_PD1k"); |
whismanoid | 0:3edb3708c8c5 | 6014 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6015 | "channel_dcba=%d, POWERn_PD1k)", |
whismanoid | 0:3edb3708c8c5 | 6016 | g_MAX5715_device.channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 6017 | g_MAX5715_device.POWER(g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 6018 | channels_bitmask_DCBA, |
whismanoid | 0:3edb3708c8c5 | 6019 | MAX5715::POWERn_PD1k); |
whismanoid | 0:3edb3708c8c5 | 6020 | } |
whismanoid | 0:3edb3708c8c5 | 6021 | break; |
whismanoid | 0:3edb3708c8c5 | 6022 | case '2': |
whismanoid | 0:3edb3708c8c5 | 6023 | { |
whismanoid | 0:3edb3708c8c5 | 6024 | // cmdLine.serial().printf("\r\n 42 ch=? -- POWERn_PD100k"); |
whismanoid | 0:3edb3708c8c5 | 6025 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6026 | "channel_dcba=%d, POWERn_PD100k)", |
whismanoid | 0:3edb3708c8c5 | 6027 | g_MAX5715_device.channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 6028 | g_MAX5715_device.POWER(g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 6029 | channels_bitmask_DCBA, |
whismanoid | 0:3edb3708c8c5 | 6030 | MAX5715::POWERn_PD100k); |
whismanoid | 0:3edb3708c8c5 | 6031 | } |
whismanoid | 0:3edb3708c8c5 | 6032 | break; |
whismanoid | 0:3edb3708c8c5 | 6033 | case '3': |
whismanoid | 0:3edb3708c8c5 | 6034 | { |
whismanoid | 0:3edb3708c8c5 | 6035 | // cmdLine.serial().printf("\r\n 43 ch=? -- POWERn_PDHiZ"); |
whismanoid | 0:3edb3708c8c5 | 6036 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6037 | "channel_dcba=%d, POWERn_PDHiZ)", |
whismanoid | 0:3edb3708c8c5 | 6038 | g_MAX5715_device.channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 6039 | g_MAX5715_device.POWER(g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 6040 | channels_bitmask_DCBA, |
whismanoid | 0:3edb3708c8c5 | 6041 | MAX5715::POWERn_PDHiZ); |
whismanoid | 0:3edb3708c8c5 | 6042 | } |
whismanoid | 0:3edb3708c8c5 | 6043 | break; |
whismanoid | 0:3edb3708c8c5 | 6044 | } |
whismanoid | 0:3edb3708c8c5 | 6045 | break; |
whismanoid | 0:3edb3708c8c5 | 6046 | } |
whismanoid | 0:3edb3708c8c5 | 6047 | break; |
whismanoid | 0:3edb3708c8c5 | 6048 | case '5': |
whismanoid | 0:3edb3708c8c5 | 6049 | { |
whismanoid | 0:3edb3708c8c5 | 6050 | // recommended for hex command codes 50..5F |
whismanoid | 0:3edb3708c8c5 | 6051 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 6052 | { |
whismanoid | 0:3edb3708c8c5 | 6053 | case '0': |
whismanoid | 0:3edb3708c8c5 | 6054 | { |
whismanoid | 0:3edb3708c8c5 | 6055 | // cmdLine.serial().printf("\r\n 50 -- SW_CLEAR"); |
whismanoid | 0:3edb3708c8c5 | 6056 | cmdLine.serial().printf("SW_CLEAR"); |
whismanoid | 0:3edb3708c8c5 | 6057 | g_MAX5715_device.SW_CLEAR(); |
whismanoid | 0:3edb3708c8c5 | 6058 | } |
whismanoid | 0:3edb3708c8c5 | 6059 | break; |
whismanoid | 0:3edb3708c8c5 | 6060 | case '1': |
whismanoid | 0:3edb3708c8c5 | 6061 | { |
whismanoid | 0:3edb3708c8c5 | 6062 | // cmdLine.serial().printf("\r\n 51 -- SW_RESET"); |
whismanoid | 0:3edb3708c8c5 | 6063 | cmdLine.serial().printf("SW_RESET"); |
whismanoid | 0:3edb3708c8c5 | 6064 | g_MAX5715_device.SW_RESET(); |
whismanoid | 0:3edb3708c8c5 | 6065 | } |
whismanoid | 0:3edb3708c8c5 | 6066 | break; |
whismanoid | 0:3edb3708c8c5 | 6067 | } |
whismanoid | 0:3edb3708c8c5 | 6068 | } |
whismanoid | 0:3edb3708c8c5 | 6069 | break; |
whismanoid | 0:3edb3708c8c5 | 6070 | case '6': |
whismanoid | 0:3edb3708c8c5 | 6071 | { |
whismanoid | 0:3edb3708c8c5 | 6072 | // recommended for hex command codes 60..6F |
whismanoid | 0:3edb3708c8c5 | 6073 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 6074 | { |
whismanoid | 0:3edb3708c8c5 | 6075 | case '0': |
whismanoid | 0:3edb3708c8c5 | 6076 | { |
whismanoid | 0:3edb3708c8c5 | 6077 | // cmdLine.serial().printf("\r\n 60 ch=? -- CONFIGn_LATCHED"); |
whismanoid | 0:3edb3708c8c5 | 6078 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6079 | "MAX5715_CONFIGn_LATCHED(channel_dcba=%d)", |
whismanoid | 0:3edb3708c8c5 | 6080 | g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 6081 | channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 6082 | g_MAX5715_device.CONFIGn_LATCHED(g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 6083 | channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 6084 | } |
whismanoid | 0:3edb3708c8c5 | 6085 | break; |
whismanoid | 0:3edb3708c8c5 | 6086 | case '1': |
whismanoid | 0:3edb3708c8c5 | 6087 | { |
whismanoid | 0:3edb3708c8c5 | 6088 | // cmdLine.serial().printf("\r\n 61 ch=? -- CONFIGn_TRANSPARENT"); |
whismanoid | 0:3edb3708c8c5 | 6089 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6090 | "MAX5715_CONFIGn_TRANSPARENT(channel_dcba=%d)", |
whismanoid | 0:3edb3708c8c5 | 6091 | g_MAX5715_device. |
whismanoid | 0:3edb3708c8c5 | 6092 | channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 6093 | g_MAX5715_device.CONFIGn_TRANSPARENT( |
whismanoid | 0:3edb3708c8c5 | 6094 | g_MAX5715_device.channels_bitmask_DCBA); |
whismanoid | 0:3edb3708c8c5 | 6095 | } |
whismanoid | 0:3edb3708c8c5 | 6096 | break; |
whismanoid | 0:3edb3708c8c5 | 6097 | case '8': |
whismanoid | 0:3edb3708c8c5 | 6098 | { |
whismanoid | 0:3edb3708c8c5 | 6099 | // cmdLine.serial().printf("\r\n 68 -- CONFIGall_LATCHED"); |
whismanoid | 0:3edb3708c8c5 | 6100 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6101 | "MAX5715_CONFIGall_LATCHED()"); |
whismanoid | 0:3edb3708c8c5 | 6102 | g_MAX5715_device.CONFIGall_LATCHED(); |
whismanoid | 0:3edb3708c8c5 | 6103 | } |
whismanoid | 0:3edb3708c8c5 | 6104 | break; |
whismanoid | 0:3edb3708c8c5 | 6105 | case '9': |
whismanoid | 0:3edb3708c8c5 | 6106 | { |
whismanoid | 0:3edb3708c8c5 | 6107 | // cmdLine.serial().printf("\r\n 69 -- CONFIGall_TRANSPARENT"); |
whismanoid | 0:3edb3708c8c5 | 6108 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6109 | "MAX5715_CONFIGall_TRANSPARENT()"); |
whismanoid | 0:3edb3708c8c5 | 6110 | g_MAX5715_device.CONFIGall_TRANSPARENT(); |
whismanoid | 0:3edb3708c8c5 | 6111 | } |
whismanoid | 0:3edb3708c8c5 | 6112 | break; |
whismanoid | 0:3edb3708c8c5 | 6113 | } |
whismanoid | 0:3edb3708c8c5 | 6114 | } |
whismanoid | 0:3edb3708c8c5 | 6115 | break; |
whismanoid | 0:3edb3708c8c5 | 6116 | case '7': |
whismanoid | 0:3edb3708c8c5 | 6117 | { |
whismanoid | 0:3edb3708c8c5 | 6118 | // recommended for hex command codes 70..7F |
whismanoid | 0:3edb3708c8c5 | 6119 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 6120 | { |
whismanoid | 0:3edb3708c8c5 | 6121 | case '0': |
whismanoid | 0:3edb3708c8c5 | 6122 | { |
whismanoid | 0:3edb3708c8c5 | 6123 | // cmdLine.serial().printf("\r\n 70 -- REF_EXT"); |
whismanoid | 0:3edb3708c8c5 | 6124 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6125 | "MAX5715_REF(REF_EXT)"); |
whismanoid | 0:3edb3708c8c5 | 6126 | g_MAX5715_device.REF(MAX5715::REF_EXT); |
whismanoid | 0:3edb3708c8c5 | 6127 | } |
whismanoid | 0:3edb3708c8c5 | 6128 | break; |
whismanoid | 0:3edb3708c8c5 | 6129 | case '1': |
whismanoid | 0:3edb3708c8c5 | 6130 | { |
whismanoid | 0:3edb3708c8c5 | 6131 | // cmdLine.serial().printf("\r\n 71 -- REF_2V500"); |
whismanoid | 0:3edb3708c8c5 | 6132 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6133 | "MAX5715_REF(REF_2V500)"); |
whismanoid | 0:3edb3708c8c5 | 6134 | g_MAX5715_device.REF(MAX5715::REF_2V500); |
whismanoid | 0:3edb3708c8c5 | 6135 | } |
whismanoid | 0:3edb3708c8c5 | 6136 | break; |
whismanoid | 0:3edb3708c8c5 | 6137 | case '2': |
whismanoid | 0:3edb3708c8c5 | 6138 | { |
whismanoid | 0:3edb3708c8c5 | 6139 | // cmdLine.serial().printf("\r\n 72 -- REF_2V048"); |
whismanoid | 0:3edb3708c8c5 | 6140 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6141 | "MAX5715_REF(REF_2V048)"); |
whismanoid | 0:3edb3708c8c5 | 6142 | g_MAX5715_device.REF(MAX5715::REF_2V048); |
whismanoid | 0:3edb3708c8c5 | 6143 | } |
whismanoid | 0:3edb3708c8c5 | 6144 | break; |
whismanoid | 0:3edb3708c8c5 | 6145 | case '3': |
whismanoid | 0:3edb3708c8c5 | 6146 | { |
whismanoid | 0:3edb3708c8c5 | 6147 | // cmdLine.serial().printf("\r\n 73 -- REF_4V096"); |
whismanoid | 0:3edb3708c8c5 | 6148 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6149 | "MAX5715_REF(REF_4V096)"); |
whismanoid | 0:3edb3708c8c5 | 6150 | g_MAX5715_device.REF(MAX5715::REF_4V096); |
whismanoid | 0:3edb3708c8c5 | 6151 | } |
whismanoid | 0:3edb3708c8c5 | 6152 | break; |
whismanoid | 0:3edb3708c8c5 | 6153 | case '4': |
whismanoid | 0:3edb3708c8c5 | 6154 | { |
whismanoid | 0:3edb3708c8c5 | 6155 | // cmdLine.serial().printf("\r\n 74 -- REF_AlwaysOn_EXT"); |
whismanoid | 0:3edb3708c8c5 | 6156 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6157 | "MAX5715_REF(REF_AlwaysOn_EXT)"); |
whismanoid | 0:3edb3708c8c5 | 6158 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_EXT); |
whismanoid | 0:3edb3708c8c5 | 6159 | } |
whismanoid | 0:3edb3708c8c5 | 6160 | break; |
whismanoid | 0:3edb3708c8c5 | 6161 | case '5': |
whismanoid | 0:3edb3708c8c5 | 6162 | { |
whismanoid | 0:3edb3708c8c5 | 6163 | // cmdLine.serial().printf("\r\n 75 -- REF_AlwaysOn_2V500"); |
whismanoid | 0:3edb3708c8c5 | 6164 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6165 | "MAX5715_REF(REF_AlwaysOn_2V500)"); |
whismanoid | 0:3edb3708c8c5 | 6166 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); |
whismanoid | 0:3edb3708c8c5 | 6167 | } |
whismanoid | 0:3edb3708c8c5 | 6168 | break; |
whismanoid | 0:3edb3708c8c5 | 6169 | case '6': |
whismanoid | 0:3edb3708c8c5 | 6170 | { |
whismanoid | 0:3edb3708c8c5 | 6171 | // cmdLine.serial().printf("\r\n 76 -- REF_AlwaysOn_2V048"); |
whismanoid | 0:3edb3708c8c5 | 6172 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6173 | "MAX5715_REF(REF_AlwaysOn_2V048)"); |
whismanoid | 0:3edb3708c8c5 | 6174 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048); |
whismanoid | 0:3edb3708c8c5 | 6175 | } |
whismanoid | 0:3edb3708c8c5 | 6176 | break; |
whismanoid | 0:3edb3708c8c5 | 6177 | case '7': |
whismanoid | 0:3edb3708c8c5 | 6178 | { |
whismanoid | 0:3edb3708c8c5 | 6179 | // cmdLine.serial().printf("\r\n 77 -- REF_AlwaysOn_4V096"); |
whismanoid | 0:3edb3708c8c5 | 6180 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6181 | "MAX5715_REF(REF_AlwaysOn_4V096)"); |
whismanoid | 0:3edb3708c8c5 | 6182 | g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_4V096); |
whismanoid | 0:3edb3708c8c5 | 6183 | } |
whismanoid | 0:3edb3708c8c5 | 6184 | break; |
whismanoid | 0:3edb3708c8c5 | 6185 | } |
whismanoid | 0:3edb3708c8c5 | 6186 | } |
whismanoid | 0:3edb3708c8c5 | 6187 | break; |
whismanoid | 0:3edb3708c8c5 | 6188 | case '8': |
whismanoid | 0:3edb3708c8c5 | 6189 | { |
whismanoid | 0:3edb3708c8c5 | 6190 | // recommended for hex command codes 80..8F |
whismanoid | 0:3edb3708c8c5 | 6191 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 6192 | { |
whismanoid | 0:3edb3708c8c5 | 6193 | case '0': |
whismanoid | 0:3edb3708c8c5 | 6194 | { |
whismanoid | 0:3edb3708c8c5 | 6195 | // TODO: cmdLine.serial().printf("\r\n 80 code=? -- CODEall"); |
whismanoid | 0:3edb3708c8c5 | 6196 | // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 6197 | g_MAX5715_device.channels_bitmask_DCBA = 0xFF; // store g_MAX5715_device.CODE[allChannels] |
whismanoid | 0:3edb3708c8c5 | 6198 | uint16_t code = g_MAX5715_device.CODE[0]; |
whismanoid | 0:3edb3708c8c5 | 6199 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 6200 | { |
whismanoid | 0:3edb3708c8c5 | 6201 | } |
whismanoid | 0:3edb3708c8c5 | 6202 | cmdLine.serial().printf("CODEall code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 6203 | g_MAX5715_device.CODEall(code); |
whismanoid | 0:3edb3708c8c5 | 6204 | } |
whismanoid | 0:3edb3708c8c5 | 6205 | break; |
whismanoid | 0:3edb3708c8c5 | 6206 | case '1': |
whismanoid | 0:3edb3708c8c5 | 6207 | { |
whismanoid | 0:3edb3708c8c5 | 6208 | // TODO: cmdLine.serial().printf("\r\n 81 -- LOADall"); |
whismanoid | 0:3edb3708c8c5 | 6209 | cmdLine.serial().printf("LOADall"); |
whismanoid | 0:3edb3708c8c5 | 6210 | g_MAX5715_device.LOADall(); |
whismanoid | 0:3edb3708c8c5 | 6211 | } |
whismanoid | 0:3edb3708c8c5 | 6212 | break; |
whismanoid | 0:3edb3708c8c5 | 6213 | case '2': |
whismanoid | 0:3edb3708c8c5 | 6214 | { |
whismanoid | 0:3edb3708c8c5 | 6215 | // TODO: cmdLine.serial().printf("\r\n 82 code=? -- CODEallLOADall"); |
whismanoid | 0:3edb3708c8c5 | 6216 | uint16_t code = g_MAX5715_device.CODE[0]; |
whismanoid | 0:3edb3708c8c5 | 6217 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 6218 | { |
whismanoid | 0:3edb3708c8c5 | 6219 | } |
whismanoid | 0:3edb3708c8c5 | 6220 | cmdLine.serial().printf("CODEallLOADall code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 6221 | g_MAX5715_device.CODEallLOADall(code); |
whismanoid | 0:3edb3708c8c5 | 6222 | } |
whismanoid | 0:3edb3708c8c5 | 6223 | break; |
whismanoid | 0:3edb3708c8c5 | 6224 | } |
whismanoid | 0:3edb3708c8c5 | 6225 | } |
whismanoid | 0:3edb3708c8c5 | 6226 | break; |
whismanoid | 0:3edb3708c8c5 | 6227 | case '9': |
whismanoid | 0:3edb3708c8c5 | 6228 | { |
whismanoid | 0:3edb3708c8c5 | 6229 | // recommended for hex command codes 90..9F |
whismanoid | 0:3edb3708c8c5 | 6230 | } |
whismanoid | 0:3edb3708c8c5 | 6231 | break; |
whismanoid | 0:3edb3708c8c5 | 6232 | case 'a': case 'A': |
whismanoid | 0:3edb3708c8c5 | 6233 | { |
whismanoid | 0:3edb3708c8c5 | 6234 | // recommended for hex command codes A0..AF |
whismanoid | 0:3edb3708c8c5 | 6235 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 6236 | { |
whismanoid | 0:3edb3708c8c5 | 6237 | case 't': case 'T': |
whismanoid | 0:3edb3708c8c5 | 6238 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6239 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6240 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 6241 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6242 | // AT command: skip the prompt to avoid confusing modem detector |
whismanoid | 0:3edb3708c8c5 | 6243 | return; |
whismanoid | 0:3edb3708c8c5 | 6244 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6245 | } |
whismanoid | 0:3edb3708c8c5 | 6246 | } |
whismanoid | 0:3edb3708c8c5 | 6247 | break; |
whismanoid | 0:3edb3708c8c5 | 6248 | case 'b': case 'B': |
whismanoid | 0:3edb3708c8c5 | 6249 | { |
whismanoid | 0:3edb3708c8c5 | 6250 | // recommended for hex command codes B0..BF |
whismanoid | 0:3edb3708c8c5 | 6251 | } |
whismanoid | 0:3edb3708c8c5 | 6252 | break; |
whismanoid | 0:3edb3708c8c5 | 6253 | case 'c': case 'C': |
whismanoid | 0:3edb3708c8c5 | 6254 | { |
whismanoid | 0:3edb3708c8c5 | 6255 | // recommended for hex command codes C0..CF |
whismanoid | 0:3edb3708c8c5 | 6256 | // // MAX5717 menu function to drive MAX5717_CLRb_Pin CLR# |
whismanoid | 0:3edb3708c8c5 | 6257 | // cmdLine.serial().printf("\r\n C -- CLR# pulse CH high CL low"); |
whismanoid | 0:3edb3708c8c5 | 6258 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 6259 | { |
whismanoid | 0:3edb3708c8c5 | 6260 | default: |
whismanoid | 0:3edb3708c8c5 | 6261 | // g_MAX5715_device.CLRboutputPulseLow(); |
whismanoid | 0:3edb3708c8c5 | 6262 | g_MAX5715_device.CLRboutputValue(1); |
whismanoid | 0:3edb3708c8c5 | 6263 | g_MAX5715_device.CLRboutputValue(0); |
whismanoid | 0:3edb3708c8c5 | 6264 | g_MAX5715_device.CLRboutputValue(1); |
whismanoid | 0:3edb3708c8c5 | 6265 | break; |
whismanoid | 0:3edb3708c8c5 | 6266 | case 'H': case 'h': case '1': |
whismanoid | 0:3edb3708c8c5 | 6267 | g_MAX5715_device.CLRboutputValue(1); // GPIOoutputCLRb(int isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 6268 | break; |
whismanoid | 0:3edb3708c8c5 | 6269 | case 'L': case 'l': case '0': |
whismanoid | 0:3edb3708c8c5 | 6270 | g_MAX5715_device.CLRboutputValue(0); // GPIOoutputCLRb(int isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 6271 | break; |
whismanoid | 0:3edb3708c8c5 | 6272 | } |
whismanoid | 0:3edb3708c8c5 | 6273 | } |
whismanoid | 0:3edb3708c8c5 | 6274 | break; |
whismanoid | 0:3edb3708c8c5 | 6275 | case 'd': case 'D': |
whismanoid | 0:3edb3708c8c5 | 6276 | { |
whismanoid | 0:3edb3708c8c5 | 6277 | // recommended for hex command codes D0..DF |
whismanoid | 0:3edb3708c8c5 | 6278 | } |
whismanoid | 0:3edb3708c8c5 | 6279 | break; |
whismanoid | 0:3edb3708c8c5 | 6280 | case 'e': case 'E': |
whismanoid | 0:3edb3708c8c5 | 6281 | { |
whismanoid | 0:3edb3708c8c5 | 6282 | // recommended for hex command codes E0..EF |
whismanoid | 0:3edb3708c8c5 | 6283 | } |
whismanoid | 0:3edb3708c8c5 | 6284 | break; |
whismanoid | 0:3edb3708c8c5 | 6285 | case 'f': case 'F': |
whismanoid | 0:3edb3708c8c5 | 6286 | { |
whismanoid | 0:3edb3708c8c5 | 6287 | // recommended for hex command codes F0..FF |
whismanoid | 0:3edb3708c8c5 | 6288 | } |
whismanoid | 0:3edb3708c8c5 | 6289 | break; |
whismanoid | 0:3edb3708c8c5 | 6290 | case 'l': case 'L': |
whismanoid | 0:3edb3708c8c5 | 6291 | { |
whismanoid | 0:3edb3708c8c5 | 6292 | // // MAX5717 menu function to drive MAX5717_LDACb_Pin LDAC# |
whismanoid | 0:3edb3708c8c5 | 6293 | // cmdLine.serial().printf("\r\n L -- LDAC# pulse LH high LL low"); |
whismanoid | 0:3edb3708c8c5 | 6294 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 6295 | { |
whismanoid | 0:3edb3708c8c5 | 6296 | default: |
whismanoid | 0:3edb3708c8c5 | 6297 | // g_MAX5715_device.LDACboutputPulseLow(); |
whismanoid | 0:3edb3708c8c5 | 6298 | g_MAX5715_device.LDACboutputValue(1); |
whismanoid | 0:3edb3708c8c5 | 6299 | g_MAX5715_device.LDACboutputValue(0); |
whismanoid | 0:3edb3708c8c5 | 6300 | g_MAX5715_device.LDACboutputValue(1); |
whismanoid | 0:3edb3708c8c5 | 6301 | break; |
whismanoid | 0:3edb3708c8c5 | 6302 | case 'H': case 'h': case '1': |
whismanoid | 0:3edb3708c8c5 | 6303 | g_MAX5715_device.LDACboutputValue(1); // GPIOoutputLDACb(int isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 6304 | break; |
whismanoid | 0:3edb3708c8c5 | 6305 | case 'L': case 'l': case '0': |
whismanoid | 0:3edb3708c8c5 | 6306 | g_MAX5715_device.LDACboutputValue(0); // GPIOoutputLDACb(int isLogicHigh); |
whismanoid | 0:3edb3708c8c5 | 6307 | break; |
whismanoid | 0:3edb3708c8c5 | 6308 | } |
whismanoid | 0:3edb3708c8c5 | 6309 | } |
whismanoid | 0:3edb3708c8c5 | 6310 | break; |
whismanoid | 0:3edb3708c8c5 | 6311 | case 'x': case 'X': |
whismanoid | 0:3edb3708c8c5 | 6312 | { |
whismanoid | 0:3edb3708c8c5 | 6313 | } |
whismanoid | 0:3edb3708c8c5 | 6314 | break; |
whismanoid | 0:3edb3708c8c5 | 6315 | case 'y': case 'Y': |
whismanoid | 0:3edb3708c8c5 | 6316 | { |
whismanoid | 0:3edb3708c8c5 | 6317 | } |
whismanoid | 0:3edb3708c8c5 | 6318 | break; |
whismanoid | 0:3edb3708c8c5 | 6319 | case 'z': case 'Z': |
whismanoid | 0:3edb3708c8c5 | 6320 | { |
whismanoid | 0:3edb3708c8c5 | 6321 | } |
whismanoid | 0:3edb3708c8c5 | 6322 | break; |
whismanoid | 0:3edb3708c8c5 | 6323 | case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command |
whismanoid | 0:3edb3708c8c5 | 6324 | { |
whismanoid | 0:3edb3708c8c5 | 6325 | // TODO: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 6326 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 6327 | { |
whismanoid | 0:3edb3708c8c5 | 6328 | default: |
whismanoid | 0:3edb3708c8c5 | 6329 | { |
whismanoid | 0:3edb3708c8c5 | 6330 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6331 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6332 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", |
whismanoid | 0:3edb3708c8c5 | 6333 | cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 6334 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6335 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6336 | } |
whismanoid | 0:3edb3708c8c5 | 6337 | } |
whismanoid | 0:3edb3708c8c5 | 6338 | } |
whismanoid | 0:3edb3708c8c5 | 6339 | break; |
whismanoid | 0:3edb3708c8c5 | 6340 | case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command |
whismanoid | 0:3edb3708c8c5 | 6341 | { |
whismanoid | 0:3edb3708c8c5 | 6342 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6343 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6344 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 6345 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6346 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6347 | } |
whismanoid | 0:3edb3708c8c5 | 6348 | break; |
whismanoid | 0:3edb3708c8c5 | 6349 | case '@': |
whismanoid | 0:3edb3708c8c5 | 6350 | { |
whismanoid | 0:3edb3708c8c5 | 6351 | // // |
whismanoid | 0:3edb3708c8c5 | 6352 | // // Menu @ -- print device configuration |
whismanoid | 0:3edb3708c8c5 | 6353 | // TODO: cmdLine.serial().printf("\r\n @ -- print MAX5715 configuration"); |
whismanoid | 0:3edb3708c8c5 | 6354 | // // |
whismanoid | 0:3edb3708c8c5 | 6355 | // print shadow register configuration |
whismanoid | 0:3edb3708c8c5 | 6356 | // |
whismanoid | 0:3edb3708c8c5 | 6357 | // shadow of write-only register CODE dddd_dddd_dddd_0000 |
whismanoid | 0:3edb3708c8c5 | 6358 | //~ int16_t CMD_1000_CODE; |
whismanoid | 0:3edb3708c8c5 | 6359 | int index = 0; |
whismanoid | 0:3edb3708c8c5 | 6360 | for (index = 0; index < 4; index++) |
whismanoid | 0:3edb3708c8c5 | 6361 | { |
whismanoid | 0:3edb3708c8c5 | 6362 | cmdLine.serial().printf("CODE %c=0x%4.4x MAX5715_VoltageOfCode(%d)=%5.3fV\r\n", |
whismanoid | 0:3edb3708c8c5 | 6363 | (char)('A' + index), |
whismanoid | 0:3edb3708c8c5 | 6364 | (g_MAX5715_device.Shadow_0010_nnnn_CODE[index] & 0xFFFF), |
whismanoid | 0:3edb3708c8c5 | 6365 | g_MAX5715_device.CODE[index], |
whismanoid | 0:3edb3708c8c5 | 6366 | g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[index]) |
whismanoid | 0:3edb3708c8c5 | 6367 | ); |
whismanoid | 0:3edb3708c8c5 | 6368 | } |
whismanoid | 0:3edb3708c8c5 | 6369 | // |
whismanoid | 0:3edb3708c8c5 | 6370 | cmdLine.serial().printf("\r\n"); |
whismanoid | 0:3edb3708c8c5 | 6371 | // |
whismanoid | 0:3edb3708c8c5 | 6372 | // |
whismanoid | 0:3edb3708c8c5 | 6373 | // Menu @) print MAX5715 configuration AND g_MAX5715_device globals |
whismanoid | 0:3edb3708c8c5 | 6374 | // |
whismanoid | 0:3edb3708c8c5 | 6375 | #if 1 // SUPPORT_CHANNELS |
whismanoid | 0:3edb3708c8c5 | 6376 | cmdLine.serial().printf("channelNumber_0_3=%d channels_bitmask_DCBA=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6377 | (g_MAX5715_device.channelNumber_0_3 & 0xFFFF), |
whismanoid | 0:3edb3708c8c5 | 6378 | (g_MAX5715_device.channels_bitmask_DCBA & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6379 | #endif // SUPPORT_CHANNELS |
whismanoid | 0:3edb3708c8c5 | 6380 | // |
whismanoid | 0:3edb3708c8c5 | 6381 | cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX5715_device.VRef); |
whismanoid | 0:3edb3708c8c5 | 6382 | // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB |
whismanoid | 0:3edb3708c8c5 | 6383 | } |
whismanoid | 0:3edb3708c8c5 | 6384 | break; |
whismanoid | 0:3edb3708c8c5 | 6385 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 6386 | |
whismanoid | 0:3edb3708c8c5 | 6387 | #if APPLICATION_MAX11131 // main_menu_onEOLcommandParser |
whismanoid | 0:3edb3708c8c5 | 6388 | case '0': |
whismanoid | 0:3edb3708c8c5 | 6389 | { |
whismanoid | 0:3edb3708c8c5 | 6390 | // recommended for hex command codes 00..0F |
whismanoid | 0:3edb3708c8c5 | 6391 | // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void); |
whismanoid | 0:3edb3708c8c5 | 6392 | // TODO: cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead"); |
whismanoid | 0:3edb3708c8c5 | 6393 | if (cmdLine.parse_uint16_dec("n", g_MAX11131_device.NumWords)) |
whismanoid | 0:3edb3708c8c5 | 6394 | { |
whismanoid | 0:3edb3708c8c5 | 6395 | } |
whismanoid | 0:3edb3708c8c5 | 6396 | cmdLine.serial().printf("ScanRead NumWords=%d", g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6397 | if (g_MAX11131_device.isExternalClock) |
whismanoid | 0:3edb3708c8c5 | 6398 | { |
whismanoid | 0:3edb3708c8c5 | 6399 | cmdLine.serial().printf(" External Clock"); |
whismanoid | 0:3edb3708c8c5 | 6400 | // |
whismanoid | 0:3edb3708c8c5 | 6401 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6402 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6403 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6404 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6405 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6406 | // |
whismanoid | 0:3edb3708c8c5 | 6407 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6408 | } |
whismanoid | 0:3edb3708c8c5 | 6409 | else |
whismanoid | 0:3edb3708c8c5 | 6410 | { |
whismanoid | 0:3edb3708c8c5 | 6411 | cmdLine.serial().printf(" Internal Clock"); |
whismanoid | 0:3edb3708c8c5 | 6412 | // |
whismanoid | 0:3edb3708c8c5 | 6413 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6414 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6415 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6416 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6417 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6418 | // |
whismanoid | 0:3edb3708c8c5 | 6419 | AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6420 | } |
whismanoid | 0:3edb3708c8c5 | 6421 | } |
whismanoid | 0:3edb3708c8c5 | 6422 | break; |
whismanoid | 0:3edb3708c8c5 | 6423 | case '1': |
whismanoid | 0:3edb3708c8c5 | 6424 | { |
whismanoid | 0:3edb3708c8c5 | 6425 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 6426 | // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 6427 | // TODO: cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual"); |
whismanoid | 0:3edb3708c8c5 | 6428 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 6429 | { |
whismanoid | 0:3edb3708c8c5 | 6430 | } |
whismanoid | 0:3edb3708c8c5 | 6431 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 6432 | { |
whismanoid | 0:3edb3708c8c5 | 6433 | } |
whismanoid | 0:3edb3708c8c5 | 6434 | if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) |
whismanoid | 0:3edb3708c8c5 | 6435 | { |
whismanoid | 0:3edb3708c8c5 | 6436 | } |
whismanoid | 0:3edb3708c8c5 | 6437 | cmdLine.serial().printf("ScanManual ch=%d pm=%d id=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6438 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 6439 | g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 6440 | g_MAX11131_device.chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 6441 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6442 | // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 6443 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 6444 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); |
whismanoid | 0:3edb3708c8c5 | 6445 | // |
whismanoid | 0:3edb3708c8c5 | 6446 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6447 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6448 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6449 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6450 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6451 | // |
whismanoid | 0:3edb3708c8c5 | 6452 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6453 | } |
whismanoid | 0:3edb3708c8c5 | 6454 | break; |
whismanoid | 0:3edb3708c8c5 | 6455 | case '2': |
whismanoid | 0:3edb3708c8c5 | 6456 | { |
whismanoid | 0:3edb3708c8c5 | 6457 | // recommended for hex command codes 20..2F |
whismanoid | 0:3edb3708c8c5 | 6458 | // 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 | 6459 | // TODO: cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat"); |
whismanoid | 0:3edb3708c8c5 | 6460 | // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6461 | // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6462 | // VERIFY: update value of g_MAX11131_device.nscan_4_8_12_16 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6463 | // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6464 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6465 | // VERIFY: parse strCommandArgs for additional arguments including key=value pairs |
whismanoid | 0:3edb3708c8c5 | 6466 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 6467 | { |
whismanoid | 0:3edb3708c8c5 | 6468 | } |
whismanoid | 0:3edb3708c8c5 | 6469 | if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) |
whismanoid | 0:3edb3708c8c5 | 6470 | { |
whismanoid | 0:3edb3708c8c5 | 6471 | } |
whismanoid | 0:3edb3708c8c5 | 6472 | if (cmdLine.parse_byte_dec("n", g_MAX11131_device.nscan_4_8_12_16)) |
whismanoid | 0:3edb3708c8c5 | 6473 | { |
whismanoid | 0:3edb3708c8c5 | 6474 | } |
whismanoid | 0:3edb3708c8c5 | 6475 | if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) |
whismanoid | 0:3edb3708c8c5 | 6476 | { |
whismanoid | 0:3edb3708c8c5 | 6477 | } |
whismanoid | 0:3edb3708c8c5 | 6478 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 6479 | { |
whismanoid | 0:3edb3708c8c5 | 6480 | } |
whismanoid | 0:3edb3708c8c5 | 6481 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6482 | "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 | 6483 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 6484 | g_MAX11131_device.average_0_4_8_16_32, |
whismanoid | 0:3edb3708c8c5 | 6485 | g_MAX11131_device.nscan_4_8_12_16, |
whismanoid | 0:3edb3708c8c5 | 6486 | g_MAX11131_device.swcnv_0_1, |
whismanoid | 0:3edb3708c8c5 | 6487 | g_MAX11131_device.PowerManagement_0_2); |
whismanoid | 0:3edb3708c8c5 | 6488 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6489 | // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 |
whismanoid | 0:3edb3708c8c5 | 6490 | // VERIFY: replace argument with driver global; g_MAX11131_device.nscan_4_8_12_16 replaces nscan_4_8_12_16 |
whismanoid | 0:3edb3708c8c5 | 6491 | // 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 | 6492 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 6493 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanRepeat(); |
whismanoid | 0:3edb3708c8c5 | 6494 | // |
whismanoid | 0:3edb3708c8c5 | 6495 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6496 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6497 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6498 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6499 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6500 | // |
whismanoid | 0:3edb3708c8c5 | 6501 | AINcode_print_value_chanID_mean(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6502 | } |
whismanoid | 0:3edb3708c8c5 | 6503 | break; |
whismanoid | 0:3edb3708c8c5 | 6504 | case '3': |
whismanoid | 0:3edb3708c8c5 | 6505 | { |
whismanoid | 0:3edb3708c8c5 | 6506 | // recommended for hex command codes 30..3F |
whismanoid | 0:3edb3708c8c5 | 6507 | // 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 | 6508 | // TODO: cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock"); |
whismanoid | 0:3edb3708c8c5 | 6509 | // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6510 | // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6511 | // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6512 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6513 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 6514 | { |
whismanoid | 0:3edb3708c8c5 | 6515 | } |
whismanoid | 0:3edb3708c8c5 | 6516 | if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) |
whismanoid | 0:3edb3708c8c5 | 6517 | { |
whismanoid | 0:3edb3708c8c5 | 6518 | } |
whismanoid | 0:3edb3708c8c5 | 6519 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 6520 | { |
whismanoid | 0:3edb3708c8c5 | 6521 | } |
whismanoid | 0:3edb3708c8c5 | 6522 | if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) |
whismanoid | 0:3edb3708c8c5 | 6523 | { |
whismanoid | 0:3edb3708c8c5 | 6524 | } |
whismanoid | 0:3edb3708c8c5 | 6525 | cmdLine.serial().printf("ScanStandardInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6526 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 6527 | g_MAX11131_device.average_0_4_8_16_32, |
whismanoid | 0:3edb3708c8c5 | 6528 | g_MAX11131_device.swcnv_0_1, |
whismanoid | 0:3edb3708c8c5 | 6529 | g_MAX11131_device.PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6530 | ); |
whismanoid | 0:3edb3708c8c5 | 6531 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6532 | // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 |
whismanoid | 0:3edb3708c8c5 | 6533 | // 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 | 6534 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 6535 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardInternalClock(); |
whismanoid | 0:3edb3708c8c5 | 6536 | // |
whismanoid | 0:3edb3708c8c5 | 6537 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6538 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6539 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6540 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6541 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6542 | // |
whismanoid | 0:3edb3708c8c5 | 6543 | AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6544 | } |
whismanoid | 0:3edb3708c8c5 | 6545 | break; |
whismanoid | 0:3edb3708c8c5 | 6546 | case '4': |
whismanoid | 0:3edb3708c8c5 | 6547 | { |
whismanoid | 0:3edb3708c8c5 | 6548 | // recommended for hex command codes 40..4F |
whismanoid | 0:3edb3708c8c5 | 6549 | // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 6550 | // TODO: cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock"); |
whismanoid | 0:3edb3708c8c5 | 6551 | // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6552 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6553 | // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6554 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 6555 | { |
whismanoid | 0:3edb3708c8c5 | 6556 | } |
whismanoid | 0:3edb3708c8c5 | 6557 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 6558 | { |
whismanoid | 0:3edb3708c8c5 | 6559 | } |
whismanoid | 0:3edb3708c8c5 | 6560 | if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) |
whismanoid | 0:3edb3708c8c5 | 6561 | { |
whismanoid | 0:3edb3708c8c5 | 6562 | } |
whismanoid | 0:3edb3708c8c5 | 6563 | cmdLine.serial().printf("ScanStandardExternalClock ch=%d pm=%d id=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6564 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 6565 | g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 6566 | g_MAX11131_device.chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 6567 | ); |
whismanoid | 0:3edb3708c8c5 | 6568 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6569 | // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 6570 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 6571 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 6572 | // |
whismanoid | 0:3edb3708c8c5 | 6573 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6574 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6575 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6576 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6577 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6578 | // |
whismanoid | 0:3edb3708c8c5 | 6579 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6580 | } |
whismanoid | 0:3edb3708c8c5 | 6581 | break; |
whismanoid | 0:3edb3708c8c5 | 6582 | case '5': |
whismanoid | 0:3edb3708c8c5 | 6583 | { |
whismanoid | 0:3edb3708c8c5 | 6584 | // recommended for hex command codes 50..5F |
whismanoid | 0:3edb3708c8c5 | 6585 | // 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 | 6586 | // TODO: cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock"); |
whismanoid | 0:3edb3708c8c5 | 6587 | // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6588 | // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6589 | // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6590 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6591 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 6592 | { |
whismanoid | 0:3edb3708c8c5 | 6593 | } |
whismanoid | 0:3edb3708c8c5 | 6594 | if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) |
whismanoid | 0:3edb3708c8c5 | 6595 | { |
whismanoid | 0:3edb3708c8c5 | 6596 | } |
whismanoid | 0:3edb3708c8c5 | 6597 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 6598 | { |
whismanoid | 0:3edb3708c8c5 | 6599 | } |
whismanoid | 0:3edb3708c8c5 | 6600 | if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) |
whismanoid | 0:3edb3708c8c5 | 6601 | { |
whismanoid | 0:3edb3708c8c5 | 6602 | } |
whismanoid | 0:3edb3708c8c5 | 6603 | cmdLine.serial().printf("ScanUpperInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6604 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 6605 | g_MAX11131_device.average_0_4_8_16_32, |
whismanoid | 0:3edb3708c8c5 | 6606 | g_MAX11131_device.swcnv_0_1, |
whismanoid | 0:3edb3708c8c5 | 6607 | g_MAX11131_device.PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6608 | ); |
whismanoid | 0:3edb3708c8c5 | 6609 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6610 | // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 |
whismanoid | 0:3edb3708c8c5 | 6611 | // 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 | 6612 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 6613 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperInternalClock(); |
whismanoid | 0:3edb3708c8c5 | 6614 | // |
whismanoid | 0:3edb3708c8c5 | 6615 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6616 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6617 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6618 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6619 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6620 | // |
whismanoid | 0:3edb3708c8c5 | 6621 | AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6622 | } |
whismanoid | 0:3edb3708c8c5 | 6623 | break; |
whismanoid | 0:3edb3708c8c5 | 6624 | case '6': |
whismanoid | 0:3edb3708c8c5 | 6625 | { |
whismanoid | 0:3edb3708c8c5 | 6626 | // recommended for hex command codes 60..6F |
whismanoid | 0:3edb3708c8c5 | 6627 | // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 6628 | // TODO: cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock"); |
whismanoid | 0:3edb3708c8c5 | 6629 | // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6630 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6631 | // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6632 | if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) |
whismanoid | 0:3edb3708c8c5 | 6633 | { |
whismanoid | 0:3edb3708c8c5 | 6634 | } |
whismanoid | 0:3edb3708c8c5 | 6635 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 6636 | { |
whismanoid | 0:3edb3708c8c5 | 6637 | } |
whismanoid | 0:3edb3708c8c5 | 6638 | if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) |
whismanoid | 0:3edb3708c8c5 | 6639 | { |
whismanoid | 0:3edb3708c8c5 | 6640 | } |
whismanoid | 0:3edb3708c8c5 | 6641 | cmdLine.serial().printf("ScanUpperExternalClock ch=%d pm=%d id=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6642 | g_MAX11131_device.channelNumber_0_15, |
whismanoid | 0:3edb3708c8c5 | 6643 | g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 6644 | g_MAX11131_device.chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 6645 | ); |
whismanoid | 0:3edb3708c8c5 | 6646 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6647 | // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 6648 | // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 |
whismanoid | 0:3edb3708c8c5 | 6649 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 6650 | // |
whismanoid | 0:3edb3708c8c5 | 6651 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6652 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6653 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6654 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6655 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6656 | // |
whismanoid | 0:3edb3708c8c5 | 6657 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6658 | } |
whismanoid | 0:3edb3708c8c5 | 6659 | break; |
whismanoid | 0:3edb3708c8c5 | 6660 | case '7': |
whismanoid | 0:3edb3708c8c5 | 6661 | { |
whismanoid | 0:3edb3708c8c5 | 6662 | // recommended for hex command codes 70..7F |
whismanoid | 0:3edb3708c8c5 | 6663 | // 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 | 6664 | // TODO: cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock"); |
whismanoid | 0:3edb3708c8c5 | 6665 | // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6666 | // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6667 | // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6668 | if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask)) |
whismanoid | 0:3edb3708c8c5 | 6669 | { |
whismanoid | 0:3edb3708c8c5 | 6670 | // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6671 | } |
whismanoid | 0:3edb3708c8c5 | 6672 | if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) |
whismanoid | 0:3edb3708c8c5 | 6673 | { |
whismanoid | 0:3edb3708c8c5 | 6674 | } |
whismanoid | 0:3edb3708c8c5 | 6675 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 6676 | { |
whismanoid | 0:3edb3708c8c5 | 6677 | } |
whismanoid | 0:3edb3708c8c5 | 6678 | if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) |
whismanoid | 0:3edb3708c8c5 | 6679 | { |
whismanoid | 0:3edb3708c8c5 | 6680 | } |
whismanoid | 0:3edb3708c8c5 | 6681 | cmdLine.serial().printf( |
whismanoid | 0:3edb3708c8c5 | 6682 | "ScanCustomInternalClock enabledChannelsMask:0x%4.4x average_0_4_8_16_32:%d pm=%d swcnv=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6683 | (g_MAX11131_device.enabledChannelsMask & 0xFFFF), |
whismanoid | 0:3edb3708c8c5 | 6684 | g_MAX11131_device.average_0_4_8_16_32, |
whismanoid | 0:3edb3708c8c5 | 6685 | g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 6686 | g_MAX11131_device.swcnv_0_1 |
whismanoid | 0:3edb3708c8c5 | 6687 | ); |
whismanoid | 0:3edb3708c8c5 | 6688 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6689 | // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 |
whismanoid | 0:3edb3708c8c5 | 6690 | // 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 | 6691 | // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask |
whismanoid | 0:3edb3708c8c5 | 6692 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomInternalClock(); |
whismanoid | 0:3edb3708c8c5 | 6693 | // |
whismanoid | 0:3edb3708c8c5 | 6694 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6695 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6696 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6697 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6698 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6699 | // |
whismanoid | 0:3edb3708c8c5 | 6700 | AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6701 | } |
whismanoid | 0:3edb3708c8c5 | 6702 | break; |
whismanoid | 0:3edb3708c8c5 | 6703 | case '8': |
whismanoid | 0:3edb3708c8c5 | 6704 | { |
whismanoid | 0:3edb3708c8c5 | 6705 | // recommended for hex command codes 80..8F |
whismanoid | 0:3edb3708c8c5 | 6706 | // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 6707 | // TODO: cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock"); |
whismanoid | 0:3edb3708c8c5 | 6708 | if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask)) |
whismanoid | 0:3edb3708c8c5 | 6709 | { |
whismanoid | 0:3edb3708c8c5 | 6710 | // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs |
whismanoid | 0:3edb3708c8c5 | 6711 | } |
whismanoid | 0:3edb3708c8c5 | 6712 | if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) |
whismanoid | 0:3edb3708c8c5 | 6713 | { |
whismanoid | 0:3edb3708c8c5 | 6714 | } |
whismanoid | 0:3edb3708c8c5 | 6715 | if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) |
whismanoid | 0:3edb3708c8c5 | 6716 | { |
whismanoid | 0:3edb3708c8c5 | 6717 | } |
whismanoid | 0:3edb3708c8c5 | 6718 | cmdLine.serial().printf("ScanCustomExternalClock enabledChannelsMask:0x%4.4x pm=%d id=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6719 | (g_MAX11131_device.enabledChannelsMask & 0xFFFF), |
whismanoid | 0:3edb3708c8c5 | 6720 | g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 6721 | g_MAX11131_device.chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 6722 | ); |
whismanoid | 0:3edb3708c8c5 | 6723 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6724 | // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 6725 | // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask |
whismanoid | 0:3edb3708c8c5 | 6726 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 6727 | // |
whismanoid | 0:3edb3708c8c5 | 6728 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6729 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6730 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6731 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6732 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6733 | // |
whismanoid | 0:3edb3708c8c5 | 6734 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6735 | } |
whismanoid | 0:3edb3708c8c5 | 6736 | break; |
whismanoid | 0:3edb3708c8c5 | 6737 | case '9': |
whismanoid | 0:3edb3708c8c5 | 6738 | { |
whismanoid | 0:3edb3708c8c5 | 6739 | // recommended for hex command codes 90..9F |
whismanoid | 0:3edb3708c8c5 | 6740 | // 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 | 6741 | // TODO: cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock"); |
whismanoid | 0:3edb3708c8c5 | 6742 | // |
whismanoid | 0:3edb3708c8c5 | 6743 | // get MAX11131 Sampleset channel selection pattern parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 6744 | // cmdLine.parse_byteCount_byteList_dec(byteCount, mosiData, MAX_SPI_BYTE_COUNT) |
whismanoid | 0:3edb3708c8c5 | 6745 | // into g_MAX11131_device.enabledChannelsPatternLength_1_256 |
whismanoid | 0:3edb3708c8c5 | 6746 | // into g_MAX11131_device.enabledChannelsPattern[0..255] |
whismanoid | 0:3edb3708c8c5 | 6747 | size_t numValues; |
whismanoid | 0:3edb3708c8c5 | 6748 | char valueList[256]; |
whismanoid | 0:3edb3708c8c5 | 6749 | if (cmdLine.parse_byteCount_byteList_dec( numValues, valueList, 256)) |
whismanoid | 0:3edb3708c8c5 | 6750 | { |
whismanoid | 0:3edb3708c8c5 | 6751 | // first value is the "9" command itself |
whismanoid | 0:3edb3708c8c5 | 6752 | g_MAX11131_device.enabledChannelsPatternLength_1_256 = numValues - 1; |
whismanoid | 0:3edb3708c8c5 | 6753 | // copy valueList[1, ...] into g_MAX11131_device.enabledChannelsPattern[0, ...] |
whismanoid | 0:3edb3708c8c5 | 6754 | for (size_t index = 0; index < (numValues - 1); index++) |
whismanoid | 0:3edb3708c8c5 | 6755 | { |
whismanoid | 0:3edb3708c8c5 | 6756 | g_MAX11131_device.enabledChannelsPattern[index] = valueList[1 + index]; |
whismanoid | 0:3edb3708c8c5 | 6757 | } |
whismanoid | 0:3edb3708c8c5 | 6758 | } |
whismanoid | 0:3edb3708c8c5 | 6759 | // |
whismanoid | 0:3edb3708c8c5 | 6760 | cmdLine.serial().printf("ScanSampleSetExternalClock enabledChannelsPattern:{ "); |
whismanoid | 0:3edb3708c8c5 | 6761 | int index; |
whismanoid | 0:3edb3708c8c5 | 6762 | for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++) |
whismanoid | 0:3edb3708c8c5 | 6763 | { |
whismanoid | 0:3edb3708c8c5 | 6764 | //~ Serial.print( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC); |
whismanoid | 0:3edb3708c8c5 | 6765 | //~ Serial.print(" "); |
whismanoid | 0:3edb3708c8c5 | 6766 | cmdLine.serial().printf("AIN%d ", ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F)); |
whismanoid | 0:3edb3708c8c5 | 6767 | } |
whismanoid | 0:3edb3708c8c5 | 6768 | cmdLine.serial().printf("}"); |
whismanoid | 0:3edb3708c8c5 | 6769 | cmdLine.serial().printf(" pm=%d id=%d\r\n", g_MAX11131_device.PowerManagement_0_2, |
whismanoid | 0:3edb3708c8c5 | 6770 | g_MAX11131_device.chan_id_0_1); |
whismanoid | 0:3edb3708c8c5 | 6771 | // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 |
whismanoid | 0:3edb3708c8c5 | 6772 | // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 |
whismanoid | 0:3edb3708c8c5 | 6773 | g_MAX11131_device.NumWords = g_MAX11131_device.ScanSampleSetExternalClock(); |
whismanoid | 0:3edb3708c8c5 | 6774 | // |
whismanoid | 0:3edb3708c8c5 | 6775 | // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] |
whismanoid | 0:3edb3708c8c5 | 6776 | // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords |
whismanoid | 0:3edb3708c8c5 | 6777 | g_MAX11131_device.ReadAINcode(); |
whismanoid | 0:3edb3708c8c5 | 6778 | // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data |
whismanoid | 0:3edb3708c8c5 | 6779 | // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs |
whismanoid | 0:3edb3708c8c5 | 6780 | // |
whismanoid | 0:3edb3708c8c5 | 6781 | AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); |
whismanoid | 0:3edb3708c8c5 | 6782 | } |
whismanoid | 0:3edb3708c8c5 | 6783 | break; |
whismanoid | 0:3edb3708c8c5 | 6784 | case 'a': case 'A': |
whismanoid | 0:3edb3708c8c5 | 6785 | { |
whismanoid | 0:3edb3708c8c5 | 6786 | // recommended for hex command codes A0..AF |
whismanoid | 0:3edb3708c8c5 | 6787 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 6788 | { |
whismanoid | 0:3edb3708c8c5 | 6789 | case 't': case 'T': |
whismanoid | 0:3edb3708c8c5 | 6790 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6791 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6792 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 6793 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6794 | // AT command: skip the prompt to avoid confusing modem detector |
whismanoid | 0:3edb3708c8c5 | 6795 | return; |
whismanoid | 0:3edb3708c8c5 | 6796 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6797 | } |
whismanoid | 0:3edb3708c8c5 | 6798 | } |
whismanoid | 0:3edb3708c8c5 | 6799 | break; |
whismanoid | 0:3edb3708c8c5 | 6800 | case 'b': case 'B': |
whismanoid | 0:3edb3708c8c5 | 6801 | { |
whismanoid | 0:3edb3708c8c5 | 6802 | // recommended for hex command codes B0..BF |
whismanoid | 0:3edb3708c8c5 | 6803 | } |
whismanoid | 0:3edb3708c8c5 | 6804 | break; |
whismanoid | 0:3edb3708c8c5 | 6805 | case 'c': case 'C': |
whismanoid | 0:3edb3708c8c5 | 6806 | { |
whismanoid | 0:3edb3708c8c5 | 6807 | // recommended for hex command codes C0..CF |
whismanoid | 0:3edb3708c8c5 | 6808 | } |
whismanoid | 0:3edb3708c8c5 | 6809 | break; |
whismanoid | 0:3edb3708c8c5 | 6810 | case 'd': case 'D': |
whismanoid | 0:3edb3708c8c5 | 6811 | { |
whismanoid | 0:3edb3708c8c5 | 6812 | // recommended for hex command codes D0..DF |
whismanoid | 0:3edb3708c8c5 | 6813 | } |
whismanoid | 0:3edb3708c8c5 | 6814 | break; |
whismanoid | 0:3edb3708c8c5 | 6815 | case 'e': case 'E': |
whismanoid | 0:3edb3708c8c5 | 6816 | { |
whismanoid | 0:3edb3708c8c5 | 6817 | // recommended for hex command codes E0..EF |
whismanoid | 0:3edb3708c8c5 | 6818 | } |
whismanoid | 0:3edb3708c8c5 | 6819 | break; |
whismanoid | 0:3edb3708c8c5 | 6820 | case 'f': case 'F': |
whismanoid | 0:3edb3708c8c5 | 6821 | { |
whismanoid | 0:3edb3708c8c5 | 6822 | // recommended for hex command codes F0..FF |
whismanoid | 0:3edb3708c8c5 | 6823 | } |
whismanoid | 0:3edb3708c8c5 | 6824 | break; |
whismanoid | 0:3edb3708c8c5 | 6825 | case 'x': case 'X': |
whismanoid | 0:3edb3708c8c5 | 6826 | { |
whismanoid | 0:3edb3708c8c5 | 6827 | } |
whismanoid | 0:3edb3708c8c5 | 6828 | break; |
whismanoid | 0:3edb3708c8c5 | 6829 | case 'y': case 'Y': |
whismanoid | 0:3edb3708c8c5 | 6830 | { |
whismanoid | 0:3edb3708c8c5 | 6831 | } |
whismanoid | 0:3edb3708c8c5 | 6832 | break; |
whismanoid | 0:3edb3708c8c5 | 6833 | case 'i': case 'I': |
whismanoid | 0:3edb3708c8c5 | 6834 | { |
whismanoid | 0:3edb3708c8c5 | 6835 | // TODO: cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range"); |
whismanoid | 0:3edb3708c8c5 | 6836 | char strChannelId[3]; |
whismanoid | 0:3edb3708c8c5 | 6837 | strChannelId[0] = cmdLine[2]; |
whismanoid | 0:3edb3708c8c5 | 6838 | strChannelId[1] = cmdLine[3]; |
whismanoid | 0:3edb3708c8c5 | 6839 | strChannelId[2] = '\0'; |
whismanoid | 0:3edb3708c8c5 | 6840 | int channelId_0_15 = strtoul(strChannelId, NULL, 10); // strtol(str, NULL, 10): get decimal value |
whismanoid | 0:3edb3708c8c5 | 6841 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 6842 | { |
whismanoid | 0:3edb3708c8c5 | 6843 | case 's': case 'S': |
whismanoid | 0:3edb3708c8c5 | 6844 | g_MAX11131_device.Reconfigure_SingleEnded(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 6845 | break; |
whismanoid | 0:3edb3708c8c5 | 6846 | case 'u': case 'U': |
whismanoid | 0:3edb3708c8c5 | 6847 | g_MAX11131_device.Reconfigure_DifferentialUnipolar(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 6848 | break; |
whismanoid | 0:3edb3708c8c5 | 6849 | case 'b': case 'B': |
whismanoid | 0:3edb3708c8c5 | 6850 | g_MAX11131_device.Reconfigure_DifferentialBipolarFSVref(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 6851 | break; |
whismanoid | 0:3edb3708c8c5 | 6852 | case 'r': case 'R': |
whismanoid | 0:3edb3708c8c5 | 6853 | g_MAX11131_device.Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 6854 | break; |
whismanoid | 0:3edb3708c8c5 | 6855 | } |
whismanoid | 0:3edb3708c8c5 | 6856 | // char cmd1 = strCommandArgs[0]; |
whismanoid | 0:3edb3708c8c5 | 6857 | // strCommandArgs.remove(0, 1); // unsigned int index, unsigned int count |
whismanoid | 0:3edb3708c8c5 | 6858 | // // get argument int channelId_0_15 |
whismanoid | 0:3edb3708c8c5 | 6859 | // // parse_strCommandArgs(strCommandArgs); |
whismanoid | 0:3edb3708c8c5 | 6860 | // int channelId_0_15 = strtoul(strCommandArgs.c_str(), NULL, 10); // strtol(str, NULL, 10): get decimal value |
whismanoid | 0:3edb3708c8c5 | 6861 | // if (cmd1 == 'S') { |
whismanoid | 0:3edb3708c8c5 | 6862 | // MAX11131_Reconfigure_SingleEnded(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 6863 | // } |
whismanoid | 0:3edb3708c8c5 | 6864 | // else if (cmd1 == 'U') { |
whismanoid | 0:3edb3708c8c5 | 6865 | // MAX11131_Reconfigure_DifferentialUnipolar(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 6866 | // } |
whismanoid | 0:3edb3708c8c5 | 6867 | // else if (cmd1 == 'B') { |
whismanoid | 0:3edb3708c8c5 | 6868 | // MAX11131_Reconfigure_DifferentialBipolarFSVref(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 6869 | // } |
whismanoid | 0:3edb3708c8c5 | 6870 | // else if (cmd1 == 'R') { |
whismanoid | 0:3edb3708c8c5 | 6871 | // MAX11131_Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15); |
whismanoid | 0:3edb3708c8c5 | 6872 | // } |
whismanoid | 0:3edb3708c8c5 | 6873 | } |
whismanoid | 0:3edb3708c8c5 | 6874 | break; |
whismanoid | 0:3edb3708c8c5 | 6875 | case '@': |
whismanoid | 0:3edb3708c8c5 | 6876 | { |
whismanoid | 0:3edb3708c8c5 | 6877 | // TODO: cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration"); |
whismanoid | 0:3edb3708c8c5 | 6878 | // print shadow register configuration |
whismanoid | 0:3edb3708c8c5 | 6879 | // |
whismanoid | 0:3edb3708c8c5 | 6880 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_MODE_CONTROL & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6881 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_MODE_CONTROL); |
whismanoid | 0:3edb3708c8c5 | 6882 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_CONFIGURATION & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6883 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_CONFIGURATION); |
whismanoid | 0:3edb3708c8c5 | 6884 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.UNIPOLAR & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6885 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.UNIPOLAR); |
whismanoid | 0:3edb3708c8c5 | 6886 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.BIPOLAR & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6887 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.BIPOLAR); |
whismanoid | 0:3edb3708c8c5 | 6888 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.RANGE & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6889 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.RANGE); |
whismanoid | 0:3edb3708c8c5 | 6890 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN0 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6891 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN0); |
whismanoid | 0:3edb3708c8c5 | 6892 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN1 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6893 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN1); |
whismanoid | 0:3edb3708c8c5 | 6894 | cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.SAMPLESET & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6895 | MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.SAMPLESET); |
whismanoid | 0:3edb3708c8c5 | 6896 | // |
whismanoid | 0:3edb3708c8c5 | 6897 | // VERIFY: print shadow SAMPLESET pattern entry |
whismanoid | 0:3edb3708c8c5 | 6898 | int entryIndex; |
whismanoid | 0:3edb3708c8c5 | 6899 | for (entryIndex = 0; entryIndex < g_MAX11131_device.enabledChannelsPatternLength_1_256; |
whismanoid | 0:3edb3708c8c5 | 6900 | entryIndex += 4) |
whismanoid | 0:3edb3708c8c5 | 6901 | { |
whismanoid | 0:3edb3708c8c5 | 6902 | uint16_t pack4channels = 0; |
whismanoid | 0:3edb3708c8c5 | 6903 | pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 0]) & 0x0F) << 12); |
whismanoid | 0:3edb3708c8c5 | 6904 | if ((entryIndex + 1) < g_MAX11131_device.enabledChannelsPatternLength_1_256) { |
whismanoid | 0:3edb3708c8c5 | 6905 | pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 1]) & 0x0F) << 8); |
whismanoid | 0:3edb3708c8c5 | 6906 | } |
whismanoid | 0:3edb3708c8c5 | 6907 | if ((entryIndex + 2) < g_MAX11131_device.enabledChannelsPatternLength_1_256) { |
whismanoid | 0:3edb3708c8c5 | 6908 | pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 2]) & 0x0F) << 4); |
whismanoid | 0:3edb3708c8c5 | 6909 | } |
whismanoid | 0:3edb3708c8c5 | 6910 | if ((entryIndex + 3) < g_MAX11131_device.enabledChannelsPatternLength_1_256) { |
whismanoid | 0:3edb3708c8c5 | 6911 | pack4channels |= ((g_MAX11131_device.enabledChannelsPattern[entryIndex + 3]) & 0x0F); |
whismanoid | 0:3edb3708c8c5 | 6912 | } |
whismanoid | 0:3edb3708c8c5 | 6913 | //~ SPIwrite16bits(pack4channels); |
whismanoid | 0:3edb3708c8c5 | 6914 | cmdLine.serial().printf(" 0x%4.4x", (pack4channels & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6915 | // decode SAMPLESET channel select pattern |
whismanoid | 0:3edb3708c8c5 | 6916 | cmdLine.serial().printf(" SampleSet Entry: AIN%d AIN%d AIN%d AIN%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6917 | ((pack4channels >> 12) & 0x000F), |
whismanoid | 0:3edb3708c8c5 | 6918 | ((pack4channels >> 8) & 0x000F), |
whismanoid | 0:3edb3708c8c5 | 6919 | ((pack4channels >> 4) & 0x000F), |
whismanoid | 0:3edb3708c8c5 | 6920 | ((pack4channels ) & 0x000F) |
whismanoid | 0:3edb3708c8c5 | 6921 | ); |
whismanoid | 0:3edb3708c8c5 | 6922 | } |
whismanoid | 0:3edb3708c8c5 | 6923 | //cmdLine.serial().printf(" SAMPLESET enabledChannelsPattern:{ "); |
whismanoid | 0:3edb3708c8c5 | 6924 | //int index; |
whismanoid | 0:3edb3708c8c5 | 6925 | //for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++) |
whismanoid | 0:3edb3708c8c5 | 6926 | //{ |
whismanoid | 0:3edb3708c8c5 | 6927 | // //~ cmdLine.serial().printf( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC); |
whismanoid | 0:3edb3708c8c5 | 6928 | // //~ cmdLine.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 6929 | // cmdLine.serial().printf("AIN"); |
whismanoid | 0:3edb3708c8c5 | 6930 | // cmdLine.serial().printf( ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F), DEC); |
whismanoid | 0:3edb3708c8c5 | 6931 | // cmdLine.serial().printf(" "); |
whismanoid | 0:3edb3708c8c5 | 6932 | //} |
whismanoid | 0:3edb3708c8c5 | 6933 | //cmdLine.serial().printf("}"); |
whismanoid | 0:3edb3708c8c5 | 6934 | // |
whismanoid | 0:3edb3708c8c5 | 6935 | // Menu @) print MAX11131 configuration AND g_MAX11131_device globals |
whismanoid | 0:3edb3708c8c5 | 6936 | // |
whismanoid | 0:3edb3708c8c5 | 6937 | cmdLine.serial().printf("SPI_MOSI_Semantic=%d\r\n", (g_MAX11131_device.SPI_MOSI_Semantic & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6938 | cmdLine.serial().printf("NumWords=%d\r\n", (g_MAX11131_device.NumWords & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6939 | cmdLine.serial().printf("isExternalClock=%d\r\n", (g_MAX11131_device.isExternalClock & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6940 | cmdLine.serial().printf("ScanMode=%d\r\n", (g_MAX11131_device.ScanMode & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6941 | cmdLine.serial().printf("channelNumber_0_15=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6942 | (g_MAX11131_device.channelNumber_0_15 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6943 | cmdLine.serial().printf("PowerManagement_0_2=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6944 | (g_MAX11131_device.PowerManagement_0_2 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6945 | cmdLine.serial().printf("chan_id_0_1=%d\r\n", (g_MAX11131_device.chan_id_0_1 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6946 | cmdLine.serial().printf("average_0_4_8_16_32=%d\r\n", |
whismanoid | 0:3edb3708c8c5 | 6947 | (g_MAX11131_device.average_0_4_8_16_32 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6948 | cmdLine.serial().printf("nscan_4_8_12_16=%d\r\n", (g_MAX11131_device.nscan_4_8_12_16 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6949 | cmdLine.serial().printf("swcnv_0_1=%d\r\n", (g_MAX11131_device.swcnv_0_1 & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6950 | cmdLine.serial().printf("enabledChannelsMask=0x%4.4x\r\n", |
whismanoid | 0:3edb3708c8c5 | 6951 | (g_MAX11131_device.enabledChannelsMask & 0xFFFF)); |
whismanoid | 0:3edb3708c8c5 | 6952 | // |
whismanoid | 0:3edb3708c8c5 | 6953 | cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX11131_device.VRef); |
whismanoid | 0:3edb3708c8c5 | 6954 | // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB |
whismanoid | 0:3edb3708c8c5 | 6955 | // |
whismanoid | 0:3edb3708c8c5 | 6956 | } |
whismanoid | 0:3edb3708c8c5 | 6957 | //case '&': |
whismanoid | 0:3edb3708c8c5 | 6958 | //{ |
whismanoid | 0:3edb3708c8c5 | 6959 | // // TODO: cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual"); |
whismanoid | 0:3edb3708c8c5 | 6960 | //} |
whismanoid | 0:3edb3708c8c5 | 6961 | break; |
whismanoid | 0:3edb3708c8c5 | 6962 | case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command |
whismanoid | 0:3edb3708c8c5 | 6963 | { |
whismanoid | 0:3edb3708c8c5 | 6964 | // TODO: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 6965 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6966 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6967 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 6968 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6969 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6970 | } |
whismanoid | 0:3edb3708c8c5 | 6971 | break; |
whismanoid | 0:3edb3708c8c5 | 6972 | case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command |
whismanoid | 0:3edb3708c8c5 | 6973 | { |
whismanoid | 0:3edb3708c8c5 | 6974 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6975 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6976 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 6977 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 6978 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 6979 | } |
whismanoid | 0:3edb3708c8c5 | 6980 | break; |
whismanoid | 0:3edb3708c8c5 | 6981 | #endif // APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 6982 | |
whismanoid | 0:3edb3708c8c5 | 6983 | #if APPLICATION_MAX5171 // main_menu_onEOLcommandParser |
whismanoid | 0:3edb3708c8c5 | 6984 | // MAX5171 main_menu_onEOLcommandParser |
whismanoid | 0:3edb3708c8c5 | 6985 | case '0': |
whismanoid | 0:3edb3708c8c5 | 6986 | { |
whismanoid | 0:3edb3708c8c5 | 6987 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 6988 | //~ cmdLine.serial().printf("\r\n 0 code=? -- CODE"); |
whismanoid | 0:3edb3708c8c5 | 6989 | uint16_t code; |
whismanoid | 0:3edb3708c8c5 | 6990 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 6991 | { |
whismanoid | 0:3edb3708c8c5 | 6992 | } |
whismanoid | 0:3edb3708c8c5 | 6993 | cmdLine.serial().printf("CODE code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 6994 | g_MAX5171_device.CODE(code); |
whismanoid | 0:3edb3708c8c5 | 6995 | } |
whismanoid | 0:3edb3708c8c5 | 6996 | break; |
whismanoid | 0:3edb3708c8c5 | 6997 | case '4': |
whismanoid | 0:3edb3708c8c5 | 6998 | { |
whismanoid | 0:3edb3708c8c5 | 6999 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 7000 | //~ cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD"); |
whismanoid | 0:3edb3708c8c5 | 7001 | uint16_t code; |
whismanoid | 0:3edb3708c8c5 | 7002 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 7003 | { |
whismanoid | 0:3edb3708c8c5 | 7004 | } |
whismanoid | 0:3edb3708c8c5 | 7005 | cmdLine.serial().printf("CODE_LOAD code=%d", code); |
whismanoid | 0:3edb3708c8c5 | 7006 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 0:3edb3708c8c5 | 7007 | } |
whismanoid | 0:3edb3708c8c5 | 7008 | break; |
whismanoid | 0:3edb3708c8c5 | 7009 | case '8': |
whismanoid | 0:3edb3708c8c5 | 7010 | { |
whismanoid | 0:3edb3708c8c5 | 7011 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 7012 | //~ cmdLine.serial().printf("\r\n 8 -- LOAD"); |
whismanoid | 0:3edb3708c8c5 | 7013 | cmdLine.serial().printf("LOAD"); |
whismanoid | 0:3edb3708c8c5 | 7014 | g_MAX5171_device.LOAD(); |
whismanoid | 0:3edb3708c8c5 | 7015 | } |
whismanoid | 0:3edb3708c8c5 | 7016 | break; |
whismanoid | 0:3edb3708c8c5 | 7017 | case 'c': case 'C': |
whismanoid | 0:3edb3708c8c5 | 7018 | { |
whismanoid | 0:3edb3708c8c5 | 7019 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 7020 | //~ cmdLine.serial().printf("\r\n c -- NOP"); |
whismanoid | 0:3edb3708c8c5 | 7021 | cmdLine.serial().printf("NOP"); |
whismanoid | 0:3edb3708c8c5 | 7022 | g_MAX5171_device.NOP(); |
whismanoid | 0:3edb3708c8c5 | 7023 | } |
whismanoid | 0:3edb3708c8c5 | 7024 | break; |
whismanoid | 0:3edb3708c8c5 | 7025 | case 'd': case 'D': |
whismanoid | 0:3edb3708c8c5 | 7026 | { |
whismanoid | 0:3edb3708c8c5 | 7027 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 7028 | //~ cmdLine.serial().printf("\r\n d -- SHUTDOWN"); |
whismanoid | 0:3edb3708c8c5 | 7029 | cmdLine.serial().printf("SHUTDOWN"); |
whismanoid | 0:3edb3708c8c5 | 7030 | g_MAX5171_device.SHUTDOWN(); |
whismanoid | 0:3edb3708c8c5 | 7031 | } |
whismanoid | 0:3edb3708c8c5 | 7032 | break; |
whismanoid | 0:3edb3708c8c5 | 7033 | case 'e': case 'E': |
whismanoid | 0:3edb3708c8c5 | 7034 | { |
whismanoid | 0:3edb3708c8c5 | 7035 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 7036 | { |
whismanoid | 0:3edb3708c8c5 | 7037 | case '0': |
whismanoid | 0:3edb3708c8c5 | 7038 | { |
whismanoid | 0:3edb3708c8c5 | 7039 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 7040 | //~ cmdLine.serial().printf("\r\n e0 -- UPO_LOW"); |
whismanoid | 0:3edb3708c8c5 | 7041 | cmdLine.serial().printf("UPO_LOW"); |
whismanoid | 0:3edb3708c8c5 | 7042 | g_MAX5171_device.UPO_LOW(); |
whismanoid | 0:3edb3708c8c5 | 7043 | } |
whismanoid | 0:3edb3708c8c5 | 7044 | break; |
whismanoid | 0:3edb3708c8c5 | 7045 | case '8': |
whismanoid | 0:3edb3708c8c5 | 7046 | { |
whismanoid | 0:3edb3708c8c5 | 7047 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 7048 | //~ cmdLine.serial().printf("\r\n e8 -- UPO_HIGH"); |
whismanoid | 0:3edb3708c8c5 | 7049 | cmdLine.serial().printf("UPO_HIGH"); |
whismanoid | 0:3edb3708c8c5 | 7050 | g_MAX5171_device.UPO_HIGH(); |
whismanoid | 0:3edb3708c8c5 | 7051 | } |
whismanoid | 0:3edb3708c8c5 | 7052 | break; |
whismanoid | 0:3edb3708c8c5 | 7053 | } |
whismanoid | 0:3edb3708c8c5 | 7054 | } |
whismanoid | 0:3edb3708c8c5 | 7055 | break; |
whismanoid | 0:3edb3708c8c5 | 7056 | case 'f': case 'F': |
whismanoid | 0:3edb3708c8c5 | 7057 | { |
whismanoid | 0:3edb3708c8c5 | 7058 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 7059 | { |
whismanoid | 0:3edb3708c8c5 | 7060 | case '0': |
whismanoid | 0:3edb3708c8c5 | 7061 | { |
whismanoid | 0:3edb3708c8c5 | 7062 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 7063 | //~ cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 7064 | cmdLine.serial().printf("MODE1_DOUT_SCLK_RISING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 7065 | g_MAX5171_device.MODE1_DOUT_SCLK_RISING_EDGE(); |
whismanoid | 0:3edb3708c8c5 | 7066 | } |
whismanoid | 0:3edb3708c8c5 | 7067 | break; |
whismanoid | 0:3edb3708c8c5 | 7068 | case '8': |
whismanoid | 0:3edb3708c8c5 | 7069 | { |
whismanoid | 0:3edb3708c8c5 | 7070 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 7071 | //~ cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 7072 | cmdLine.serial().printf("MODE0_DOUT_SCLK_FALLING_EDGE"); |
whismanoid | 0:3edb3708c8c5 | 7073 | g_MAX5171_device.MODE0_DOUT_SCLK_FALLING_EDGE(); |
whismanoid | 0:3edb3708c8c5 | 7074 | } |
whismanoid | 0:3edb3708c8c5 | 7075 | break; |
whismanoid | 0:3edb3708c8c5 | 7076 | } |
whismanoid | 0:3edb3708c8c5 | 7077 | } |
whismanoid | 0:3edb3708c8c5 | 7078 | break; |
whismanoid | 0:3edb3708c8c5 | 7079 | case 'a': case 'A': |
whismanoid | 0:3edb3708c8c5 | 7080 | { |
whismanoid | 0:3edb3708c8c5 | 7081 | // recommended for hex command codes A0..AF |
whismanoid | 0:3edb3708c8c5 | 7082 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 7083 | { |
whismanoid | 0:3edb3708c8c5 | 7084 | case 't': case 'T': |
whismanoid | 0:3edb3708c8c5 | 7085 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7086 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7087 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7088 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7089 | // AT command: skip the prompt to avoid confusing modem detector |
whismanoid | 0:3edb3708c8c5 | 7090 | return; |
whismanoid | 0:3edb3708c8c5 | 7091 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7092 | } |
whismanoid | 0:3edb3708c8c5 | 7093 | } |
whismanoid | 0:3edb3708c8c5 | 7094 | break; |
whismanoid | 0:3edb3708c8c5 | 7095 | case 'x': case 'X': |
whismanoid | 0:3edb3708c8c5 | 7096 | { |
whismanoid | 0:3edb3708c8c5 | 7097 | } |
whismanoid | 0:3edb3708c8c5 | 7098 | break; |
whismanoid | 0:3edb3708c8c5 | 7099 | case 'y': case 'Y': |
whismanoid | 0:3edb3708c8c5 | 7100 | { |
whismanoid | 0:3edb3708c8c5 | 7101 | } |
whismanoid | 0:3edb3708c8c5 | 7102 | break; |
whismanoid | 0:3edb3708c8c5 | 7103 | case 'z': case 'Z': |
whismanoid | 0:3edb3708c8c5 | 7104 | { |
whismanoid | 0:3edb3708c8c5 | 7105 | } |
whismanoid | 0:3edb3708c8c5 | 7106 | break; |
whismanoid | 0:3edb3708c8c5 | 7107 | case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command |
whismanoid | 0:3edb3708c8c5 | 7108 | { |
whismanoid | 0:3edb3708c8c5 | 7109 | // TODO: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 7110 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7111 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7112 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7113 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7114 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7115 | } |
whismanoid | 0:3edb3708c8c5 | 7116 | break; |
whismanoid | 0:3edb3708c8c5 | 7117 | case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command |
whismanoid | 0:3edb3708c8c5 | 7118 | { |
whismanoid | 0:3edb3708c8c5 | 7119 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7120 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7121 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7122 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7123 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7124 | } |
whismanoid | 0:3edb3708c8c5 | 7125 | break; |
whismanoid | 0:3edb3708c8c5 | 7126 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 7127 | |
whismanoid | 0:3edb3708c8c5 | 7128 | |
whismanoid | 0:3edb3708c8c5 | 7129 | #if APPLICATION_MAX11410 // main_menu_onEOLcommandParser |
whismanoid | 0:3edb3708c8c5 | 7130 | // TODO1: MAX11410 main_menu_onEOLcommandParser |
whismanoid | 0:3edb3708c8c5 | 7131 | case '0': |
whismanoid | 0:3edb3708c8c5 | 7132 | { |
whismanoid | 0:3edb3708c8c5 | 7133 | // recommended for hex command codes 00..0F |
whismanoid | 0:3edb3708c8c5 | 7134 | // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); |
whismanoid | 0:3edb3708c8c5 | 7135 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 7136 | uint16_t code; |
whismanoid | 0:3edb3708c8c5 | 7137 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 7138 | { |
whismanoid | 0:3edb3708c8c5 | 7139 | } |
whismanoid | 0:3edb3708c8c5 | 7140 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 7141 | { |
whismanoid | 0:3edb3708c8c5 | 7142 | } |
whismanoid | 0:3edb3708c8c5 | 7143 | if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG)) |
whismanoid | 0:3edb3708c8c5 | 7144 | { |
whismanoid | 0:3edb3708c8c5 | 7145 | isUpdatedSPIConfig = true; |
whismanoid | 0:3edb3708c8c5 | 7146 | } |
whismanoid | 0:3edb3708c8c5 | 7147 | cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 7148 | MAX5715_CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 7149 | cmdLine.serial().printf("\r\n placeholder"); |
whismanoid | 0:3edb3708c8c5 | 7150 | } |
whismanoid | 0:3edb3708c8c5 | 7151 | break; |
whismanoid | 0:3edb3708c8c5 | 7152 | case '1': |
whismanoid | 0:3edb3708c8c5 | 7153 | { |
whismanoid | 0:3edb3708c8c5 | 7154 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 7155 | } |
whismanoid | 0:3edb3708c8c5 | 7156 | break; |
whismanoid | 0:3edb3708c8c5 | 7157 | case '2': |
whismanoid | 0:3edb3708c8c5 | 7158 | { |
whismanoid | 0:3edb3708c8c5 | 7159 | // recommended for hex command codes 20..2F |
whismanoid | 0:3edb3708c8c5 | 7160 | } |
whismanoid | 0:3edb3708c8c5 | 7161 | break; |
whismanoid | 0:3edb3708c8c5 | 7162 | case '3': |
whismanoid | 0:3edb3708c8c5 | 7163 | { |
whismanoid | 0:3edb3708c8c5 | 7164 | // recommended for hex command codes 30..3F |
whismanoid | 0:3edb3708c8c5 | 7165 | } |
whismanoid | 0:3edb3708c8c5 | 7166 | break; |
whismanoid | 0:3edb3708c8c5 | 7167 | case '4': |
whismanoid | 0:3edb3708c8c5 | 7168 | { |
whismanoid | 0:3edb3708c8c5 | 7169 | // recommended for hex command codes 40..4F |
whismanoid | 0:3edb3708c8c5 | 7170 | } |
whismanoid | 0:3edb3708c8c5 | 7171 | break; |
whismanoid | 0:3edb3708c8c5 | 7172 | case '5': |
whismanoid | 0:3edb3708c8c5 | 7173 | { |
whismanoid | 0:3edb3708c8c5 | 7174 | // recommended for hex command codes 50..5F |
whismanoid | 0:3edb3708c8c5 | 7175 | } |
whismanoid | 0:3edb3708c8c5 | 7176 | break; |
whismanoid | 0:3edb3708c8c5 | 7177 | case '6': |
whismanoid | 0:3edb3708c8c5 | 7178 | { |
whismanoid | 0:3edb3708c8c5 | 7179 | // recommended for hex command codes 60..6F |
whismanoid | 0:3edb3708c8c5 | 7180 | } |
whismanoid | 0:3edb3708c8c5 | 7181 | break; |
whismanoid | 0:3edb3708c8c5 | 7182 | case '7': |
whismanoid | 0:3edb3708c8c5 | 7183 | { |
whismanoid | 0:3edb3708c8c5 | 7184 | // recommended for hex command codes 70..7F |
whismanoid | 0:3edb3708c8c5 | 7185 | } |
whismanoid | 0:3edb3708c8c5 | 7186 | break; |
whismanoid | 0:3edb3708c8c5 | 7187 | case '8': |
whismanoid | 0:3edb3708c8c5 | 7188 | { |
whismanoid | 0:3edb3708c8c5 | 7189 | // recommended for hex command codes 80..8F |
whismanoid | 0:3edb3708c8c5 | 7190 | } |
whismanoid | 0:3edb3708c8c5 | 7191 | break; |
whismanoid | 0:3edb3708c8c5 | 7192 | case '9': |
whismanoid | 0:3edb3708c8c5 | 7193 | { |
whismanoid | 0:3edb3708c8c5 | 7194 | // recommended for hex command codes 90..9F |
whismanoid | 0:3edb3708c8c5 | 7195 | } |
whismanoid | 0:3edb3708c8c5 | 7196 | break; |
whismanoid | 0:3edb3708c8c5 | 7197 | case 'a': case 'A': |
whismanoid | 0:3edb3708c8c5 | 7198 | { |
whismanoid | 0:3edb3708c8c5 | 7199 | // recommended for hex command codes A0..AF |
whismanoid | 0:3edb3708c8c5 | 7200 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 7201 | { |
whismanoid | 0:3edb3708c8c5 | 7202 | case 't': case 'T': |
whismanoid | 0:3edb3708c8c5 | 7203 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7204 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7205 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7206 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7207 | // AT command: skip the prompt to avoid confusing modem detector |
whismanoid | 0:3edb3708c8c5 | 7208 | return; |
whismanoid | 0:3edb3708c8c5 | 7209 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7210 | } |
whismanoid | 0:3edb3708c8c5 | 7211 | } |
whismanoid | 0:3edb3708c8c5 | 7212 | break; |
whismanoid | 0:3edb3708c8c5 | 7213 | case 'b': case 'B': |
whismanoid | 0:3edb3708c8c5 | 7214 | { |
whismanoid | 0:3edb3708c8c5 | 7215 | // recommended for hex command codes B0..BF |
whismanoid | 0:3edb3708c8c5 | 7216 | } |
whismanoid | 0:3edb3708c8c5 | 7217 | break; |
whismanoid | 0:3edb3708c8c5 | 7218 | case 'c': case 'C': |
whismanoid | 0:3edb3708c8c5 | 7219 | { |
whismanoid | 0:3edb3708c8c5 | 7220 | // recommended for hex command codes C0..CF |
whismanoid | 0:3edb3708c8c5 | 7221 | } |
whismanoid | 0:3edb3708c8c5 | 7222 | break; |
whismanoid | 0:3edb3708c8c5 | 7223 | case 'd': case 'D': |
whismanoid | 0:3edb3708c8c5 | 7224 | { |
whismanoid | 0:3edb3708c8c5 | 7225 | // recommended for hex command codes D0..DF |
whismanoid | 0:3edb3708c8c5 | 7226 | } |
whismanoid | 0:3edb3708c8c5 | 7227 | break; |
whismanoid | 0:3edb3708c8c5 | 7228 | case 'e': case 'E': |
whismanoid | 0:3edb3708c8c5 | 7229 | { |
whismanoid | 0:3edb3708c8c5 | 7230 | // recommended for hex command codes E0..EF |
whismanoid | 0:3edb3708c8c5 | 7231 | } |
whismanoid | 0:3edb3708c8c5 | 7232 | break; |
whismanoid | 0:3edb3708c8c5 | 7233 | case 'f': case 'F': |
whismanoid | 0:3edb3708c8c5 | 7234 | { |
whismanoid | 0:3edb3708c8c5 | 7235 | // recommended for hex command codes F0..FF |
whismanoid | 0:3edb3708c8c5 | 7236 | } |
whismanoid | 0:3edb3708c8c5 | 7237 | break; |
whismanoid | 0:3edb3708c8c5 | 7238 | case 'x': case 'X': |
whismanoid | 0:3edb3708c8c5 | 7239 | { |
whismanoid | 0:3edb3708c8c5 | 7240 | } |
whismanoid | 0:3edb3708c8c5 | 7241 | break; |
whismanoid | 0:3edb3708c8c5 | 7242 | case 'y': case 'Y': |
whismanoid | 0:3edb3708c8c5 | 7243 | { |
whismanoid | 0:3edb3708c8c5 | 7244 | } |
whismanoid | 0:3edb3708c8c5 | 7245 | break; |
whismanoid | 0:3edb3708c8c5 | 7246 | case 'z': case 'Z': |
whismanoid | 0:3edb3708c8c5 | 7247 | { |
whismanoid | 0:3edb3708c8c5 | 7248 | } |
whismanoid | 0:3edb3708c8c5 | 7249 | break; |
whismanoid | 0:3edb3708c8c5 | 7250 | case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command |
whismanoid | 0:3edb3708c8c5 | 7251 | { |
whismanoid | 0:3edb3708c8c5 | 7252 | // TODO: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 7253 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7254 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7255 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7256 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7257 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7258 | } |
whismanoid | 0:3edb3708c8c5 | 7259 | break; |
whismanoid | 0:3edb3708c8c5 | 7260 | case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command |
whismanoid | 0:3edb3708c8c5 | 7261 | { |
whismanoid | 0:3edb3708c8c5 | 7262 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7263 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7264 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7265 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7266 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7267 | } |
whismanoid | 0:3edb3708c8c5 | 7268 | break; |
whismanoid | 0:3edb3708c8c5 | 7269 | #endif // APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 7270 | |
whismanoid | 0:3edb3708c8c5 | 7271 | |
whismanoid | 0:3edb3708c8c5 | 7272 | #if APPLICATION_MAX12345 // main_menu_onEOLcommandParser |
whismanoid | 0:3edb3708c8c5 | 7273 | case '0': |
whismanoid | 0:3edb3708c8c5 | 7274 | { |
whismanoid | 0:3edb3708c8c5 | 7275 | // recommended for hex command codes 00..0F |
whismanoid | 0:3edb3708c8c5 | 7276 | // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); |
whismanoid | 0:3edb3708c8c5 | 7277 | uint16_t ch = g_MAX5715_device.channelNumber_0_3; |
whismanoid | 0:3edb3708c8c5 | 7278 | uint16_t code; |
whismanoid | 0:3edb3708c8c5 | 7279 | if (cmdLine.parse_uint16_dec("ch", ch)) |
whismanoid | 0:3edb3708c8c5 | 7280 | { |
whismanoid | 0:3edb3708c8c5 | 7281 | } |
whismanoid | 0:3edb3708c8c5 | 7282 | if (cmdLine.parse_uint16_dec("code", code)) |
whismanoid | 0:3edb3708c8c5 | 7283 | { |
whismanoid | 0:3edb3708c8c5 | 7284 | } |
whismanoid | 0:3edb3708c8c5 | 7285 | if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG)) |
whismanoid | 0:3edb3708c8c5 | 7286 | { |
whismanoid | 0:3edb3708c8c5 | 7287 | isUpdatedSPIConfig = true; |
whismanoid | 0:3edb3708c8c5 | 7288 | } |
whismanoid | 0:3edb3708c8c5 | 7289 | cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); |
whismanoid | 0:3edb3708c8c5 | 7290 | MAX5715_CODEnLOADn(ch, code); |
whismanoid | 0:3edb3708c8c5 | 7291 | cmdLine.serial().printf("\r\n placeholder"); |
whismanoid | 0:3edb3708c8c5 | 7292 | } |
whismanoid | 0:3edb3708c8c5 | 7293 | break; |
whismanoid | 0:3edb3708c8c5 | 7294 | case '1': |
whismanoid | 0:3edb3708c8c5 | 7295 | { |
whismanoid | 0:3edb3708c8c5 | 7296 | // recommended for hex command codes 10..1F |
whismanoid | 0:3edb3708c8c5 | 7297 | } |
whismanoid | 0:3edb3708c8c5 | 7298 | break; |
whismanoid | 0:3edb3708c8c5 | 7299 | case '2': |
whismanoid | 0:3edb3708c8c5 | 7300 | { |
whismanoid | 0:3edb3708c8c5 | 7301 | // recommended for hex command codes 20..2F |
whismanoid | 0:3edb3708c8c5 | 7302 | } |
whismanoid | 0:3edb3708c8c5 | 7303 | break; |
whismanoid | 0:3edb3708c8c5 | 7304 | case '3': |
whismanoid | 0:3edb3708c8c5 | 7305 | { |
whismanoid | 0:3edb3708c8c5 | 7306 | // recommended for hex command codes 30..3F |
whismanoid | 0:3edb3708c8c5 | 7307 | } |
whismanoid | 0:3edb3708c8c5 | 7308 | break; |
whismanoid | 0:3edb3708c8c5 | 7309 | case '4': |
whismanoid | 0:3edb3708c8c5 | 7310 | { |
whismanoid | 0:3edb3708c8c5 | 7311 | // recommended for hex command codes 40..4F |
whismanoid | 0:3edb3708c8c5 | 7312 | } |
whismanoid | 0:3edb3708c8c5 | 7313 | break; |
whismanoid | 0:3edb3708c8c5 | 7314 | case '5': |
whismanoid | 0:3edb3708c8c5 | 7315 | { |
whismanoid | 0:3edb3708c8c5 | 7316 | // recommended for hex command codes 50..5F |
whismanoid | 0:3edb3708c8c5 | 7317 | } |
whismanoid | 0:3edb3708c8c5 | 7318 | break; |
whismanoid | 0:3edb3708c8c5 | 7319 | case '6': |
whismanoid | 0:3edb3708c8c5 | 7320 | { |
whismanoid | 0:3edb3708c8c5 | 7321 | // recommended for hex command codes 60..6F |
whismanoid | 0:3edb3708c8c5 | 7322 | } |
whismanoid | 0:3edb3708c8c5 | 7323 | break; |
whismanoid | 0:3edb3708c8c5 | 7324 | case '7': |
whismanoid | 0:3edb3708c8c5 | 7325 | { |
whismanoid | 0:3edb3708c8c5 | 7326 | // recommended for hex command codes 70..7F |
whismanoid | 0:3edb3708c8c5 | 7327 | } |
whismanoid | 0:3edb3708c8c5 | 7328 | break; |
whismanoid | 0:3edb3708c8c5 | 7329 | case '8': |
whismanoid | 0:3edb3708c8c5 | 7330 | { |
whismanoid | 0:3edb3708c8c5 | 7331 | // recommended for hex command codes 80..8F |
whismanoid | 0:3edb3708c8c5 | 7332 | } |
whismanoid | 0:3edb3708c8c5 | 7333 | break; |
whismanoid | 0:3edb3708c8c5 | 7334 | case '9': |
whismanoid | 0:3edb3708c8c5 | 7335 | { |
whismanoid | 0:3edb3708c8c5 | 7336 | // recommended for hex command codes 90..9F |
whismanoid | 0:3edb3708c8c5 | 7337 | } |
whismanoid | 0:3edb3708c8c5 | 7338 | break; |
whismanoid | 0:3edb3708c8c5 | 7339 | case 'a': case 'A': |
whismanoid | 0:3edb3708c8c5 | 7340 | { |
whismanoid | 0:3edb3708c8c5 | 7341 | // recommended for hex command codes A0..AF |
whismanoid | 0:3edb3708c8c5 | 7342 | switch (cmdLine[1]) |
whismanoid | 0:3edb3708c8c5 | 7343 | { |
whismanoid | 0:3edb3708c8c5 | 7344 | case 't': case 'T': |
whismanoid | 0:3edb3708c8c5 | 7345 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7346 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7347 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7348 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7349 | // AT command: skip the prompt to avoid confusing modem detector |
whismanoid | 0:3edb3708c8c5 | 7350 | return; |
whismanoid | 0:3edb3708c8c5 | 7351 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7352 | } |
whismanoid | 0:3edb3708c8c5 | 7353 | } |
whismanoid | 0:3edb3708c8c5 | 7354 | break; |
whismanoid | 0:3edb3708c8c5 | 7355 | case 'b': case 'B': |
whismanoid | 0:3edb3708c8c5 | 7356 | { |
whismanoid | 0:3edb3708c8c5 | 7357 | // recommended for hex command codes B0..BF |
whismanoid | 0:3edb3708c8c5 | 7358 | } |
whismanoid | 0:3edb3708c8c5 | 7359 | break; |
whismanoid | 0:3edb3708c8c5 | 7360 | case 'c': case 'C': |
whismanoid | 0:3edb3708c8c5 | 7361 | { |
whismanoid | 0:3edb3708c8c5 | 7362 | // recommended for hex command codes C0..CF |
whismanoid | 0:3edb3708c8c5 | 7363 | } |
whismanoid | 0:3edb3708c8c5 | 7364 | break; |
whismanoid | 0:3edb3708c8c5 | 7365 | case 'd': case 'D': |
whismanoid | 0:3edb3708c8c5 | 7366 | { |
whismanoid | 0:3edb3708c8c5 | 7367 | // recommended for hex command codes D0..DF |
whismanoid | 0:3edb3708c8c5 | 7368 | } |
whismanoid | 0:3edb3708c8c5 | 7369 | break; |
whismanoid | 0:3edb3708c8c5 | 7370 | case 'e': case 'E': |
whismanoid | 0:3edb3708c8c5 | 7371 | { |
whismanoid | 0:3edb3708c8c5 | 7372 | // recommended for hex command codes E0..EF |
whismanoid | 0:3edb3708c8c5 | 7373 | } |
whismanoid | 0:3edb3708c8c5 | 7374 | break; |
whismanoid | 0:3edb3708c8c5 | 7375 | case 'f': case 'F': |
whismanoid | 0:3edb3708c8c5 | 7376 | { |
whismanoid | 0:3edb3708c8c5 | 7377 | // recommended for hex command codes F0..FF |
whismanoid | 0:3edb3708c8c5 | 7378 | } |
whismanoid | 0:3edb3708c8c5 | 7379 | break; |
whismanoid | 0:3edb3708c8c5 | 7380 | case 'x': case 'X': |
whismanoid | 0:3edb3708c8c5 | 7381 | { |
whismanoid | 0:3edb3708c8c5 | 7382 | } |
whismanoid | 0:3edb3708c8c5 | 7383 | break; |
whismanoid | 0:3edb3708c8c5 | 7384 | case 'y': case 'Y': |
whismanoid | 0:3edb3708c8c5 | 7385 | { |
whismanoid | 0:3edb3708c8c5 | 7386 | } |
whismanoid | 0:3edb3708c8c5 | 7387 | break; |
whismanoid | 0:3edb3708c8c5 | 7388 | case 'z': case 'Z': |
whismanoid | 0:3edb3708c8c5 | 7389 | { |
whismanoid | 0:3edb3708c8c5 | 7390 | } |
whismanoid | 0:3edb3708c8c5 | 7391 | break; |
whismanoid | 0:3edb3708c8c5 | 7392 | case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command |
whismanoid | 0:3edb3708c8c5 | 7393 | { |
whismanoid | 0:3edb3708c8c5 | 7394 | // TODO: '~' is not recommended for menu commands, interferes with ssh |
whismanoid | 0:3edb3708c8c5 | 7395 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7396 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7397 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7398 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7399 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7400 | } |
whismanoid | 0:3edb3708c8c5 | 7401 | break; |
whismanoid | 0:3edb3708c8c5 | 7402 | case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command |
whismanoid | 0:3edb3708c8c5 | 7403 | { |
whismanoid | 0:3edb3708c8c5 | 7404 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7405 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7406 | cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7407 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7408 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7409 | } |
whismanoid | 0:3edb3708c8c5 | 7410 | break; |
whismanoid | 0:3edb3708c8c5 | 7411 | #endif // APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 7412 | |
whismanoid | 0:3edb3708c8c5 | 7413 | //#if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7414 | // // tolerate AT commands, which may be sent during probe |
whismanoid | 0:3edb3708c8c5 | 7415 | // // "AT\r" |
whismanoid | 0:3edb3708c8c5 | 7416 | // // "AT+CGMI\r" -- request manufacturer identification AT+CMGI=? |
whismanoid | 0:3edb3708c8c5 | 7417 | // // "AT+CGMM\r" -- request manufacturer model |
whismanoid | 0:3edb3708c8c5 | 7418 | // // "AT%IPSYS?\r" |
whismanoid | 0:3edb3708c8c5 | 7419 | // // "ATE0\r" -- echo disable |
whismanoid | 0:3edb3708c8c5 | 7420 | // // "ATV1\r" -- verbose result codes OK | ERROR | NO CARRIER |
whismanoid | 0:3edb3708c8c5 | 7421 | // // menu_main() ignore_until_line_end: AT |
whismanoid | 0:3edb3708c8c5 | 7422 | // // menu_main() ignore_until_line_end: AT+CGMI |
whismanoid | 0:3edb3708c8c5 | 7423 | // // menu_main() ignore_until_line_end: AT+CGMM |
whismanoid | 0:3edb3708c8c5 | 7424 | // // menu_main() ignore_until_line_end: AT%IPSYS? |
whismanoid | 0:3edb3708c8c5 | 7425 | // // menu_main() ignore_until_line_end: ATE0 |
whismanoid | 0:3edb3708c8c5 | 7426 | // // menu_main() ignore_until_line_end: ATV1 |
whismanoid | 0:3edb3708c8c5 | 7427 | // // menu_main() ignore_until_line_end: AT+CMEE=1 |
whismanoid | 0:3edb3708c8c5 | 7428 | // // menu_main() ignore_until_line_end: ATX4 |
whismanoid | 0:3edb3708c8c5 | 7429 | // // menu_main() ignore_until_line_end: AT&C1 |
whismanoid | 0:3edb3708c8c5 | 7430 | // // menu_main() ignore_until_line_end: ATE0 |
whismanoid | 0:3edb3708c8c5 | 7431 | // // menu_main() ignore_until_line_end: AT+CMEE=1 |
whismanoid | 0:3edb3708c8c5 | 7432 | // // menu_main() ignore_until_line_end: AT+GCAP |
whismanoid | 0:3edb3708c8c5 | 7433 | // // menu_main() ignore_until_line_end: ATI |
whismanoid | 0:3edb3708c8c5 | 7434 | // // menu_main() ignore_until_line_end: AT+CPIN? |
whismanoid | 0:3edb3708c8c5 | 7435 | // // menu_main() ignore_until_line_end: AT+CGMM |
whismanoid | 0:3edb3708c8c5 | 7436 | // case 'A': |
whismanoid | 0:3edb3708c8c5 | 7437 | // // likely unwanted AT command, host probing for a modem. |
whismanoid | 0:3edb3708c8c5 | 7438 | // // ignore everything up to next line end '\r' or '\n'. |
whismanoid | 0:3edb3708c8c5 | 7439 | // //~ ignore_until_line_end = true; |
whismanoid | 0:3edb3708c8c5 | 7440 | //# if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7441 | // cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7442 | //# endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7443 | // //~ goto label_menu_main_idle; |
whismanoid | 0:3edb3708c8c5 | 7444 | // break; |
whismanoid | 0:3edb3708c8c5 | 7445 | //#endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7446 | // |
whismanoid | 0:3edb3708c8c5 | 7447 | // |
whismanoid | 0:3edb3708c8c5 | 7448 | // TODO1: add new commands here |
whismanoid | 0:3edb3708c8c5 | 7449 | // |
whismanoid | 0:3edb3708c8c5 | 7450 | default: |
whismanoid | 0:3edb3708c8c5 | 7451 | cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7452 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7453 | cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", |
whismanoid | 0:3edb3708c8c5 | 7454 | cmdLine.str()[0], cmdLine.str()); |
whismanoid | 0:3edb3708c8c5 | 7455 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7456 | } // switch (cmdLine[0]) |
whismanoid | 0:3edb3708c8c5 | 7457 | // |
whismanoid | 0:3edb3708c8c5 | 7458 | // print command prompt |
whismanoid | 0:3edb3708c8c5 | 7459 | #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 0:3edb3708c8c5 | 7460 | cmdLine.serial().printf("\r\nMAX5715 > "); |
whismanoid | 0:3edb3708c8c5 | 7461 | #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 0:3edb3708c8c5 | 7462 | cmdLine.serial().printf("\r\nMAX11131 > "); |
whismanoid | 0:3edb3708c8c5 | 7463 | #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 0:3edb3708c8c5 | 7464 | cmdLine.serial().printf("\r\nMAX5171 > "); |
whismanoid | 0:3edb3708c8c5 | 7465 | #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 0:3edb3708c8c5 | 7466 | cmdLine.serial().printf("\r\nMAX11410 > "); |
whismanoid | 0:3edb3708c8c5 | 7467 | #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt |
whismanoid | 0:3edb3708c8c5 | 7468 | cmdLine.serial().printf("\r\nMAX12345 > "); |
whismanoid | 0:3edb3708c8c5 | 7469 | #else |
whismanoid | 0:3edb3708c8c5 | 7470 | cmdLine.serial().printf("\r\n> "); |
whismanoid | 0:3edb3708c8c5 | 7471 | #endif |
whismanoid | 0:3edb3708c8c5 | 7472 | } |
whismanoid | 0:3edb3708c8c5 | 7473 | #endif //USE_COMMAND_BUFFER |
whismanoid | 0:3edb3708c8c5 | 7474 | |
whismanoid | 0:3edb3708c8c5 | 7475 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7476 | void InitializeConfiguration() |
whismanoid | 0:3edb3708c8c5 | 7477 | { |
whismanoid | 0:3edb3708c8c5 | 7478 | |
whismanoid | 0:3edb3708c8c5 | 7479 | #if APPLICATION_MAX5715 // InitializeConfiguration |
whismanoid | 0:3edb3708c8c5 | 7480 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7481 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX5715_Init()"); |
whismanoid | 0:3edb3708c8c5 | 7482 | # endif |
whismanoid | 0:3edb3708c8c5 | 7483 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7484 | cmdLine_microUSBserial.serial().printf("\r\nMAX5715_Init()"); |
whismanoid | 0:3edb3708c8c5 | 7485 | # endif |
whismanoid | 0:3edb3708c8c5 | 7486 | int initResult = g_MAX5715_device.Init(); // defined in #include MAX5715.h |
whismanoid | 0:3edb3708c8c5 | 7487 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7488 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX5715_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 7489 | # endif |
whismanoid | 0:3edb3708c8c5 | 7490 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7491 | cmdLine_microUSBserial.serial().printf("\r\nMAX5715_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 7492 | # endif |
whismanoid | 0:3edb3708c8c5 | 7493 | #endif // APPLICATION_MAX5715 |
whismanoid | 0:3edb3708c8c5 | 7494 | |
whismanoid | 0:3edb3708c8c5 | 7495 | #if APPLICATION_MAX11131 // InitializeConfiguration |
whismanoid | 0:3edb3708c8c5 | 7496 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7497 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX11131_Init()"); |
whismanoid | 0:3edb3708c8c5 | 7498 | # endif |
whismanoid | 0:3edb3708c8c5 | 7499 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7500 | cmdLine_microUSBserial.serial().printf("\r\nMAX11131_Init()"); |
whismanoid | 0:3edb3708c8c5 | 7501 | # endif |
whismanoid | 0:3edb3708c8c5 | 7502 | g_MAX11131_device.Init(); // defined in #include MAX11131.h |
whismanoid | 0:3edb3708c8c5 | 7503 | #endif // APPLICATION_MAX11131 |
whismanoid | 0:3edb3708c8c5 | 7504 | |
whismanoid | 0:3edb3708c8c5 | 7505 | #if APPLICATION_MAX5171 // InitializeConfiguration |
whismanoid | 0:3edb3708c8c5 | 7506 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7507 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX5171_Init()"); |
whismanoid | 0:3edb3708c8c5 | 7508 | # endif |
whismanoid | 0:3edb3708c8c5 | 7509 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7510 | cmdLine_microUSBserial.serial().printf("\r\nMAX5171_Init()"); |
whismanoid | 0:3edb3708c8c5 | 7511 | # endif |
whismanoid | 0:3edb3708c8c5 | 7512 | int initResult = g_MAX5171_device.Init(); // defined in #include MAX5171.h |
whismanoid | 0:3edb3708c8c5 | 7513 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7514 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX5171_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 7515 | # endif |
whismanoid | 0:3edb3708c8c5 | 7516 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7517 | cmdLine_microUSBserial.serial().printf("\r\nMAX5171_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 7518 | # endif |
whismanoid | 0:3edb3708c8c5 | 7519 | #endif // APPLICATION_MAX5171 |
whismanoid | 0:3edb3708c8c5 | 7520 | |
whismanoid | 0:3edb3708c8c5 | 7521 | #if APPLICATION_MAX11410 // InitializeConfiguration |
whismanoid | 0:3edb3708c8c5 | 7522 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7523 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX11410_Init()"); |
whismanoid | 0:3edb3708c8c5 | 7524 | # endif |
whismanoid | 0:3edb3708c8c5 | 7525 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7526 | cmdLine_microUSBserial.serial().printf("\r\nMAX11410_Init()"); |
whismanoid | 0:3edb3708c8c5 | 7527 | # endif |
whismanoid | 0:3edb3708c8c5 | 7528 | int initResult = g_MAX11410_device.Init(); // defined in #include MAX11410.h |
whismanoid | 0:3edb3708c8c5 | 7529 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7530 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX11410_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 7531 | # endif |
whismanoid | 0:3edb3708c8c5 | 7532 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7533 | cmdLine_microUSBserial.serial().printf("\r\nMAX11410_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 7534 | # endif |
whismanoid | 0:3edb3708c8c5 | 7535 | #endif // APPLICATION_MAX11410 |
whismanoid | 0:3edb3708c8c5 | 7536 | |
whismanoid | 0:3edb3708c8c5 | 7537 | #if APPLICATION_MAX12345 // InitializeConfiguration |
whismanoid | 0:3edb3708c8c5 | 7538 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7539 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX12345_Init()"); |
whismanoid | 0:3edb3708c8c5 | 7540 | # endif |
whismanoid | 0:3edb3708c8c5 | 7541 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7542 | cmdLine_microUSBserial.serial().printf("\r\nMAX12345_Init()"); |
whismanoid | 0:3edb3708c8c5 | 7543 | # endif |
whismanoid | 0:3edb3708c8c5 | 7544 | int initResult = MAX12345_Init(); // defined in #include MAX12345.h |
whismanoid | 0:3edb3708c8c5 | 7545 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7546 | cmdLine_DAPLINKserial.serial().printf("\r\nMAX12345_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 7547 | # endif |
whismanoid | 0:3edb3708c8c5 | 7548 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7549 | cmdLine_microUSBserial.serial().printf("\r\nMAX12345_Init() returned %d\r\n", initResult); |
whismanoid | 0:3edb3708c8c5 | 7550 | # endif |
whismanoid | 0:3edb3708c8c5 | 7551 | #endif // APPLICATION_MAX12345 |
whismanoid | 0:3edb3708c8c5 | 7552 | |
whismanoid | 0:3edb3708c8c5 | 7553 | } |
whismanoid | 0:3edb3708c8c5 | 7554 | |
whismanoid | 0:3edb3708c8c5 | 7555 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7556 | // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 7557 | void diagnostic_led_EOF() |
whismanoid | 0:3edb3708c8c5 | 7558 | { |
whismanoid | 0:3edb3708c8c5 | 7559 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 7560 | led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 7561 | // 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 | 7562 | ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 7563 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 7564 | ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 7565 | led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 7566 | ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 7567 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 7568 | ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); |
whismanoid | 0:3edb3708c8c5 | 7569 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 7570 | } |
whismanoid | 0:3edb3708c8c5 | 7571 | |
whismanoid | 0:3edb3708c8c5 | 7572 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7573 | // Support commands that get handled immediately w/o waiting for EOL |
whismanoid | 0:3edb3708c8c5 | 7574 | // handled as immediate command, do not append to buffer |
whismanoid | 0:3edb3708c8c5 | 7575 | void on_immediate_0x21() // Unicode (U+0021) ! EXCLAMATION MARK |
whismanoid | 0:3edb3708c8c5 | 7576 | { |
whismanoid | 0:3edb3708c8c5 | 7577 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 7578 | led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 7579 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 7580 | InitializeConfiguration(); |
whismanoid | 0:3edb3708c8c5 | 7581 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7582 | } |
whismanoid | 0:3edb3708c8c5 | 7583 | |
whismanoid | 0:3edb3708c8c5 | 7584 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7585 | // Support commands that get handled immediately w/o waiting for EOL |
whismanoid | 0:3edb3708c8c5 | 7586 | // handled as immediate command, do not append to buffer |
whismanoid | 0:3edb3708c8c5 | 7587 | void on_immediate_0x7b() // Unicode (U+007B) { LEFT CURLY BRACKET |
whismanoid | 0:3edb3708c8c5 | 7588 | { |
whismanoid | 0:3edb3708c8c5 | 7589 | //~ led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 7590 | //~ InitializeConfiguration(); |
whismanoid | 0:3edb3708c8c5 | 7591 | //~ ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7592 | #if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 7593 | onButton2FallingEdge(); |
whismanoid | 0:3edb3708c8c5 | 7594 | #endif |
whismanoid | 0:3edb3708c8c5 | 7595 | } |
whismanoid | 0:3edb3708c8c5 | 7596 | |
whismanoid | 0:3edb3708c8c5 | 7597 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7598 | // Support commands that get handled immediately w/o waiting for EOL |
whismanoid | 0:3edb3708c8c5 | 7599 | // handled as immediate command, do not append to buffer |
whismanoid | 0:3edb3708c8c5 | 7600 | void on_immediate_0x7d() // Unicode (U+007D) } RIGHT CURLY BRACKET |
whismanoid | 0:3edb3708c8c5 | 7601 | { |
whismanoid | 0:3edb3708c8c5 | 7602 | //~ led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 7603 | //~ InitializeConfiguration(); |
whismanoid | 0:3edb3708c8c5 | 7604 | //~ ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7605 | #if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 7606 | onButton1FallingEdge(); |
whismanoid | 0:3edb3708c8c5 | 7607 | #endif |
whismanoid | 0:3edb3708c8c5 | 7608 | } |
whismanoid | 0:3edb3708c8c5 | 7609 | |
whismanoid | 0:3edb3708c8c5 | 7610 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7611 | // based on example code: https://os.mbed.com/docs/v5.7/reference/pwmout.html |
whismanoid | 0:3edb3708c8c5 | 7612 | int main() |
whismanoid | 0:3edb3708c8c5 | 7613 | { |
whismanoid | 0:3edb3708c8c5 | 7614 | //#ifdef SCOPE_TRIG_PIN |
whismanoid | 0:3edb3708c8c5 | 7615 | // //pinMode(SCOPE_TRIG_PIN, OUTPUT); |
whismanoid | 0:3edb3708c8c5 | 7616 | // scopeTrigPinP11 = 0; // digitalWrite(SCOPE_TRIG_PIN, LOW); |
whismanoid | 0:3edb3708c8c5 | 7617 | // scopeTrigPinP11 = 1; // digitalWrite(SCOPE_TRIG_PIN, HIGH); |
whismanoid | 0:3edb3708c8c5 | 7618 | //#endif // SCOPE_TRIG_PIN |
whismanoid | 0:3edb3708c8c5 | 7619 | |
whismanoid | 0:3edb3708c8c5 | 7620 | // Configure serial ports |
whismanoid | 0:3edb3708c8c5 | 7621 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 7622 | // Note: DAPLINKserial interferes with the timer tick interrupt. Try faster baud rate? |
whismanoid | 0:3edb3708c8c5 | 7623 | DAPLINKserial.baud(115200); // default 9600 baud |
whismanoid | 0:3edb3708c8c5 | 7624 | //microUSBserial.baud(9600); // class USBSerial has no baud function |
whismanoid | 0:3edb3708c8c5 | 7625 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7626 | DAPLINKserial.printf("\r\n\r\nDAPLINK_SERIAL: main() startup\r\n"); |
whismanoid | 0:3edb3708c8c5 | 7627 | # endif |
whismanoid | 0:3edb3708c8c5 | 7628 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7629 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 7630 | // MAX32625MBED crash if DAPLINKserial.baud(anything other than 9600 baud) |
whismanoid | 0:3edb3708c8c5 | 7631 | // xxx DAPLINKserial.baud(115200); // default 9600 baud |
whismanoid | 0:3edb3708c8c5 | 7632 | //microUSBserial.baud(9600); // class USBSerial has no baud function |
whismanoid | 0:3edb3708c8c5 | 7633 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7634 | DAPLINKserial.printf("\r\n\r\nDAPLINK_SERIAL: main() startup\r\n"); |
whismanoid | 0:3edb3708c8c5 | 7635 | # endif |
whismanoid | 0:3edb3708c8c5 | 7636 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7637 | #elif defined(TARGET_LPC1768) |
whismanoid | 0:3edb3708c8c5 | 7638 | microUSBserial.baud(115200); // default 9600 baud |
whismanoid | 0:3edb3708c8c5 | 7639 | #else |
whismanoid | 0:3edb3708c8c5 | 7640 | // unknown target |
whismanoid | 0:3edb3708c8c5 | 7641 | #endif |
whismanoid | 0:3edb3708c8c5 | 7642 | #if USE_COMMAND_BUFFER |
whismanoid | 0:3edb3708c8c5 | 7643 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7644 | cmdLine_microUSBserial.clear(); |
whismanoid | 0:3edb3708c8c5 | 7645 | //~ cmdLine_microUSBserial.serial().printf("\r\n cmdLine_microUSBserial.serial().printf test\r\n"); |
whismanoid | 0:3edb3708c8c5 | 7646 | cmdLine_microUSBserial.onEOLcommandParser = main_menu_onEOLcommandParser; |
whismanoid | 0:3edb3708c8c5 | 7647 | /// @todo CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21); |
whismanoid | 0:3edb3708c8c5 | 7648 | cmdLine_microUSBserial.on_immediate_0x21 = on_immediate_0x21; |
whismanoid | 0:3edb3708c8c5 | 7649 | cmdLine_microUSBserial.on_immediate_0x7b = on_immediate_0x7b; |
whismanoid | 0:3edb3708c8c5 | 7650 | cmdLine_microUSBserial.on_immediate_0x7d = on_immediate_0x7d; |
whismanoid | 0:3edb3708c8c5 | 7651 | # endif |
whismanoid | 0:3edb3708c8c5 | 7652 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7653 | cmdLine_DAPLINKserial.clear(); |
whismanoid | 0:3edb3708c8c5 | 7654 | //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n"); |
whismanoid | 0:3edb3708c8c5 | 7655 | cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser; |
whismanoid | 0:3edb3708c8c5 | 7656 | /// @todo CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21); |
whismanoid | 0:3edb3708c8c5 | 7657 | cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21; |
whismanoid | 0:3edb3708c8c5 | 7658 | cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b; |
whismanoid | 0:3edb3708c8c5 | 7659 | cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d; |
whismanoid | 0:3edb3708c8c5 | 7660 | # endif |
whismanoid | 0:3edb3708c8c5 | 7661 | #endif |
whismanoid | 0:3edb3708c8c5 | 7662 | |
whismanoid | 0:3edb3708c8c5 | 7663 | |
whismanoid | 0:3edb3708c8c5 | 7664 | print_banner(); |
whismanoid | 0:3edb3708c8c5 | 7665 | |
whismanoid | 0:3edb3708c8c5 | 7666 | //#ifdef SCOPE_TRIG_PIN |
whismanoid | 0:3edb3708c8c5 | 7667 | // scopePinP12 = 0; |
whismanoid | 0:3edb3708c8c5 | 7668 | // scopePinP12 = 1; |
whismanoid | 0:3edb3708c8c5 | 7669 | //#endif // SCOPE_TRIG_PIN |
whismanoid | 0:3edb3708c8c5 | 7670 | |
whismanoid | 0:3edb3708c8c5 | 7671 | #if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 7672 | # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 7673 | # else |
whismanoid | 0:3edb3708c8c5 | 7674 | button1.fall(&onButton1FallingEdge); |
whismanoid | 0:3edb3708c8c5 | 7675 | # endif |
whismanoid | 0:3edb3708c8c5 | 7676 | #endif // HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 7677 | #if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 7678 | # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 7679 | # else |
whismanoid | 0:3edb3708c8c5 | 7680 | button2.fall(&onButton2FallingEdge); |
whismanoid | 0:3edb3708c8c5 | 7681 | # endif |
whismanoid | 0:3edb3708c8c5 | 7682 | #endif // HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 7683 | |
whismanoid | 0:3edb3708c8c5 | 7684 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 7685 | // TODO1: timer tick needs to be the highest priority (priority 0, the default). |
whismanoid | 0:3edb3708c8c5 | 7686 | // TODO1: DAPLINKserial interferes with the timer tick interrupt. |
whismanoid | 0:3edb3708c8c5 | 7687 | // Lower the priority of the serial port interrupts to avoid disrupting motor operation. |
whismanoid | 0:3edb3708c8c5 | 7688 | NVIC_SetPriority(UART0_IRQn, 2); // reservedBlueToothSerial(P0_1, P0_0) // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7689 | NVIC_SetPriority(UART1_IRQn, 2); // DAPLINKserial(P2_1, P2_0) // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7690 | NVIC_SetPriority(UART2_IRQn, 2); // reservedSerial(P3_1, P3_0) // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7691 | NVIC_SetPriority(UART3_IRQn, 2); // reservedSerial(P5_4, P5_3) // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7692 | NVIC_SetPriority(GPIO_P0_IRQn, 2); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7693 | NVIC_SetPriority(GPIO_P1_IRQn, 2); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7694 | NVIC_SetPriority(GPIO_P2_IRQn, 2); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7695 | NVIC_SetPriority(GPIO_P3_IRQn, 2); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7696 | NVIC_SetPriority(GPIO_P4_IRQn, 2); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7697 | NVIC_SetPriority(GPIO_P5_IRQn, 2); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7698 | NVIC_SetPriority(GPIO_P6_IRQn, 2); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7699 | NVIC_SetPriority(GPIO_P7_IRQn, 2); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7700 | NVIC_SetPriority(GPIO_P8_IRQn, 2); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7701 | //~ NVIC_SetPriority(RTC0_IRQn, 0); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7702 | //~ NVIC_SetPriority(RTC3_IRQn, 0); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7703 | //~ NVIC_SetPriority(US_TIMER_IRQn, 0); // 0=highest priority; 1=lower |
whismanoid | 0:3edb3708c8c5 | 7704 | #endif |
whismanoid | 0:3edb3708c8c5 | 7705 | |
whismanoid | 0:3edb3708c8c5 | 7706 | #if HAS_SPI |
whismanoid | 0:3edb3708c8c5 | 7707 | // spi init |
whismanoid | 0:3edb3708c8c5 | 7708 | // mode | POL PHA |
whismanoid | 0:3edb3708c8c5 | 7709 | // -----+-------- |
whismanoid | 0:3edb3708c8c5 | 7710 | // 0 | 0 0 |
whismanoid | 0:3edb3708c8c5 | 7711 | // 1 | 0 1 |
whismanoid | 0:3edb3708c8c5 | 7712 | // 2 | 1 0 |
whismanoid | 0:3edb3708c8c5 | 7713 | // 3 | 1 1 |
whismanoid | 0:3edb3708c8c5 | 7714 | //~ spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 7715 | //~ spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 7716 | //~ spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 7717 | //~ spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default) |
whismanoid | 0:3edb3708c8c5 | 7718 | // |
whismanoid | 0:3edb3708c8c5 | 7719 | //~ spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default) |
whismanoid | 0:3edb3708c8c5 | 7720 | //~ spi.frequency(9600000); // int SCLK_Hz=9600000 = 9.6MHz = 96MHz/10 |
whismanoid | 0:3edb3708c8c5 | 7721 | //~ spi.frequency(10666666); // int SCLK_Hz=10666666 = 10.6MHz = 96MHz/9 |
whismanoid | 0:3edb3708c8c5 | 7722 | //~ spi.frequency(12000000); // int SCLK_Hz=12000000 = 12MHz = 96MHz/8 |
whismanoid | 0:3edb3708c8c5 | 7723 | //~ spi.frequency(13714286); // int SCLK_Hz=13714286 = 13.7MHz = 96MHz/7 |
whismanoid | 0:3edb3708c8c5 | 7724 | //~ spi.frequency(16000000); // int SCLK_Hz=16000000 = 16MHz = 96MHz/6 |
whismanoid | 0:3edb3708c8c5 | 7725 | //~ spi.frequency(19200000); // int SCLK_Hz=19200000 = 19.2MHz = 96MHz/5 |
whismanoid | 0:3edb3708c8c5 | 7726 | //~ spi.frequency(24000000); // int SCLK_Hz=24000000 = 24MHz = 96MHz/4 |
whismanoid | 0:3edb3708c8c5 | 7727 | //~ spi.frequency(32000000); // int SCLK_Hz=32000000 = 32MHz = 96MHz/3 |
whismanoid | 0:3edb3708c8c5 | 7728 | //~ spi.frequency(48000000); // int SCLK_Hz=48000000 = 48MHz = 96MHz/2 |
whismanoid | 0:3edb3708c8c5 | 7729 | // unspecified SPI device |
whismanoid | 0:3edb3708c8c5 | 7730 | 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 | 7731 | spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default) |
whismanoid | 0:3edb3708c8c5 | 7732 | spi_cs = 1; |
whismanoid | 0:3edb3708c8c5 | 7733 | #endif |
whismanoid | 0:3edb3708c8c5 | 7734 | |
whismanoid | 0:3edb3708c8c5 | 7735 | #if HAS_I2C |
whismanoid | 0:3edb3708c8c5 | 7736 | // i2c init |
whismanoid | 0:3edb3708c8c5 | 7737 | // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) |
whismanoid | 0:3edb3708c8c5 | 7738 | // i2cMaster.frequency(g_I2C_SCL_Hz); |
whismanoid | 0:3edb3708c8c5 | 7739 | #else |
whismanoid | 0:3edb3708c8c5 | 7740 | // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 |
whismanoid | 0:3edb3708c8c5 | 7741 | #if HAS_digitalInOut14 |
whismanoid | 0:3edb3708c8c5 | 7742 | // DigitalInOut digitalInOut14(P1_6, PIN_INPUT, PullUp, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 7743 | digitalInOut14.input(); |
whismanoid | 0:3edb3708c8c5 | 7744 | #endif |
whismanoid | 0:3edb3708c8c5 | 7745 | #if HAS_digitalInOut15 |
whismanoid | 0:3edb3708c8c5 | 7746 | // DigitalInOut digitalInOut15(P1_7, PIN_INPUT, PullUp, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) |
whismanoid | 0:3edb3708c8c5 | 7747 | digitalInOut15.input(); |
whismanoid | 0:3edb3708c8c5 | 7748 | #endif |
whismanoid | 0:3edb3708c8c5 | 7749 | #if HAS_digitalInOut16 |
whismanoid | 0:3edb3708c8c5 | 7750 | // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain |
whismanoid | 0:3edb3708c8c5 | 7751 | // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V |
whismanoid | 0:3edb3708c8c5 | 7752 | //DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 7753 | digitalInOut16.input(); |
whismanoid | 0:3edb3708c8c5 | 7754 | #endif |
whismanoid | 0:3edb3708c8c5 | 7755 | #if HAS_digitalInOut17 |
whismanoid | 0:3edb3708c8c5 | 7756 | //DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) |
whismanoid | 0:3edb3708c8c5 | 7757 | digitalInOut17.input(); |
whismanoid | 0:3edb3708c8c5 | 7758 | #endif |
whismanoid | 0:3edb3708c8c5 | 7759 | #endif |
whismanoid | 0:3edb3708c8c5 | 7760 | |
whismanoid | 0:3edb3708c8c5 | 7761 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 7762 | #if defined(TARGET_MAX32630) |
whismanoid | 0:3edb3708c8c5 | 7763 | led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 7764 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7765 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 7766 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7767 | led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 7768 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7769 | led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 7770 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7771 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 7772 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7773 | led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 7774 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7775 | led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 7776 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7777 | led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 7778 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7779 | #elif defined(TARGET_MAX32625MBED) |
whismanoid | 0:3edb3708c8c5 | 7780 | led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 7781 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7782 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 7783 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7784 | led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 7785 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7786 | led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 7787 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7788 | led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 7789 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7790 | led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 7791 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7792 | led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 7793 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7794 | led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 7795 | ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); |
whismanoid | 0:3edb3708c8c5 | 7796 | #else // not defined(TARGET_LPC1768 etc.) |
whismanoid | 0:3edb3708c8c5 | 7797 | led1 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 7798 | led2 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 7799 | led3 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 7800 | led4 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 7801 | ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); |
whismanoid | 0:3edb3708c8c5 | 7802 | //led1 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 7803 | led2 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 7804 | ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); |
whismanoid | 0:3edb3708c8c5 | 7805 | led1 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 7806 | //led2 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 7807 | led3 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 7808 | ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); |
whismanoid | 0:3edb3708c8c5 | 7809 | led2 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 7810 | //led3 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 7811 | led4 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 7812 | ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); |
whismanoid | 0:3edb3708c8c5 | 7813 | led3 = LED_OFF; |
whismanoid | 0:3edb3708c8c5 | 7814 | led4 = LED_ON; |
whismanoid | 0:3edb3708c8c5 | 7815 | // |
whismanoid | 0:3edb3708c8c5 | 7816 | #endif // target definition |
whismanoid | 0:3edb3708c8c5 | 7817 | #endif |
whismanoid | 0:3edb3708c8c5 | 7818 | |
whismanoid | 0:3edb3708c8c5 | 7819 | // cmd_TE(); |
whismanoid | 0:3edb3708c8c5 | 7820 | |
whismanoid | 0:3edb3708c8c5 | 7821 | #if USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 7822 | rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 7823 | #endif // USE_LEDS |
whismanoid | 0:3edb3708c8c5 | 7824 | InitializeConfiguration(); |
whismanoid | 0:3edb3708c8c5 | 7825 | |
whismanoid | 0:3edb3708c8c5 | 7826 | while (1) { |
whismanoid | 0:3edb3708c8c5 | 7827 | #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING |
whismanoid | 0:3edb3708c8c5 | 7828 | // avoid runtime error on button1 press [mbed-os-5.11] |
whismanoid | 0:3edb3708c8c5 | 7829 | // instead of using InterruptIn, use DigitalIn and poll in main while(1) |
whismanoid | 0:3edb3708c8c5 | 7830 | # if HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 7831 | static int button1_value_prev = 1; |
whismanoid | 0:3edb3708c8c5 | 7832 | static int button1_value_now = 1; |
whismanoid | 0:3edb3708c8c5 | 7833 | button1_value_prev = button1_value_now; |
whismanoid | 0:3edb3708c8c5 | 7834 | button1_value_now = button1.read(); |
whismanoid | 0:3edb3708c8c5 | 7835 | if ((button1_value_prev - button1_value_now) == 1) |
whismanoid | 0:3edb3708c8c5 | 7836 | { |
whismanoid | 0:3edb3708c8c5 | 7837 | // on button1 falling edge (button1 press) |
whismanoid | 0:3edb3708c8c5 | 7838 | onButton1FallingEdge(); |
whismanoid | 0:3edb3708c8c5 | 7839 | } |
whismanoid | 0:3edb3708c8c5 | 7840 | # endif // HAS_BUTTON1_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 7841 | # if HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 7842 | static int button2_value_prev = 1; |
whismanoid | 0:3edb3708c8c5 | 7843 | static int button2_value_now = 1; |
whismanoid | 0:3edb3708c8c5 | 7844 | button2_value_prev = button2_value_now; |
whismanoid | 0:3edb3708c8c5 | 7845 | button2_value_now = button2.read(); |
whismanoid | 0:3edb3708c8c5 | 7846 | if ((button2_value_prev - button2_value_now) == 1) |
whismanoid | 0:3edb3708c8c5 | 7847 | { |
whismanoid | 0:3edb3708c8c5 | 7848 | // on button2 falling edge (button2 press) |
whismanoid | 0:3edb3708c8c5 | 7849 | onButton2FallingEdge(); |
whismanoid | 0:3edb3708c8c5 | 7850 | } |
whismanoid | 0:3edb3708c8c5 | 7851 | # endif // HAS_BUTTON2_DEMO_INTERRUPT |
whismanoid | 0:3edb3708c8c5 | 7852 | #endif |
whismanoid | 0:3edb3708c8c5 | 7853 | #if USE_COMMAND_BUFFER |
whismanoid | 0:3edb3708c8c5 | 7854 | //cmdLine_update(); |
whismanoid | 0:3edb3708c8c5 | 7855 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7856 | // GREEN = DAPLINKserial |
whismanoid | 0:3edb3708c8c5 | 7857 | //~ led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 7858 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7859 | if (DAPLINKserial.readable()) { |
whismanoid | 0:3edb3708c8c5 | 7860 | cmdLine_DAPLINKserial.append(DAPLINKserial.getc()); |
whismanoid | 0:3edb3708c8c5 | 7861 | } |
whismanoid | 0:3edb3708c8c5 | 7862 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7863 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7864 | // BLUE = reading ADC |
whismanoid | 0:3edb3708c8c5 | 7865 | //~ led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 7866 | // CS=%d) set comTickLimit %d..%d CSA) comTickLimit is set by AIN0 |
whismanoid | 0:3edb3708c8c5 | 7867 | //~ if (is_comTickLimit_from_AIN0) { |
whismanoid | 0:3edb3708c8c5 | 7868 | //~ update_comTickLimit_from_AIN0_AIN4(); |
whismanoid | 0:3edb3708c8c5 | 7869 | //~ } |
whismanoid | 0:3edb3708c8c5 | 7870 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7871 | // YELLOW = microUSBserial |
whismanoid | 0:3edb3708c8c5 | 7872 | //~ led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 7873 | # if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7874 | if (microUSBserial.readable()) { |
whismanoid | 0:3edb3708c8c5 | 7875 | int c = microUSBserial.getc(); |
whismanoid | 0:3edb3708c8c5 | 7876 | cmdLine_microUSBserial.append(c); |
whismanoid | 0:3edb3708c8c5 | 7877 | #if IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7878 | # if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7879 | cmdLine_DAPLINKserial.serial().printf("%c", c); |
whismanoid | 0:3edb3708c8c5 | 7880 | # endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7881 | #endif // IGNORE_AT_COMMANDS |
whismanoid | 0:3edb3708c8c5 | 7882 | // |
whismanoid | 0:3edb3708c8c5 | 7883 | } |
whismanoid | 0:3edb3708c8c5 | 7884 | # endif // HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7885 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7886 | // MAGENTA = reading ADC |
whismanoid | 0:3edb3708c8c5 | 7887 | //~ led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 7888 | // CP=%d) set pwmCompare %d..%d CPA) PWM is set by AIN1 |
whismanoid | 0:3edb3708c8c5 | 7889 | //~ if (is_pwmCompare_from_AIN1) { |
whismanoid | 0:3edb3708c8c5 | 7890 | //~ update_pwmCompare_from_AIN1_AIN5(); |
whismanoid | 0:3edb3708c8c5 | 7891 | //~ } |
whismanoid | 0:3edb3708c8c5 | 7892 | //-------------------------------------------------- |
whismanoid | 0:3edb3708c8c5 | 7893 | // CYAN = other while loop stuff? |
whismanoid | 0:3edb3708c8c5 | 7894 | //~ led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 7895 | //~ rgb_led.red(); // diagnostic rbg led RED |
whismanoid | 0:3edb3708c8c5 | 7896 | //~ rgb_led.green(); // diagnostic rbg led GREEN |
whismanoid | 0:3edb3708c8c5 | 7897 | //~ rgb_led.blue(); // diagnostic rbg led BLUE |
whismanoid | 0:3edb3708c8c5 | 7898 | //~ rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE |
whismanoid | 0:3edb3708c8c5 | 7899 | //~ rgb_led.cyan(); // diagnostic rbg led GREEN+BLUE=CYAN |
whismanoid | 0:3edb3708c8c5 | 7900 | //~ rgb_led.magenta(); // diagnostic rbg led RED+BLUE=MAGENTA |
whismanoid | 0:3edb3708c8c5 | 7901 | //~ rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW |
whismanoid | 0:3edb3708c8c5 | 7902 | //~ rgb_led.black(); // diagnostic rbg led BLACK |
whismanoid | 0:3edb3708c8c5 | 7903 | #else // USE_COMMAND_BUFFER |
whismanoid | 0:3edb3708c8c5 | 7904 | // |
whismanoid | 0:3edb3708c8c5 | 7905 | // character echo demo stuff; sandbox |
whismanoid | 0:3edb3708c8c5 | 7906 | // |
whismanoid | 0:3edb3708c8c5 | 7907 | // char* gets(char* buf, int size); // equivalent to char *gets_s( char *str, rsize_t n ) |
whismanoid | 0:3edb3708c8c5 | 7908 | // Reads characters from stdin until a newline is found or end-of-file occurs. |
whismanoid | 0:3edb3708c8c5 | 7909 | // Writes only at most n-1 characters into the array pointed to by str, |
whismanoid | 0:3edb3708c8c5 | 7910 | // and always writes the terminating null character (unless str is a null pointer). |
whismanoid | 0:3edb3708c8c5 | 7911 | // The newline character, is discarded and not written to the buffer. |
whismanoid | 0:3edb3708c8c5 | 7912 | if (gets(line_buffer, sizeof(line_buffer))) |
whismanoid | 0:3edb3708c8c5 | 7913 | { |
whismanoid | 0:3edb3708c8c5 | 7914 | puts(line_buffer); |
whismanoid | 0:3edb3708c8c5 | 7915 | } |
whismanoid | 0:3edb3708c8c5 | 7916 | |
whismanoid | 0:3edb3708c8c5 | 7917 | // serial port demo -- echo from DAPLINKserial to microUSBserial |
whismanoid | 0:3edb3708c8c5 | 7918 | #if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7919 | if (DAPLINKserial.readable()) { |
whismanoid | 0:3edb3708c8c5 | 7920 | int c = DAPLINKserial.getc(); |
whismanoid | 0:3edb3708c8c5 | 7921 | led2 = (c & 1); |
whismanoid | 0:3edb3708c8c5 | 7922 | #if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7923 | DAPLINKserial.putc(c); |
whismanoid | 0:3edb3708c8c5 | 7924 | #endif |
whismanoid | 0:3edb3708c8c5 | 7925 | #if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7926 | microUSBserial.putc(c); |
whismanoid | 0:3edb3708c8c5 | 7927 | #endif |
whismanoid | 0:3edb3708c8c5 | 7928 | // command processing |
whismanoid | 0:3edb3708c8c5 | 7929 | if (c == '?') { |
whismanoid | 0:3edb3708c8c5 | 7930 | print_banner(); |
whismanoid | 0:3edb3708c8c5 | 7931 | } |
whismanoid | 0:3edb3708c8c5 | 7932 | } |
whismanoid | 0:3edb3708c8c5 | 7933 | #endif // HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7934 | // serial port demo -- echo from microUSBserial to DAPLINKserial |
whismanoid | 0:3edb3708c8c5 | 7935 | #if HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7936 | if (microUSBserial.readable()) { |
whismanoid | 0:3edb3708c8c5 | 7937 | int c = microUSBserial.getc(); |
whismanoid | 0:3edb3708c8c5 | 7938 | led1 = (c & 1); |
whismanoid | 0:3edb3708c8c5 | 7939 | #if HAS_DAPLINK_SERIAL |
whismanoid | 0:3edb3708c8c5 | 7940 | DAPLINKserial.putc(c); |
whismanoid | 0:3edb3708c8c5 | 7941 | #endif |
whismanoid | 0:3edb3708c8c5 | 7942 | microUSBserial.putc(c); |
whismanoid | 0:3edb3708c8c5 | 7943 | // command processing |
whismanoid | 0:3edb3708c8c5 | 7944 | if (c == '?') { |
whismanoid | 0:3edb3708c8c5 | 7945 | print_banner(); |
whismanoid | 0:3edb3708c8c5 | 7946 | } |
whismanoid | 0:3edb3708c8c5 | 7947 | } |
whismanoid | 0:3edb3708c8c5 | 7948 | #endif // HAS_MICROUSBSERIAL |
whismanoid | 0:3edb3708c8c5 | 7949 | #endif // USE_COMMAND_BUFFER |
whismanoid | 0:3edb3708c8c5 | 7950 | } // while(1) |
whismanoid | 0:3edb3708c8c5 | 7951 | } |