
Test program running on MAX32625MBED. Control through USB Serial commands using a terminal emulator such as teraterm or putty.
Dependencies: MaximTinyTester CmdLine MAX541 USBDevice
Revision 52:607010f0c54e, committed 2020-02-11
- Comitter:
- whismanoid
- Date:
- Tue Feb 11 01:16:34 2020 +0000
- Parent:
- 51:15d9a9e0b623
- Child:
- 53:3d5a3d241a5e
- Commit message:
- MAX11043 initial serial tester for investigation
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MAX11043/MAX11043.cpp Tue Feb 11 01:16:34 2020 +0000 @@ -0,0 +1,934 @@ +// /******************************************************************************* +// * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved. +// * +// * Permission is hereby granted, free of charge, to any person obtaining a +// * copy of this software and associated documentation files (the "Software"), +// * to deal in the Software without restriction, including without limitation +// * the rights to use, copy, modify, merge, publish, distribute, sublicense, +// * and/or sell copies of the Software, and to permit persons to whom the +// * Software is furnished to do so, subject to the following conditions: +// * +// * The above copyright notice and this permission notice shall be included +// * in all copies or substantial portions of the Software. +// * +// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +// * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// * OTHER DEALINGS IN THE SOFTWARE. +// * +// * Except as contained in this notice, the name of Maxim Integrated +// * Products, Inc. shall not be used except as stated in the Maxim Integrated +// * Products, Inc. Branding Policy. +// * +// * The mere transfer of this software does not imply any licenses +// * of trade secrets, proprietary technology, copyrights, patents, +// * trademarks, maskwork rights, or any other form of intellectual +// * property whatsoever. Maxim Integrated Products, Inc. retains all +// * ownership rights. +// ******************************************************************************* +// */ +// ********************************************************************* +// @file MAX11043.cpp +// ********************************************************************* +// Device Driver file +// DO NOT EDIT; except areas designated "CUSTOMIZE". Automatically generated file. +// generated by XMLSystemOfDevicesToMBED.py +// System Name = ExampleSystem +// System Description = Device driver example + +#include "MAX11043.h" + +// Device Name = MAX11043 +// Device Description = 200ksps, Low-Power, Serial SPI 24-Bit, 4-Channel, Differential/Single-Ended Input, Simultaneous-Sampling SD ADC +// Device DeviceBriefDescription = 24-bit 200ksps Delta-Sigma ADC +// Device Manufacturer = Maxim Integrated +// Device PartNumber = MAX11043ATL+ +// Device RegValue_Width = DataWidth16bit_HL +// +// ADC MaxOutputDataRate = 200ksps +// ADC NumChannels = 4 +// ADC ResolutionBits = 24 +// +// SPI CS = ActiveLow +// SPI FrameStart = CS +// SPI CPOL = 0 +// SPI CPHA = 0 +// SPI MOSI and MISO Data are both stable on Rising edge of SCLK +// SPI SCLK Idle Low +// SPI SCLKMaxMHz = 40 +// SPI SCLKMinMHz = 0 +// +// InputPin Name = CONVRUN +// InputPin Description = CONVRUN (digital input). Convert Run. Drive high to start continuous conversions on all 4 channels. The device is idle when +// CONVRUN is low. +// InputPin Function = Configuration +// +// InputPin Name = SHDN +// InputPin Description = Shutdown (digital input). Active-High Shutdown Input. Drive high to shut down the MAX11043. +// InputPin Function = Configuration +// +// InputPin Name = DACSTEP +// InputPin Description = DACSTEP (digital input). DAC Step Input. Drive high to move the DAC output in the direction of UP/DWN on the next rising +// edge of the system clock. +// InputPin Function = Configuration +// +// InputPin Name = UP/DWN# +// InputPin Description = UP/DWN# (digital input). DAC Step Direction Select. Drive high to step up, drive low to step down when DACSTEP is toggled. +// InputPin Function = Configuration +// +// OutputPin Name = EOC +// OutputPin Description = End of Conversion Output. Active-Low End-of-Conversion Indicator. EOC asserts low to indicate that new data is ready. +// OutputPin Function = Event +// + +// CODE GENERATOR: class constructor definition +MAX11043::MAX11043(SPI &spi, DigitalOut &cs_pin, // SPI interface + // CODE GENERATOR: class constructor definition gpio InputPin pins + DigitalOut &CONVRUN_pin, // Digital Configuration Input to MAX11043 device + DigitalOut &SHDN_pin, // Digital Configuration Input to MAX11043 device + DigitalOut &DACSTEP_pin, // Digital Configuration Input to MAX11043 device + DigitalOut &UP_slash_DWNb_pin, // Digital Configuration Input to MAX11043 device + // CODE GENERATOR: class constructor definition gpio OutputPin pins + DigitalIn &EOC_pin, // Digital Event Output from MAX11043 device + // CODE GENERATOR: class constructor definition ic_variant + MAX11043_ic_t ic_variant) + // CODE GENERATOR: class constructor initializer list + : m_spi(spi), m_cs_pin(cs_pin), // SPI interface + // CODE GENERATOR: class constructor initializer list gpio InputPin pins + m_CONVRUN_pin(CONVRUN_pin), // Digital Configuration Input to MAX11043 device + m_SHDN_pin(SHDN_pin), // Digital Configuration Input to MAX11043 device + m_DACSTEP_pin(DACSTEP_pin), // Digital Configuration Input to MAX11043 device + m_UP_slash_DWNb_pin(UP_slash_DWNb_pin), // Digital Configuration Input to MAX11043 device + // CODE GENERATOR: class constructor initializer list gpio OutputPin pins + m_EOC_pin(EOC_pin), // Digital Event Output from MAX11043 device + // CODE GENERATOR: class constructor initializer list ic_variant + m_ic_variant(ic_variant) +{ + // CODE GENERATOR: class constructor definition SPI interface initialization + // + // SPI CS = ActiveLow + // SPI FrameStart = CS + m_SPI_cs_state = 1; + m_cs_pin = m_SPI_cs_state; + + // SPI CPOL = 0 + // SPI CPHA = 0 + // SPI MOSI and MISO Data are both stable on Rising edge of SCLK + // SPI SCLK Idle Low + m_SPI_dataMode = 0; //SPI_MODE0; // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low + m_spi.format(8,m_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 + + // SPI SCLKMaxMHz = 40 + // SPI SCLKMinMHz = 0 + //#define SPI_SCLK_Hz 48000000 // 48MHz + //#define SPI_SCLK_Hz 24000000 // 24MHz + //#define SPI_SCLK_Hz 12000000 // 12MHz + //#define SPI_SCLK_Hz 6000000 // 6MHz + //#define SPI_SCLK_Hz 4000000 // 4MHz + //#define SPI_SCLK_Hz 2000000 // 2MHz + //#define SPI_SCLK_Hz 1000000 // 1MHz + m_SPI_SCLK_Hz = 12000000; // 12MHz; MAX11043 limit is 40MHz + m_spi.frequency(m_SPI_SCLK_Hz); + + // + // CODE GENERATOR: class constructor definition gpio InputPin (Input to device) initialization + // + // CONVRUN Configuration Input to MAX11043 device + m_CONVRUN_pin = 1; // output logic high -- initial value in constructor + // + // SHDN Configuration Input to MAX11043 device + m_SHDN_pin = 1; // output logic high -- initial value in constructor + // + // DACSTEP Configuration Input to MAX11043 device + m_DACSTEP_pin = 1; // output logic high -- initial value in constructor + // + // UP_slash_DWNb Configuration Input to MAX11043 device + m_UP_slash_DWNb_pin = 1; // output logic high -- initial value in constructor + // + // CODE GENERATOR: class constructor definition gpio OutputPin (Output from MAX11043 device) initialization + // + // EOC Event Output from device +} + +// CODE GENERATOR: class destructor definition +MAX11043::~MAX11043() +{ + // do nothing +} + +// CODE GENERATOR: spi_frequency setter definition +/// set SPI SCLK frequency +void MAX11043::spi_frequency(int spi_sclk_Hz) +{ + m_SPI_SCLK_Hz = spi_sclk_Hz; + m_spi.frequency(m_SPI_SCLK_Hz); +} + +// CODE GENERATOR: omit global g_MAX11043_device +// CODE GENERATOR: extern function declarations +// CODE GENERATOR: extern function requirement MAX11043::SPIoutputCS +// Assert SPI Chip Select +// SPI chip-select for MAX11043 +// +void MAX11043::SPIoutputCS(int isLogicHigh) +{ + // CODE GENERATOR: extern function definition for function SPIoutputCS + // CODE GENERATOR: extern function definition for standard SPI interface function SPIoutputCS(int isLogicHigh) + m_SPI_cs_state = isLogicHigh; + m_cs_pin = m_SPI_cs_state; +} + +// CODE GENERATOR: extern function requirement MAX11043::SPIwrite16bits +// SPI write 16 bits +// SPI interface to MAX11043 shift 16 bits mosiData into MAX11043 DIN +// +void MAX11043::SPIwrite16bits(int16_t mosiData16) +{ + // CODE GENERATOR: extern function definition for function SPIwrite16bits + // TODO1: CODE GENERATOR: extern function definition for standard SPI interface function SPIwrite16bits(int16_t mosiData16) + size_t byteCount = 2; + static char mosiData[2]; + static char misoData[2]; + mosiData[0] = (char)((mosiData16 >> 8) & 0xFF); // MSByte + mosiData[1] = (char)((mosiData16 >> 0) & 0xFF); // LSByte + // + // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() + //~ noInterrupts(); + // + //~ digitalWrite(Scope_Trigger_Pin, LOW); // diagnostic Scope_Trigger_Pin + // + unsigned int numBytesTransferred = m_spi.write(mosiData, byteCount, misoData, byteCount); + //~ m_spi.transfer(mosiData8_FF0000); + //~ m_spi.transfer(mosiData16_00FF00); + //~ m_spi.transfer(mosiData16_0000FF); + // + //~ digitalWrite(Scope_Trigger_Pin, HIGH); // diagnostic Scope_Trigger_Pin + // + // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() + //~ interrupts(); + // Optional Diagnostic function to print SPI transactions + if (onSPIprint) + { + onSPIprint(byteCount, (uint8_t*)mosiData, (uint8_t*)misoData); + } + // + // VERIFY: SPIwrite24bits print diagnostic information + //cmdLine.serial().printf(" MOSI->")); + //cmdLine.serial().printf(" 0x")); + //Serial.print( (mosiData8_FF0000 & 0xFF), HEX); + //cmdLine.serial().printf(" 0x")); + //Serial.print( (mosiData16_00FF00 & 0xFF), HEX); + //cmdLine.serial().printf(" 0x")); + //Serial.print( (mosiData16_0000FF & 0xFF), HEX); + // hex dump mosiData[0..byteCount-1] +#if 0 // HAS_MICROUSBSERIAL + cmdLine_microUSBserial.serial().printf("\r\nSPI"); + if (byteCount > 7) { + cmdLine_microUSBserial.serial().printf(" byteCount:%d", byteCount); + } + cmdLine_microUSBserial.serial().printf(" MOSI->"); + for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) + { + cmdLine_microUSBserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); + } + // hex dump misoData[0..byteCount-1] + cmdLine_microUSBserial.serial().printf(" MISO<-"); + for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) + { + cmdLine_microUSBserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); + } + cmdLine_microUSBserial.serial().printf(" "); +#endif +#if 0 // HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("\r\nSPI"); + if (byteCount > 7) { + cmdLine_DAPLINKserial.serial().printf(" byteCount:%d", byteCount); + } + cmdLine_DAPLINKserial.serial().printf(" MOSI->"); + for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) + { + cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); + } + // hex dump misoData[0..byteCount-1] + cmdLine_DAPLINKserial.serial().printf(" MISO<-"); + for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) + { + cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); + } + cmdLine_DAPLINKserial.serial().printf(" "); +#endif + // VERIFY: DIAGNOSTIC: print MAX5715 device register write + // TODO: MAX5715_print_register_verbose(mosiData8_FF0000, mosiData16_00FFFF); + // TODO: print_verbose_SPI_diagnostic(mosiData16_FF00, mosiData16_00FF, misoData16_FF00, misoData16_00FF); + // + // int misoData16 = (misoData16_FF00 << 8) | misoData16_00FF; + // return misoData16; +} + +// CODE GENERATOR: extern function requirement MAX11043::SPIreadWrite16bits +// SPI read and write 16 bits +// SPI interface to MAX11043 shift 16 bits mosiData16 into MAX11043 DIN +// while simultaneously capturing 16 bits miso data from MAX11043 DOUT +// +int16_t MAX11043::SPIreadWrite16bits(int16_t mosiData16) +{ + // CODE GENERATOR: extern function definition for function SPIreadWrite16bits + // TODO1: CODE GENERATOR: extern function definition for standard SPI interface function SPIreadWrite16bits(int16_t mosiData16) + size_t byteCount = 2; + static char mosiData[2]; + static char misoData[2]; + mosiData[0] = (char)((mosiData16 >> 8) & 0xFF); // MSByte + mosiData[1] = (char)((mosiData16 >> 0) & 0xFF); // LSByte + // + // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() + //~ noInterrupts(); + // + //~ digitalWrite(Scope_Trigger_Pin, LOW); // diagnostic Scope_Trigger_Pin + // + unsigned int numBytesTransferred = m_spi.write(mosiData, byteCount, misoData, byteCount); + //~ m_spi.transfer(mosiData8_FF0000); + //~ m_spi.transfer(mosiData16_00FF00); + //~ m_spi.transfer(mosiData16_0000FF); + // + //~ digitalWrite(Scope_Trigger_Pin, HIGH); // diagnostic Scope_Trigger_Pin + // + // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() + //~ interrupts(); + // Optional Diagnostic function to print SPI transactions + if (onSPIprint) + { + onSPIprint(byteCount, (uint8_t*)mosiData, (uint8_t*)misoData); + } + // + // VERIFY: SPIwrite24bits print diagnostic information + //cmdLine.serial().printf(" MOSI->")); + //cmdLine.serial().printf(" 0x")); + //Serial.print( (mosiData8_FF0000 & 0xFF), HEX); + //cmdLine.serial().printf(" 0x")); + //Serial.print( (mosiData16_00FF00 & 0xFF), HEX); + //cmdLine.serial().printf(" 0x")); + //Serial.print( (mosiData16_0000FF & 0xFF), HEX); + // hex dump mosiData[0..byteCount-1] +#if 0 // HAS_MICROUSBSERIAL + cmdLine_microUSBserial.serial().printf("\r\nSPI"); + if (byteCount > 7) { + cmdLine_microUSBserial.serial().printf(" byteCount:%d", byteCount); + } + cmdLine_microUSBserial.serial().printf(" MOSI->"); + for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) + { + cmdLine_microUSBserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); + } + // hex dump misoData[0..byteCount-1] + cmdLine_microUSBserial.serial().printf(" MISO<-"); + for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) + { + cmdLine_microUSBserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); + } + cmdLine_microUSBserial.serial().printf(" "); +#endif +#if 0 // HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("\r\nSPI"); + if (byteCount > 7) { + cmdLine_DAPLINKserial.serial().printf(" byteCount:%d", byteCount); + } + cmdLine_DAPLINKserial.serial().printf(" MOSI->"); + for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) + { + cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); + } + // hex dump misoData[0..byteCount-1] + cmdLine_DAPLINKserial.serial().printf(" MISO<-"); + for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) + { + cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); + } + cmdLine_DAPLINKserial.serial().printf(" "); +#endif + // VERIFY: DIAGNOSTIC: print MAX5715 device register write + // TODO: MAX5715_print_register_verbose(mosiData8_FF0000, mosiData16_00FFFF); + // TODO: print_verbose_SPI_diagnostic(mosiData16_FF00, mosiData16_00FF, misoData16_FF00, misoData16_00FF); + // + //int misoData16 = (misoData16_FF00 << 8) | misoData16_00FF; + int misoData16 = (misoData[0] << 8) | misoData[1]; + return misoData16; +} + +// CODE GENERATOR: extern function requirement MAX11043::SPIreadWrite32bits +// SPI read and write 32 bits +// SPI interface to MAX11043 shift 32 bits mosiData into MAX11043 DIN +// while simultaneously capturing 32 bits miso data from MAX11043 DOUT +// +int32_t MAX11043::SPIreadWrite32bits(int32_t mosiData32) +{ + // CODE GENERATOR: extern function definition for function SPIreadWrite32bits + // TODO1: CODE GENERATOR: extern function definition for standard SPI interface function SPIreadWrite32bits(int32_t mosiData32) + size_t byteCount = 4; + static char mosiData[4]; + static char misoData[4]; + mosiData[0] = (char)((mosiData32 >> 24) & 0xFF); // MSByte + mosiData[1] = (char)((mosiData32 >> 16) & 0xFF); + mosiData[2] = (char)((mosiData32 >> 8) & 0xFF); + mosiData[3] = (char)((mosiData32 >> 0) & 0xFF); // LSByte + // + // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() + //~ noInterrupts(); + // + //~ digitalWrite(Scope_Trigger_Pin, LOW); // diagnostic Scope_Trigger_Pin + // + unsigned int numBytesTransferred = m_spi.write(mosiData, byteCount, misoData, byteCount); + //~ m_spi.transfer(mosiData8_FF0000); + //~ m_spi.transfer(mosiData16_00FF00); + //~ m_spi.transfer(mosiData16_0000FF); + // + //~ digitalWrite(Scope_Trigger_Pin, HIGH); // diagnostic Scope_Trigger_Pin + // + // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() + //~ interrupts(); + // Optional Diagnostic function to print SPI transactions + if (onSPIprint) + { + onSPIprint(byteCount, (uint8_t*)mosiData, (uint8_t*)misoData); + } + // + // VERIFY: SPIwrite24bits print diagnostic information + //cmdLine.serial().printf(" MOSI->")); + //cmdLine.serial().printf(" 0x")); + //Serial.print( (mosiData8_FF0000 & 0xFF), HEX); + //cmdLine.serial().printf(" 0x")); + //Serial.print( (mosiData16_00FF00 & 0xFF), HEX); + //cmdLine.serial().printf(" 0x")); + //Serial.print( (mosiData16_0000FF & 0xFF), HEX); + // hex dump mosiData[0..byteCount-1] +#if 0 // HAS_MICROUSBSERIAL + cmdLine_microUSBserial.serial().printf("\r\nSPI"); + if (byteCount > 7) { + cmdLine_microUSBserial.serial().printf(" byteCount:%d", byteCount); + } + cmdLine_microUSBserial.serial().printf(" MOSI->"); + for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) + { + cmdLine_microUSBserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); + } + // hex dump misoData[0..byteCount-1] + cmdLine_microUSBserial.serial().printf(" MISO<-"); + for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) + { + cmdLine_microUSBserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); + } + cmdLine_microUSBserial.serial().printf(" "); +#endif +#if 0 // HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("\r\nSPI"); + if (byteCount > 7) { + cmdLine_DAPLINKserial.serial().printf(" byteCount:%d", byteCount); + } + cmdLine_DAPLINKserial.serial().printf(" MOSI->"); + for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) + { + cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); + } + // hex dump misoData[0..byteCount-1] + cmdLine_DAPLINKserial.serial().printf(" MISO<-"); + for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) + { + cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); + } + cmdLine_DAPLINKserial.serial().printf(" "); +#endif + // VERIFY: DIAGNOSTIC: print MAX5715 device register write + // TODO: MAX5715_print_register_verbose(mosiData8_FF0000, mosiData16_00FFFF); + // TODO: print_verbose_SPI_diagnostic(mosiData16_FF00, mosiData16_00FF, misoData16_FF00, misoData16_00FF); + // + //int misoData32 = (misoData32_FF000000 << 24) | (misoData32_FF0000 << 16) | (misoData32_0000FF00 << 8) | misoData32_000000FF; + int misoData32 = (misoData[0] << 24) | (misoData[1] << 16) | (misoData[2] << 8) | misoData[3]; + return misoData32; +} + +// TODO1: CODE GENERATOR: extern function GPIOoutputSHDN alias SHDNoutputValue +// CODE GENERATOR: extern function requirement MAX11043::SHDNoutputValue +// Assert MAX11043 SHDN pin : High = _____, Low = _____. +// +void MAX11043::SHDNoutputValue(int isLogicHigh) +{ + // CODE GENERATOR: extern function definition for function SHDNoutputValue + // TODO1: CODE GENERATOR: extern function definition for gpio interface function SHDNoutputValue + // TODO1: CODE GENERATOR: gpio pin SHDN assuming member function m_SHDN_pin + // TODO1: CODE GENERATOR: gpio direction output + // m_SHDN_pin.output(); // only applicable to DigitalInOut + // TODO1: CODE GENERATOR: gpio function Value + m_SHDN_pin = isLogicHigh; +} + +// TODO1: CODE GENERATOR: extern function GPIOoutputCONVRUN alias CONVRUNoutputValue +// CODE GENERATOR: extern function requirement MAX11043::CONVRUNoutputValue +// Assert MAX11043 CONVRUN pin : High = _____, Low = _____. +// +void MAX11043::CONVRUNoutputValue(int isLogicHigh) +{ + // CODE GENERATOR: extern function definition for function CONVRUNoutputValue + // TODO1: CODE GENERATOR: extern function definition for gpio interface function CONVRUNoutputValue + // TODO1: CODE GENERATOR: gpio pin CONVRUN assuming member function m_CONVRUN_pin + // TODO1: CODE GENERATOR: gpio direction output + // m_CONVRUN_pin.output(); // only applicable to DigitalInOut + // TODO1: CODE GENERATOR: gpio function Value + m_CONVRUN_pin = isLogicHigh; +} + +// TODO1: CODE GENERATOR: extern function GPIOoutputDACSTEP alias DACSTEPoutputValue +// CODE GENERATOR: extern function requirement MAX11043::DACSTEPoutputValue +// Assert MAX11043 DACSTEP pin : High = _____, Low = _____. +// +void MAX11043::DACSTEPoutputValue(int isLogicHigh) +{ + // CODE GENERATOR: extern function definition for function DACSTEPoutputValue + // TODO1: CODE GENERATOR: extern function definition for gpio interface function DACSTEPoutputValue + // TODO1: CODE GENERATOR: gpio pin DACSTEP assuming member function m_DACSTEP_pin + // TODO1: CODE GENERATOR: gpio direction output + // m_DACSTEP_pin.output(); // only applicable to DigitalInOut + // TODO1: CODE GENERATOR: gpio function Value + m_DACSTEP_pin = isLogicHigh; +} + +// TODO1: CODE GENERATOR: extern function GPIOoutputUP_slash_DWNb alias UP_slash_DWNboutputValue +// CODE GENERATOR: extern function requirement MAX11043::UP_slash_DWNboutputValue +// Assert MAX11043 UP_slash_DWNb pin : High = _____, Low = _____. +// +void MAX11043::UP_slash_DWNboutputValue(int isLogicHigh) +{ + // CODE GENERATOR: extern function definition for function UP_slash_DWNboutputValue + // TODO1: CODE GENERATOR: extern function definition for gpio interface function UP_slash_DWNboutputValue + // TODO1: CODE GENERATOR: gpio pin UP_slash_DWNb assuming member function m_UP_slash_DWNb_pin + // TODO1: CODE GENERATOR: gpio direction output + // m_UP_slash_DWNb_pin.output(); // only applicable to DigitalInOut + // TODO1: CODE GENERATOR: gpio function Value + m_UP_slash_DWNb_pin = isLogicHigh; +} + +// CODE GENERATOR: extern function requirement MAX11043::EOCinputWaitUntilLow +// Wait for MAX11043 EOC pin low, indicating end of conversion. +// Required when using any of the InternalClock modes. +// +void MAX11043::EOCinputWaitUntilLow() +{ + // CODE GENERATOR: extern function definition for function EOCinputWaitUntilLow + // TODO1: CODE GENERATOR: extern function definition for gpio interface function EOCinputWaitUntilLow + // TODO1: CODE GENERATOR: gpio pin EOC assuming member function m_EOC_pin + // TODO1: CODE GENERATOR: gpio direction input + // m_EOC_pin.input(); // only applicable to DigitalInOut + // TODO1: CODE GENERATOR: gpio function WaitUntilLow + while (m_EOC_pin != 0) + { + // spinlock waiting for logic low pin state + } +} + +// CODE GENERATOR: extern function requirement MAX11043::EOCinputValue +// Return the status of the MAX11043 EOC pin. +// +int MAX11043::EOCinputValue() +{ + // CODE GENERATOR: extern function definition for function EOCinputValue + // TODO1: CODE GENERATOR: extern function definition for gpio interface function EOCinputValue + // TODO1: CODE GENERATOR: gpio pin EOC assuming member function m_EOC_pin + // TODO1: CODE GENERATOR: gpio direction input + // m_EOC_pin.input(); // only applicable to DigitalInOut + // TODO1: CODE GENERATOR: gpio function Value + return m_EOC_pin.read(); +} + +// CODE GENERATOR: class member function definitions +//---------------------------------------- +// Menu item '!' +// Initialize device +// @return 1 on success; 0 on failure +uint8_t MAX11043::Init(void) +{ + + //---------------------------------------- + // TODO1: AC79 MAX11043 AIN0-AIN1 reference voltage, in Volts + VRef_xxxxxx = 2.500; + + //---------------------------------------- + // shadow of register ctrl CMD_r000_1001_dddd_dddd_CTRL + ctrl = 0x01; + + //---------------------------------------- + // set by Configure_PGA gain index register pga CMD_r000_1110_xxdd_xddd_PGA + pgaGain = 1; + + //---------------------------------------- + // init (based on old EV kit GUI) + #warning "Not Implemented Yet: MAX11043::Init init..." + // bool bOpResult = false; + // String FWVersionString = "00"; + // bool bDemoMode = true; + // int scan_resolution = 0; + // int scan_channels = 0; + // int scan_bits = 0; + // int sampleRateFactore = 0; + // double sampleRate = 0; + // unsigned long banks_requested = 0; + // bool bScanMode = 0; + + //---------------------------------------- + // Device ID Validation + #warning "Not Implemented Yet: MAX11043::Init Device ID Validation..." + // const uint32_t part_id_expect = 0x000F02; + // uint32_t part_id_readback; + // RegRead(xxxxxxxxxxxxCMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback); + // if (part_id_readback != part_id_expect) return 0; + + //---------------------------------------- + // write8 0x00 PD = 0x03 (Reset Registers; enter Standby mode) + // RegWrite(xxxxxxxxxxxCMD_r000_0000_xxxx_xxdd_PD, PD_11_Reset); + + //---------------------------------------- + // write8 0x00 PD = 0x00 (NOP) + // RegWrite(xxxxxxxxxxxxCMD_r000_0000_xxxx_xxdd_PD, PD_00_Normal); + + //---------------------------------------- + // success + return 1; +} + +//---------------------------------------- +// Write a MAX11043 register. +// +// CMD_1aaa_aaaa_REGISTER_READ bit is cleared 0 indicating a write operation. +// +// MAX11043 register length can be determined by function RegSize. +// +// For 8-bit register size: +// +// SPI 16-bit transfer +// +// SPI MOSI = 0aaa_aaaa_dddd_dddd +// +// SPI MISO = xxxx_xxxx_xxxx_xxxx +// +// For 16-bit register size: +// +// SPI 24-bit or 32-bit transfer +// +// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd +// +// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx +// +// For 24-bit register size: +// +// SPI 32-bit transfer +// +// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd_dddd_dddd +// +// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx +// +// @return 1 on success; 0 on failure +uint8_t MAX11043::RegWrite(MAX11043_CMD_enum_t commandByte, uint32_t regData) +{ + + //---------------------------------------- + // switch based on register address szie RegSize(commandByte) + //commandByte = (MAX11043_CMD_enum_t)((commandByte &~ CMD_0aaa_aa10_RdAddr_ReadAnyRegister) & 0xFF); + switch(RegSize(commandByte)) + { + case 8: // 8-bit register size + { + // SPI 16-bit transfer + // SPI MOSI = 0aaa_aaaa_dddd_dddd + // SPI MISO = xxxx_xxxx_xxxx_xxxx + int16_t mosiData16 = ((int16_t)commandByte << 8) | ((int16_t)regData & 0xFF); + SPIoutputCS(0); + SPIwrite16bits(mosiData16); + SPIoutputCS(1); + } + break; + case 16: // 16-bit register size + #warning "Not Verified Yet: MAX11043::RegWrite 16-bit SPIreadWrite32bits" + { + // SPI 24-bit or 32-bit transfer + // SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd + // SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx + // SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd_0000_0000 + // SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx + int32_t mosiData32 = ((int32_t)commandByte << 24) | (((int32_t)regData & 0xFFFF) << 8); + SPIoutputCS(0); + SPIreadWrite32bits(mosiData32); + SPIoutputCS(1); + } + break; + case 24: // 24-bit register size + { + // SPI 32-bit transfer + // SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd_dddd_dddd + // SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx + int32_t mosiData32 = ((int32_t)commandByte << 24) | ((int32_t)regData & 0x00FFFFFF); + SPIoutputCS(0); + SPIreadWrite32bits(mosiData32); + SPIoutputCS(1); + } + break; + } + + //---------------------------------------- + // success + return 1; +} + +//---------------------------------------- +// Read an 8-bit MAX11043 register +// +// CMD_1aaa_aaaa_REGISTER_READ bit is set 1 indicating a read operation. +// +// MAX11043 register length can be determined by function RegSize. +// +// For 8-bit register size: +// +// SPI 16-bit transfer +// +// SPI MOSI = 1aaa_aaaa_0000_0000 +// +// SPI MISO = xxxx_xxxx_dddd_dddd +// +// For 16-bit register size: +// +// SPI 24-bit or 32-bit transfer +// +// SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000 +// +// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd +// +// For 24-bit register size: +// +// SPI 32-bit transfer +// +// SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000_0000_0000 +// +// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd_dddd_dddd +// +// +// @return 1 on success; 0 on failure +uint8_t MAX11043::RegRead(MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData) +{ + + //---------------------------------------- + // switch based on register address szie RegSize(regAddress) + //commandByte = (MAX11043_CMD_enum_t)((commandByte &~ CMD_0aaa_aa10_RdAddr_ReadAnyRegister) & 0xFF); + switch(RegSize(commandByte)) + { + case 8: // 8-bit register size + { + // SPI 16-bit transfer + // SPI MOSI = 1aaa_aaaa_0000_0000 + // SPI MISO = xxxx_xxxx_dddd_dddd + int16_t mosiData16 = ((CMD_0aaa_aa10_RdAddr_ReadAnyRegister | (int16_t)commandByte) << 8) | ((int16_t)0); + SPIoutputCS(0); + int16_t misoData16 = SPIreadWrite16bits(mosiData16); + SPIoutputCS(1); + (*ptrRegData) = (misoData16 & 0x00FF); + } + break; + case 16: // 16-bit register size + #warning "Not Verified Yet: MAX11043::RegRead 16-bit SPIreadWrite32bits" + { + // SPI 24-bit or 32-bit transfer + // SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000 + // SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd + // SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000_0000_0000 + // SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd_xxxx_xxxx + int32_t mosiData32 = ((CMD_0aaa_aa10_RdAddr_ReadAnyRegister | (int32_t)commandByte) << 24); + SPIoutputCS(0); + int32_t misoData32 = SPIreadWrite32bits(mosiData32); + SPIoutputCS(1); + (*ptrRegData) = ((misoData32 >> 8) & 0x00FFFF); + } + break; + case 24: // 24-bit register size + { + // SPI 32-bit transfer + // SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000_0000_0000 + // SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd_dddd_dddd + int32_t mosiData32 = ((CMD_0aaa_aa10_RdAddr_ReadAnyRegister | (int32_t)commandByte) << 24); + SPIoutputCS(0); + int32_t misoData32 = SPIreadWrite32bits(mosiData32); + SPIoutputCS(1); + (*ptrRegData) = (misoData32 & 0x00FFFFFF); + } + break; + } + + //---------------------------------------- + // success + return 1; +} + +//---------------------------------------- +// Return the size of a MAX11043 register +// +// @return 8 for 8-bit, 16 for 16-bit, 24 for 24-bit, else 0 for undefined register size +uint8_t MAX11043::RegSize(MAX11043_CMD_enum_t commandByte) +{ + + //---------------------------------------- + // switch based on register address value regAddress + // commandByte = (MAX11043_CMD_enum_t)((commandByte &~ CMD_0aaa_aa10_RdAddr_ReadAnyRegister) & 0xFF); + switch(commandByte) + { + default: + case CMD_0aaa_aa00_WrAddr_WriteAnyRegister: + case CMD_0aaa_aa10_RdAddr_ReadAnyRegister: + case CMD_1111_1111_NoOperationMOSIidleHigh: + return 0; // undefined register size + case CMD_0001_1110_d8_Rd07_Status: + case CMD_0101_0100_d8_Wr15_FilterCAddress: + case CMD_0101_0110_d8_Rd15_FilterCAddress: + case CMD_0110_0000_d8_Wr18_FlashMode: + case CMD_0110_0010_d8_Rd18_FlashMode: + return 8; // 8-bit register size + case CMD_0010_0000_d16_Wr08_Configuration: + case CMD_0010_0010_d16_Rd08_Configuration: + case CMD_0010_0100_d16_Wr09_DAC: + case CMD_0010_0110_d16_Rd09_DAC: + case CMD_0010_1000_d16_Wr0A_DACStep: + case CMD_0010_1010_d16_Rd0A_DACStep: + case CMD_0010_1100_d16_Wr0B_DACHDACL: + case CMD_0010_1110_d16_Rd0B_DACHDACL: + case CMD_0011_0000_d16_Wr0C_ConfigA: + case CMD_0011_0010_d16_Rd0C_ConfigA: + case CMD_0011_0100_d16_Wr0D_ConfigB: + case CMD_0011_0110_d16_Rd0D_ConfigB: + case CMD_0011_1000_d16_Wr0E_ConfigC: + case CMD_0011_1010_d16_Rd0E_ConfigC: + case CMD_0011_1100_d16_Wr0F_ConfigD: + case CMD_0011_1110_d16_Rd0F_ConfigD: + case CMD_0100_0000_d16_Wr10_Reference: + case CMD_0100_0010_d16_Rd10_Reference: + case CMD_0100_0100_d16_Wr11_AGain: + case CMD_0100_0110_d16_Rd11_AGain: + case CMD_0100_1000_d16_Wr12_BGain: + case CMD_0100_1010_d16_Rd12_BGain: + case CMD_0100_1100_d16_Wr13_CGain: + case CMD_0100_1110_d16_Rd13_CGain: + case CMD_0101_0000_d16_Wr14_DGain: + case CMD_0101_0010_d16_Rd14_DGain: + case CMD_0110_0100_d16_Wr19_FlashAddr: + case CMD_0110_0110_d16_Rd19_FlashAddr: + case CMD_0110_1000_d16_Wr1A_FlashDataIn: + case CMD_0110_1010_d16_Rd1A_FlashDataIn: + case CMD_0110_1110_d16_Rd1B_FlashDataOut: + return 16; // 16-bit register size + case CMD_0000_0010_d24_Rd00_ADCa: + case CMD_0000_0110_d24_Rd01_ADCb: + case CMD_0000_1010_d24_Rd02_ADCc: + case CMD_0000_1110_d24_Rd03_ADCd: + return 24; // 24-bit register size + case CMD_0001_0010_d24_d24_Rd04_ADCab: + case CMD_0001_0110_d24_d24_Rd05_ADCcd: + return 48; // 24-bit register size + case CMD_0001_1010_d24_d24_d24_d24_Rd06_ADCabcd: + return 96; // 24-bit register size + case CMD_0101_1000_d32_Wr16_FilterCDataOut: + case CMD_0101_1010_d32_Rd16_FilterCDataOut: + case CMD_0101_1100_d32_Wr17_FilterCDataIn: + case CMD_0101_1110_d32_Rd17_FilterCDataIn: + return 32; // 32-bit register size + } +} + +//---------------------------------------- +// Return the address field of a MAX11043 register +// +// @return register address field as given in datasheet +uint8_t MAX11043::RegAddrOfCommand(MAX11043_CMD_enum_t commandByte) +{ + + //---------------------------------------- + // extract register address value from command byte + return (uint8_t)((commandByte &~ 0x83) >> 2); // CMD_0aaa_aa10_RdAddr_ReadAnyRegister +} + +//---------------------------------------- +// Test whether a command byte is a register read command +// +// @return true if command byte is a register read command +uint8_t MAX11043::IsRegReadCommand(MAX11043_CMD_enum_t commandByte) +{ + + //---------------------------------------- + // Test whether a command byte is a register read command + return (commandByte &~ 0x02) ? 1 : 0; // CMD_0aaa_aa10_RdAddr_ReadAnyRegister +} + +//---------------------------------------- +// Return the name of a MAX11043 register +// +// @return null-terminated constant C string containing register name or empty string +const char* MAX11043::RegName(MAX11043_CMD_enum_t commandByte) +{ + + //---------------------------------------- + // switch based on register address value regAddress + // commandByte = (MAX11043_CMD_enum_t)((commandByte &~ CMD_0aaa_aa10_RdAddr_ReadAnyRegister) & 0xFF); + switch(commandByte) + { + default: + return ""; // undefined register + // case CMD_0aaa_aa00_WrAddr_WriteAnyRegister: return "_______"; + // case CMD_0aaa_aa10_RdAddr_ReadAnyRegister: return "_______"; + // case CMD_1111_1111_NoOperationMOSIidleHigh: return "_______"; + case CMD_0000_0010_d24_Rd00_ADCa: return "ADCa"; + case CMD_0000_0110_d24_Rd01_ADCb: return "ADCb"; + case CMD_0000_1010_d24_Rd02_ADCc: return "ADCc"; + case CMD_0000_1110_d24_Rd03_ADCd: return "ADCd"; + case CMD_0001_0010_d24_d24_Rd04_ADCab: return "ADCab"; + case CMD_0001_0110_d24_d24_Rd05_ADCcd: return "ADCcd"; + case CMD_0001_1010_d24_d24_d24_d24_Rd06_ADCabcd: return "ADCabcd"; + case CMD_0001_1110_d8_Rd07_Status: return "Status"; + case CMD_0010_0000_d16_Wr08_Configuration: return "Configuration"; + case CMD_0010_0010_d16_Rd08_Configuration: return "Configuration"; + case CMD_0010_0100_d16_Wr09_DAC: return "DAC"; + case CMD_0010_0110_d16_Rd09_DAC: return "DAC"; + case CMD_0010_1000_d16_Wr0A_DACStep: return "DACStep"; + case CMD_0010_1010_d16_Rd0A_DACStep: return "DACStep"; + case CMD_0010_1100_d16_Wr0B_DACHDACL: return "DACHDACL"; + case CMD_0010_1110_d16_Rd0B_DACHDACL: return "DACHDACL"; + case CMD_0011_0000_d16_Wr0C_ConfigA: return "ConfigA"; + case CMD_0011_0010_d16_Rd0C_ConfigA: return "ConfigA"; + case CMD_0011_0100_d16_Wr0D_ConfigB: return "ConfigB"; + case CMD_0011_0110_d16_Rd0D_ConfigB: return "ConfigB"; + case CMD_0011_1000_d16_Wr0E_ConfigC: return "ConfigC"; + case CMD_0011_1010_d16_Rd0E_ConfigC: return "ConfigC"; + case CMD_0011_1100_d16_Wr0F_ConfigD: return "ConfigD"; + case CMD_0011_1110_d16_Rd0F_ConfigD: return "ConfigD"; + case CMD_0100_0000_d16_Wr10_Reference: return "Reference"; + case CMD_0100_0010_d16_Rd10_Reference: return "Reference"; + case CMD_0100_0100_d16_Wr11_AGain: return "AGain"; + case CMD_0100_0110_d16_Rd11_AGain: return "AGain"; + case CMD_0100_1000_d16_Wr12_BGain: return "BGain"; + case CMD_0100_1010_d16_Rd12_BGain: return "BGain"; + case CMD_0100_1100_d16_Wr13_CGain: return "CGain"; + case CMD_0100_1110_d16_Rd13_CGain: return "CGain"; + case CMD_0101_0000_d16_Wr14_DGain: return "DGain"; + case CMD_0101_0010_d16_Rd14_DGain: return "DGain"; + case CMD_0101_0100_d8_Wr15_FilterCAddress: return "FilterCAddress"; + case CMD_0101_0110_d8_Rd15_FilterCAddress: return "FilterCAddress"; + case CMD_0101_1000_d32_Wr16_FilterCDataOut: return "FilterCDataOut"; + case CMD_0101_1010_d32_Rd16_FilterCDataOut: return "FilterCDataOut"; + case CMD_0101_1100_d32_Wr17_FilterCDataIn: return "FilterCDataIn"; + case CMD_0101_1110_d32_Rd17_FilterCDataIn: return "FilterCDataIn"; + case CMD_0110_0000_d8_Wr18_FlashMode: return "FlashMode"; + case CMD_0110_0010_d8_Rd18_FlashMode: return "FlashMode"; + case CMD_0110_0100_d16_Wr19_FlashAddr: return "FlashAddr"; + case CMD_0110_0110_d16_Rd19_FlashAddr: return "FlashAddr"; + case CMD_0110_1000_d16_Wr1A_FlashDataIn: return "FlashDataIn"; + case CMD_0110_1010_d16_Rd1A_FlashDataIn: return "FlashDataIn"; + case CMD_0110_1110_d16_Rd1B_FlashDataOut: return "FlashDataOut"; + } +} + + +// End of file +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MAX11043/MAX11043.h Tue Feb 11 01:16:34 2020 +0000 @@ -0,0 +1,832 @@ +// /******************************************************************************* +// * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved. +// * +// * Permission is hereby granted, free of charge, to any person obtaining a +// * copy of this software and associated documentation files (the "Software"), +// * to deal in the Software without restriction, including without limitation +// * the rights to use, copy, modify, merge, publish, distribute, sublicense, +// * and/or sell copies of the Software, and to permit persons to whom the +// * Software is furnished to do so, subject to the following conditions: +// * +// * The above copyright notice and this permission notice shall be included +// * in all copies or substantial portions of the Software. +// * +// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +// * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// * OTHER DEALINGS IN THE SOFTWARE. +// * +// * Except as contained in this notice, the name of Maxim Integrated +// * Products, Inc. shall not be used except as stated in the Maxim Integrated +// * Products, Inc. Branding Policy. +// * +// * The mere transfer of this software does not imply any licenses +// * of trade secrets, proprietary technology, copyrights, patents, +// * trademarks, maskwork rights, or any other form of intellectual +// * property whatsoever. Maxim Integrated Products, Inc. retains all +// * ownership rights. +// ******************************************************************************* +// */ +// ********************************************************************* +// @file MAX11043.h +// ********************************************************************* +// Header file +// DO NOT EDIT; except areas designated "CUSTOMIZE". Automatically generated file. +// generated by XMLSystemOfDevicesToMBED.py +// System Name = ExampleSystem +// System Description = Device driver example +// Device Name = MAX11043 +// Device Description = 200ksps, Low-Power, Serial SPI 24-Bit, 4-Channel, Differential/Single-Ended Input, Simultaneous-Sampling SD ADC +// Device DeviceBriefDescription = 24-bit 200ksps Delta-Sigma ADC +// Device Manufacturer = Maxim Integrated +// Device PartNumber = MAX11043ATL+ +// Device RegValue_Width = DataWidth16bit_HL +// +// ADC MaxOutputDataRate = 200ksps +// ADC NumChannels = 4 +// ADC ResolutionBits = 24 +// +// SPI CS = ActiveLow +// SPI FrameStart = CS +// SPI CPOL = 0 +// SPI CPHA = 0 +// SPI MOSI and MISO Data are both stable on Rising edge of SCLK +// SPI SCLK Idle Low +// SPI SCLKMaxMHz = 40 +// SPI SCLKMinMHz = 0 +// + + +// Prevent multiple declaration +#ifndef __MAX11043_H__ +#define __MAX11043_H__ + +// standard include for target platform -- Platform_Include_Boilerplate +#include "mbed.h" +// Platforms: +// - MAX32625MBED +// - supports mbed-os-5.11, requires USBDevice library +// - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - MAX32600MBED +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board. +// - NUCLEO_F446RE +// - remove USBDevice library +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - NUCLEO_F401RE +// - remove USBDevice library +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - MAX32630FTHR +// - #include "max32630fthr.h" +// - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/ +// - remove MAX32620FTHR library (if present) +// - MAX32620FTHR +// - #include "MAX32620FTHR.h" +// - remove max32630fthr library (if present) +// - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/ +// - not tested yet +// - MAX32625PICO +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - not tested yet +// +// end Platform_Include_Boilerplate + +// CODE GENERATOR: conditional defines +// CODE GENERATOR: class declaration and docstrings +/** + * @brief MAX11043 200ksps, Low-Power, Serial SPI 24-Bit, 4-Channel, Differential/Single-Ended Input, Simultaneous-Sampling SD ADC + * + * + * + * Datasheet: https://www.maximintegrated.com/MAX11043 + * + * + * + * //---------- CODE GENERATOR: helloCppCodeList + * @code + * // CODE GENERATOR: example code includes + * + * // example code includes + * // standard include for target platform -- Platform_Include_Boilerplate + * #include "mbed.h" + * // Platforms: + * // - MAX32625MBED + * // - supports mbed-os-5.11, requires USBDevice library + * // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ + * // - remove max32630fthr library (if present) + * // - remove MAX32620FTHR library (if present) + * // - MAX32600MBED + * // - remove max32630fthr library (if present) + * // - remove MAX32620FTHR library (if present) + * // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board. + * // - NUCLEO_F446RE + * // - remove USBDevice library + * // - remove max32630fthr library (if present) + * // - remove MAX32620FTHR library (if present) + * // - NUCLEO_F401RE + * // - remove USBDevice library + * // - remove max32630fthr library (if present) + * // - remove MAX32620FTHR library (if present) + * // - MAX32630FTHR + * // - #include "max32630fthr.h" + * // - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/ + * // - remove MAX32620FTHR library (if present) + * // - MAX32620FTHR + * // - #include "MAX32620FTHR.h" + * // - remove max32630fthr library (if present) + * // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/ + * // - not tested yet + * // - MAX32625PICO + * // - remove max32630fthr library (if present) + * // - remove MAX32620FTHR library (if present) + * // - not tested yet + * // + * // end Platform_Include_Boilerplate + * #include "MAX11043.h" + * + * // example code board support + * //MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); + * //DigitalOut rLED(LED1); + * //DigitalOut gLED(LED2); + * //DigitalOut bLED(LED3); + * // + * // Arduino "shield" connector port definitions (MAX32625MBED shown) + * #if defined(TARGET_MAX32625MBED) + * #define A0 AIN_0 + * #define A1 AIN_1 + * #define A2 AIN_2 + * #define A3 AIN_3 + * #define D0 P0_0 + * #define D1 P0_1 + * #define D2 P0_2 + * #define D3 P0_3 + * #define D4 P0_4 + * #define D5 P0_5 + * #define D6 P0_6 + * #define D7 P0_7 + * #define D8 P1_4 + * #define D9 P1_5 + * #define D10 P1_3 + * #define D11 P1_1 + * #define D12 P1_2 + * #define D13 P1_0 + * #endif + * + * // example code declare SPI interface + * #if defined(TARGET_MAX32625MBED) + * SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13 + * DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10 + * #elif defined(TARGET_MAX32600MBED) + * SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 + * DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10 + * #else + * SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 + * DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10 + * #endif + * + * // example code declare GPIO interface pins + * DigitalOut CONVRUN_pin(D9); // Digital Configuration Input to MAX11043 device + * DigitalOut SHDN_pin(D8); // Digital Configuration Input to MAX11043 device + * DigitalOut DACSTEP_pin(D7); // Digital Configuration Input to MAX11043 device + * DigitalOut UP_slash_DWNb_pin(D6); // Digital Configuration Input to MAX11043 device + * DigitalIn EOC_pin(D2); // Digital Event Output from MAX11043 device + * // example code declare device instance + * MAX11043 g_MAX11043_device(spi, spi_cs, CONVRUN_pin, SHDN_pin, DACSTEP_pin, UP_slash_DWNb_pin, EOC_pin, MAX11043::MAX11043_IC); + * + * // CODE GENERATOR: example code for ADC: serial port declaration + * //-------------------------------------------------- + * // Declare the Serial driver + * // default baud rate settings are 9600 8N1 + * // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe + * // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/ + * #if defined(TARGET_MAX32630) + * #include "USBSerial.h" + * // Hardware serial port over DAPLink + * // The default baud rate for the DapLink UART is 9600 + * //Serial DAPLINKserial(P2_1, P2_0); // tx, rx + * // #define HAS_DAPLINK_SERIAL 1 + * // Virtual serial port over USB + * // The baud rate does not affect the virtual USBSerial UART. + * USBSerial serial; + * //-------------------------------------------------- + * #elif defined(TARGET_MAX32625MBED) + * #include "USBSerial.h" + * // Hardware serial port over DAPLink + * // The default baud rate for the DapLink UART is 9600 + * //Serial DAPLINKserial(P2_1, P2_0); // tx, rx + * // #define HAS_DAPLINK_SERIAL 1 + * // Virtual serial port over USB + * // The baud rate does not affect the virtual USBSerial UART. + * USBSerial serial; + * //-------------------------------------------------- + * #elif defined(TARGET_MAX32600) + * #include "USBSerial.h" + * // Hardware serial port over DAPLink + * // The default baud rate for the DapLink UART is 9600 + * Serial DAPLINKserial(P1_1, P1_0); // tx, rx + * #define HAS_DAPLINK_SERIAL 1 + * // Virtual serial port over USB + * // The baud rate does not affect the virtual USBSerial UART. + * USBSerial serial; + * //-------------------------------------------------- + * #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) + * Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx + * //-------------------------------------------------- + * #else + * #if defined(SERIAL_TX) + * #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..." + * Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx + * #elif defined(USBTX) + * #warning "target not previously tested; guess serial pins are USBTX, USBRX..." + * Serial serial(USBTX, USBRX); // tx, rx + * #elif defined(UART_TX) + * #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..." + * Serial serial(UART_TX, UART_RX); // tx, rx + * #else + * #warning "target not previously tested; need to define serial pins..." + * #endif + * #endif + * // + * #include "CmdLine.h" + * CmdLine cmdLine(serial, "serial"); + * + * // example code main function + * int main() + * { + * // CODE GENERATOR: example code: member function Init + * g_MAX11043_device.Init(); + * + * while (1) + * { + * // CODE GENERATOR: example code: has no member function REF + * // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line + * // CODE GENERATOR: ResolutionBits = 24 + * // CODE GENERATOR: FScode = None + * // CODE GENERATOR: NumChannels = 4 + * while(1) { // this code repeats forever + * // this code repeats forever + * // CODE GENERATOR: example code: has no member function ScanStandardExternalClock + * // CODE GENERATOR: example code: has no member function ReadAINcode + * // wait(3.0); + * // CODE GENERATOR: print conversion result + * // Use Arduino Serial Plotter to view output: Tools | Serial Plotter + * cmdLine.serial().printf("%d", g_MAX11043_device.AINcode[0]); + * for (int index = 1; index <= channelId_0_3; index++) { + * cmdLine.serial().printf(",%d", g_MAX11043_device.AINcode[index]); + * } + * cmdLine.serial().printf("\r\n"); + * + * } // this code repeats forever + * } + * } + * @endcode + * //---------- CODE GENERATOR: end helloCppCodeList + */ +class MAX11043 { +public: +// CODE GENERATOR: TypedefEnum EnumItem declarations +// CODE GENERATOR: TypedefEnum MAX11043_CMD_enum_t + //---------------------------------------- + /// Register Addresses + /// + /// Naming convention is CMD_bitstream_WrAddr_FunctionName + /// - first byte format is 0aaa_aar0 + /// - 0 = bitstream required 0 bit + /// - aaa_aa = bitstream 5-bit register address field + /// - r = bitstream read/write bit (1=read, 0=write) + /// - WrAddr = Write operation to address Addr + /// - RdAddr = Read operation from address Addr + /// - d8 = 8-bit register data field + /// - d16 = 16-bit register data field + /// - d24 = 24-bit register data field + /// - d32 = 32-bit register data field + /// - x = don't care + typedef enum MAX11043_CMD_enum_t { + CMD_0aaa_aa00_WrAddr_WriteAnyRegister = 0x00, //!< 8'b00000000 + CMD_0000_0010_d24_Rd00_ADCa = 0x02, //!< 8'b00000010 + CMD_0000_0110_d24_Rd01_ADCb = 0x06, //!< 8'b00000110 + CMD_0000_1010_d24_Rd02_ADCc = 0x0a, //!< 8'b00001010 + CMD_0000_1110_d24_Rd03_ADCd = 0x0e, //!< 8'b00001110 + CMD_0001_0010_d24_d24_Rd04_ADCab = 0x12, //!< 8'b00010010 + CMD_0001_0110_d24_d24_Rd05_ADCcd = 0x16, //!< 8'b00010110 + CMD_0001_1010_d24_d24_d24_d24_Rd06_ADCabcd = 0x1a, //!< 8'b00011010 + CMD_0001_1110_d8_Rd07_Status = 0x1e, //!< 8'b00011110 + CMD_0010_0000_d16_Wr08_Configuration = 0x20, //!< 8'b00100000 + CMD_0010_0010_d16_Rd08_Configuration = 0x22, //!< 8'b00100010 + CMD_0010_0100_d16_Wr09_DAC = 0x24, //!< 8'b00100100 + CMD_0010_0110_d16_Rd09_DAC = 0x26, //!< 8'b00100110 + CMD_0010_1000_d16_Wr0A_DACStep = 0x28, //!< 8'b00101000 + CMD_0010_1010_d16_Rd0A_DACStep = 0x2a, //!< 8'b00101010 + CMD_0010_1100_d16_Wr0B_DACHDACL = 0x2c, //!< 8'b00101100 + CMD_0010_1110_d16_Rd0B_DACHDACL = 0x2e, //!< 8'b00101110 + CMD_0011_0000_d16_Wr0C_ConfigA = 0x30, //!< 8'b00110000 + CMD_0011_0010_d16_Rd0C_ConfigA = 0x32, //!< 8'b00110010 + CMD_0011_0100_d16_Wr0D_ConfigB = 0x34, //!< 8'b00110100 + CMD_0011_0110_d16_Rd0D_ConfigB = 0x36, //!< 8'b00110110 + CMD_0011_1000_d16_Wr0E_ConfigC = 0x38, //!< 8'b00111000 + CMD_0011_1010_d16_Rd0E_ConfigC = 0x3a, //!< 8'b00111010 + CMD_0011_1100_d16_Wr0F_ConfigD = 0x3c, //!< 8'b00111100 + CMD_0011_1110_d16_Rd0F_ConfigD = 0x3e, //!< 8'b00111110 + CMD_0100_0000_d16_Wr10_Reference = 0x40, //!< 8'b01000000 + CMD_0100_0010_d16_Rd10_Reference = 0x42, //!< 8'b01000010 + CMD_0100_0100_d16_Wr11_AGain = 0x44, //!< 8'b01000100 + CMD_0100_0110_d16_Rd11_AGain = 0x46, //!< 8'b01000110 + CMD_0100_1000_d16_Wr12_BGain = 0x48, //!< 8'b01001000 + CMD_0100_1010_d16_Rd12_BGain = 0x4a, //!< 8'b01001010 + CMD_0100_1100_d16_Wr13_CGain = 0x4c, //!< 8'b01001100 + CMD_0100_1110_d16_Rd13_CGain = 0x4e, //!< 8'b01001110 + CMD_0101_0000_d16_Wr14_DGain = 0x50, //!< 8'b01010000 + CMD_0101_0010_d16_Rd14_DGain = 0x52, //!< 8'b01010010 + CMD_0101_0100_d8_Wr15_FilterCAddress = 0x54, //!< 8'b01010100 + CMD_0101_0110_d8_Rd15_FilterCAddress = 0x56, //!< 8'b01010110 + CMD_0101_1000_d32_Wr16_FilterCDataOut = 0x58, //!< 8'b01011000 + CMD_0101_1010_d32_Rd16_FilterCDataOut = 0x5a, //!< 8'b01011010 + CMD_0101_1100_d32_Wr17_FilterCDataIn = 0x5c, //!< 8'b01011100 + CMD_0101_1110_d32_Rd17_FilterCDataIn = 0x5e, //!< 8'b01011110 + CMD_0110_0000_d8_Wr18_FlashMode = 0x60, //!< 8'b01100000 + CMD_0110_0010_d8_Rd18_FlashMode = 0x62, //!< 8'b01100010 + CMD_0110_0100_d16_Wr19_FlashAddr = 0x64, //!< 8'b01100100 + CMD_0110_0110_d16_Rd19_FlashAddr = 0x66, //!< 8'b01100110 + CMD_0110_1000_d16_Wr1A_FlashDataIn = 0x68, //!< 8'b01101000 + CMD_0110_1010_d16_Rd1A_FlashDataIn = 0x6a, //!< 8'b01101010 + CMD_0110_1110_d16_Rd1B_FlashDataOut = 0x6e, //!< 8'b01101110 + CMD_0aaa_aa10_RdAddr_ReadAnyRegister = 0x80, //!< 8'b10000000 + CMD_1111_1111_NoOperationMOSIidleHigh = 0xff, //!< 8'b11111111 + } MAX11043_CMD_enum_t; + +// CODE GENERATOR: TypedefEnum MAX11043_STATUS_enum_t + //---------------------------------------- + /// CMD_0001_1110_d8_Rd_Status + /// regAddr=07h + /// Status: x x FlashBusy BOOT OFLGA OFLGB OFLGC OFLGD + typedef enum MAX11043_STATUS_enum_t { + STATUS_xxxx_xxx1_OverflowFlagOFLGD = 0x01, //!< 8'b00000001 + STATUS_xxxx_xx1x_OverflowFlagOFLGC = 0x02, //!< 8'b00000010 + STATUS_xxxx_x1xx_OverflowFlagOFLGB = 0x04, //!< 8'b00000100 + STATUS_xxxx_1xxx_OverflowFlagOFLGA = 0x08, //!< 8'b00001000 + STATUS_xxx1_xxxx_PowerOnResetBOOT = 0x10, //!< 8'b00010000 + STATUS_xx1x_xxxx_FlashBusy = 0x20, //!< 8'b00100000 + STATUS_x1xx_xxxx_RESERVED = 0x40, //!< 8'b01000000 + STATUS_1xxx_xxxx_RESERVED = 0x80, //!< 8'b10000000 + } MAX11043_STATUS_enum_t; + +// CODE GENERATOR: TypedefEnum MAX11043_CONFIG_enum_t + //---------------------------------------- + /// CMD_0010_0000_d16_Wr_Configuration + /// regAddr=08h + /// Config: EXTCLK CLKDIV1 CLKDIV0 PD PDA PDB PDC PDD PDDAC PDOSC 24BIT SCHANA SCHANB SCHANC SCHAND DECSEL + typedef enum MAX11043_CONFIG_enum_t { + CONFIG_xxxx_xxxx_xxxx_xxx1_DECSEL12 = 0x0001, //!< 16'b0000000000000001 + CONFIG_xxxx_xxxx_xxxx_xx1x_SCHAND = 0x0002, //!< 16'b0000000000000010 + CONFIG_xxxx_xxxx_xxxx_x1xx_SCHANC = 0x0004, //!< 16'b0000000000000100 + CONFIG_xxxx_xxxx_xxxx_1xxx_SCHANB = 0x0008, //!< 16'b0000000000001000 + CONFIG_xxxx_xxxx_xxx1_xxxx_SCHANA = 0x0010, //!< 16'b0000000000010000 + CONFIG_xxxx_xxxx_xx1x_xxxx_24BIT = 0x0020, //!< 16'b0000000000100000 + CONFIG_xxxx_xxxx_x1xx_xxxx_PDOSC = 0x0040, //!< 16'b0000000001000000 + CONFIG_xxxx_xxxx_1xxx_xxxx_PDDAC = 0x0080, //!< 16'b0000000010000000 + CONFIG_xxxx_xxx1_xxxx_xxxx_PDD = 0x0100, //!< 16'b0000000100000000 + CONFIG_xxxx_xx1x_xxxx_xxxx_PDC = 0x0200, //!< 16'b0000001000000000 + CONFIG_xxxx_x1xx_xxxx_xxxx_PDB = 0x0400, //!< 16'b0000010000000000 + CONFIG_xxxx_1xxx_xxxx_xxxx_PDA = 0x0800, //!< 16'b0000100000000000 + CONFIG_xxx1_xxxx_xxxx_xxxx_PD = 0x1000, //!< 16'b0001000000000000 + CONFIG_xx1x_xxxx_xxxx_xxxx_CLKDIV0 = 0x2000, //!< 16'b0010000000000000 + CONFIG_x1xx_xxxx_xxxx_xxxx_CLKDIV1 = 0x4000, //!< 16'b0100000000000000 + CONFIG_1xxx_xxxx_xxxx_xxxx_EXTCLK = 0x8000, //!< 16'b1000000000000000 + } MAX11043_CONFIG_enum_t; + +// CODE GENERATOR: TypedefEnum MAX11043_CONFIGABCD_enum_t + //---------------------------------------- + /// CMD_0011_0000_d16_Wr_CONFIGa + /// CMD_0011_0100_d16_Wr_CONFIGb + /// CMD_0011_1000_d16_Wr_CONFIGc + /// CMD_0011_1100_d16_Wr_CONFIGd + /// regAddr=0Ch + /// regAddr=0Dh + /// regAddr=0Eh + /// regAddr=0Fh + /// ConfigABCD: x x x BDAC[3:0] DIFF EQ MODG[1:0] PDPGA FILT PGAG ENBIASP ENBIASN + typedef enum MAX11043_CONFIGABCD_enum_t { + CONFIGABCD_xxxx_xxxx_xxxx_xxx1_ENBIASN = 0x0001, //!< 16'b0000000000000001 + CONFIGABCD_xxxx_xxxx_xxxx_xx1x_ENBIASP = 0x0002, //!< 16'b0000000000000010 + CONFIGABCD_xxxx_xxxx_xxxx_x1xx_PGAG16 = 0x0004, //!< 16'b0000000000000100 + CONFIGABCD_xxxx_xxxx_xxxx_1xxx_FILTLP = 0x0008, //!< 16'b0000000000001000 + CONFIGABCD_xxxx_xxxx_xxx1_xxxx_PDPGA = 0x0010, //!< 16'b0000000000010000 + CONFIGABCD_xxxx_xxxx_xx1x_xxxx_MODG0 = 0x0020, //!< 16'b0000000000100000 + CONFIGABCD_xxxx_xxxx_x1xx_xxxx_MODG1 = 0x0040, //!< 16'b0000000001000000 + CONFIGABCD_xxxx_xxxx_1xxx_xxxx_EQ = 0x0080, //!< 16'b0000000010000000 + CONFIGABCD_xxxx_xxx1_xxxx_xxxx_DIFF = 0x0100, //!< 16'b0000000100000000 + CONFIGABCD_xxxx_xx1x_xxxx_xxxx_BDAC0 = 0x0200, //!< 16'b0000001000000000 + CONFIGABCD_xxxx_x1xx_xxxx_xxxx_BDAC1 = 0x0400, //!< 16'b0000010000000000 + CONFIGABCD_xxxx_1xxx_xxxx_xxxx_BDAC2 = 0x0800, //!< 16'b0000100000000000 + CONFIGABCD_xxx1_xxxx_xxxx_xxxx_BDAC3 = 0x1000, //!< 16'b0001000000000000 + CONFIGABCD_xx1x_xxxx_xxxx_xxxx_RESERVED = 0x2000, //!< 16'b0010000000000000 + CONFIGABCD_x1xx_xxxx_xxxx_xxxx_RESERVED = 0x4000, //!< 16'b0100000000000000 + CONFIGABCD_1xxx_xxxx_xxxx_xxxx_RESERVED = 0x8000, //!< 16'b1000000000000000 + } MAX11043_CONFIGABCD_enum_t; + +// CODE GENERATOR: TypedefEnum MAX11043_BDAC_enum_t + //---------------------------------------- + /// CMD_0011_0000_d16_Wr_CONFIGa + /// CMD_0011_0100_d16_Wr_CONFIGb + /// CMD_0011_1000_d16_Wr_CONFIGc + /// CMD_0011_1100_d16_Wr_CONFIGd + /// CONFIGABCD_xxx1_xxxx_xxxx_xxxx_BDAC3 + /// CONFIGABCD_xxxx_1xxx_xxxx_xxxx_BDAC2 + /// CONFIGABCD_xxxx_x1xx_xxxx_xxxx_BDAC1 + /// CONFIGABCD_xxxx_xx1x_xxxx_xxxx_BDAC0 + /// Sets the input bias voltage for AC-coupled signals when ENBIAS_ is set to 1. + /// regAddr=0Ch + /// regAddr=0Dh + /// regAddr=0Eh + /// regAddr=0Fh + /// ConfigABCD: x x x BDAC[3:0] DIFF EQ MODG[1:0] PDPGA FILT PGAG ENBIASP ENBIASN + typedef enum MAX11043_BDAC_enum_t { + BDAC_0000_033pctAVDD = 0x00, //!< 8'b00000000 + BDAC_0001_035pctAVDD = 0x01, //!< 8'b00000001 + BDAC_0010_038pctAVDD = 0x02, //!< 8'b00000010 + BDAC_0011_040pctAVDD = 0x03, //!< 8'b00000011 + BDAC_0100_042pctAVDD = 0x04, //!< 8'b00000100 + BDAC_0101_044pctAVDD = 0x05, //!< 8'b00000101 + BDAC_0110_046pctAVDD = 0x06, //!< 8'b00000110 + BDAC_0111_048pctAVDD = 0x07, //!< 8'b00000111 + BDAC_1000_050pctAVDD = 0x08, //!< 8'b00001000 + BDAC_1001_052pctAVDD = 0x09, //!< 8'b00001001 + BDAC_1010_054pctAVDD = 0x0a, //!< 8'b00001010 + BDAC_1011_056pctAVDD = 0x0b, //!< 8'b00001011 + BDAC_1100_058pctAVDD = 0x0c, //!< 8'b00001100 + BDAC_1101_060pctAVDD = 0x0d, //!< 8'b00001101 + BDAC_1110_062pctAVDD = 0x0e, //!< 8'b00001110 + BDAC_1111_065pctAVDD = 0x0f, //!< 8'b00001111 + } MAX11043_BDAC_enum_t; + +// CODE GENERATOR: TypedefEnum MAX11043_REFERENCE_enum_t + //---------------------------------------- + /// CMD_0100_0000_d16_Wr_Reference + /// regAddr=10h + /// ReferenceDelay: 0 0 0 PURGE[4:0] EXTREF EXBUFA EXBUFB EXBUFC EXBUFD EXBUFDAC EXBUFDACH EXBUFDACL + typedef enum MAX11043_REFERENCE_enum_t { + REFERENCE_xxxx_xxxx_xxxx_xxx1_EXBUFDACL = 0x0001, //!< 16'b0000000000000001 + REFERENCE_xxxx_xxxx_xxxx_xx1x_EXBUFDACH = 0x0002, //!< 16'b0000000000000010 + REFERENCE_xxxx_xxxx_xxxx_x1xx_EXBUFDAC = 0x0004, //!< 16'b0000000000000100 + REFERENCE_xxxx_xxxx_xxxx_1xxx_EXBUFD = 0x0008, //!< 16'b0000000000001000 + REFERENCE_xxxx_xxxx_xxx1_xxxx_EXBUFC = 0x0010, //!< 16'b0000000000010000 + REFERENCE_xxxx_xxxx_xx1x_xxxx_EXBUFB = 0x0020, //!< 16'b0000000000100000 + REFERENCE_xxxx_xxxx_x1xx_xxxx_EXBUFA = 0x0040, //!< 16'b0000000001000000 + REFERENCE_xxxx_xxxx_1xxx_xxxx_EXTREF = 0x0080, //!< 16'b0000000010000000 + REFERENCE_xxxx_xxx1_xxxx_xxxx_PURGE0 = 0x0100, //!< 16'b0000000100000000 + REFERENCE_xxxx_xx1x_xxxx_xxxx_PURGE1 = 0x0200, //!< 16'b0000001000000000 + REFERENCE_xxxx_x1xx_xxxx_xxxx_PURGE2 = 0x0400, //!< 16'b0000010000000000 + REFERENCE_xxxx_1xxx_xxxx_xxxx_PURGE3 = 0x0800, //!< 16'b0000100000000000 + REFERENCE_xxx1_xxxx_xxxx_xxxx_PURGE4 = 0x1000, //!< 16'b0001000000000000 + REFERENCE_xx1x_xxxx_xxxx_xxxx_RESERVED = 0x2000, //!< 16'b0010000000000000 + REFERENCE_x1xx_xxxx_xxxx_xxxx_RESERVED = 0x4000, //!< 16'b0100000000000000 + REFERENCE_1xxx_xxxx_xxxx_xxxx_RESERVED = 0x8000, //!< 16'b1000000000000000 + } MAX11043_REFERENCE_enum_t; + +// TODO1: CODE GENERATOR: ic_variant -- IC's supported with this driver + /** + * @brief IC's supported with this driver + * @details MAX11043 + */ + typedef enum + { + MAX11043_IC = 0, + //MAX11043_IC = 1 + } MAX11043_ic_t; + +// TODO1: CODE GENERATOR: class constructor declaration + /**********************************************************//** + * @brief Constructor for MAX11043 Class. + * + * @details Requires an existing SPI object as well as a DigitalOut object. + * The DigitalOut object is used for a chip enable signal + * + * On Entry: + * @param[in] spi - pointer to existing SPI object + * @param[in] cs_pin - pointer to a DigitalOut pin object + * CODE GENERATOR: class constructor docstrings gpio InputPin pins + * @param[in] CONVRUN_pin - pointer to a DigitalOut pin object + * @param[in] SHDN_pin - pointer to a DigitalOut pin object + * @param[in] DACSTEP_pin - pointer to a DigitalOut pin object + * @param[in] UP_slash_DWNb_pin - pointer to a DigitalOut pin object + * CODE GENERATOR: class constructor docstrings gpio OutputPin pins + * @param[in] EOC_pin - pointer to a DigitalIn pin object + * @param[in] ic_variant - which type of MAX11043 is used + * + * On Exit: + * + * @return None + **************************************************************/ + MAX11043(SPI &spi, DigitalOut &cs_pin, // SPI interface + // CODE GENERATOR: class constructor declaration gpio InputPin pins + DigitalOut &CONVRUN_pin, // Digital Configuration Input to MAX11043 device + DigitalOut &SHDN_pin, // Digital Configuration Input to MAX11043 device + DigitalOut &DACSTEP_pin, // Digital Configuration Input to MAX11043 device + DigitalOut &UP_slash_DWNb_pin, // Digital Configuration Input to MAX11043 device + // CODE GENERATOR: class constructor declaration gpio OutputPin pins + DigitalIn &EOC_pin, // Digital Event Output from MAX11043 device + MAX11043_ic_t ic_variant); + +// CODE GENERATOR: class destructor declaration + /************************************************************ + * @brief Default destructor for MAX11043 Class. + * + * @details Destroys SPI object if owner + * + * On Entry: + * + * On Exit: + * + * @return None + **************************************************************/ + ~MAX11043(); + + // CODE GENERATOR: Declare SPI diagnostic function pointer void onSPIprint() + /// Function pointer void f(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]) + Callback<void(size_t, uint8_t*, uint8_t*)> onSPIprint; //!< optional @ref onSPIprint SPI diagnostic function + + // CODE GENERATOR: spi_frequency setter declaration + /// set SPI SCLK frequency + void spi_frequency(int spi_sclk_Hz); + + // CODE GENERATOR: spi_frequency getter declaration and definition + /// get SPI SCLK frequency + int get_spi_frequency() const { return m_SPI_SCLK_Hz; } + + // CODE GENERATOR: spi_dataMode getter declaration and definition + /// get SPI mode + int get_spi_dataMode() const { return m_SPI_dataMode; } + +//---------------------------------------- +// CODE GENERATOR: omit typedef enum MAX11043_device_t, class members instead of global device object +public: + + /// TODO1: AC79 MAX11043 AIN0-AIN1 reference voltage, in Volts + double VRef_xxxxxx; + + /// TODO1: AC79 MAX11043 shadow of register ctrl CMD_r000_1001_dddd_dddd_CTRL + uint32_t ctrl; + + /// TODO1: AC79 MAX11043 read-only pga gain 1, 2, 4, 8, 16, 32, 64, or 128 set by Configure_PGA gain index register pga CMD_r000_1110_xxdd_xddd_PGA + uint8_t pgaGain; + + /// TODO1: AC79 MAX11043 shadow of register status CMD_r011_1000_dddd_dddd_dddd_dddd_dxxx_dddd_STATUS + uint32_t status; + + /// TODO1: AC79 MAX11043 shadow of register data0 CMD_r011_0000_dddd_dddd_dddd_dddd_dddd_dddd_DATA0 + uint32_t data0; + + /// TODO1: AC79 MAX11043 Each channel's most recent value in LSBs. + /// Updated by Measure_Voltage function. + /// Use VoltageOfCode function to convert LSBs to physical voltage. + /// (Valid index range AINP_SEL_0000_AIN0 to AINP_SEL_1010_AVDD) + /// + uint32_t AINcode[11]; + +// CODE GENERATOR: omit global g_MAX11043_device + +// CODE GENERATOR: extern function declarations +// CODE GENERATOR: extern function declaration SPIoutputCS +//---------------------------------------- +// Assert SPI Chip Select +// SPI chip-select for MAX11043 +// + void SPIoutputCS(int isLogicHigh); + +// CODE GENERATOR: extern function declaration SPIwrite16bits +//---------------------------------------- +// SPI write 16 bits +// SPI interface to MAX11043 shift 16 bits mosiData into MAX11043 DIN +// + void SPIwrite16bits(int16_t mosiData16); + +// CODE GENERATOR: extern function declaration SPIreadWrite16bits +//---------------------------------------- +// SPI read and write 16 bits +// SPI interface to MAX11043 shift 16 bits mosiData16 into MAX11043 DIN +// while simultaneously capturing 16 bits miso data from MAX11043 DOUT +// + int16_t SPIreadWrite16bits(int16_t mosiData16); + +// CODE GENERATOR: extern function declaration SPIreadWrite32bits +//---------------------------------------- +// SPI read and write 32 bits +// SPI interface to MAX11043 shift 32 bits mosiData into MAX11043 DIN +// while simultaneously capturing 32 bits miso data from MAX11043 DOUT +// + int32_t SPIreadWrite32bits(int32_t mosiData32); + +// CODE GENERATOR: extern function declaration SHDNoutputValue +//---------------------------------------- +// Assert MAX11043 SHDN pin : High = _____, Low = _____. +// + void SHDNoutputValue(int isLogicHigh); + +// CODE GENERATOR: extern function declaration CONVRUNoutputValue +//---------------------------------------- +// Assert MAX11043 CONVRUN pin : High = _____, Low = _____. +// + void CONVRUNoutputValue(int isLogicHigh); + +// CODE GENERATOR: extern function declaration DACSTEPoutputValue +//---------------------------------------- +// Assert MAX11043 DACSTEP pin : High = _____, Low = _____. +// + void DACSTEPoutputValue(int isLogicHigh); + +// CODE GENERATOR: extern function declaration UP_slash_DWNboutputValue +//---------------------------------------- +// Assert MAX11043 UP_slash_DWNb pin : High = _____, Low = _____. +// + void UP_slash_DWNboutputValue(int isLogicHigh); + +// CODE GENERATOR: extern function declaration EOCinputWaitUntilLow +//---------------------------------------- +// Wait for MAX11043 EOC pin low, indicating end of conversion. +// Required when using any of the InternalClock modes. +// + void EOCinputWaitUntilLow(); + +// CODE GENERATOR: extern function declaration EOCinputValue +//---------------------------------------- +// Return the status of the MAX11043 EOC pin. +// + int EOCinputValue(); + +// CODE GENERATOR: class member data +private: +// CODE GENERATOR: class member data for SPI interface + // SPI object + SPI &m_spi; + int m_SPI_SCLK_Hz; + int m_SPI_dataMode; + int m_SPI_cs_state; + + // Selector pin object + DigitalOut &m_cs_pin; + +// CODE GENERATOR: class member data for gpio InputPin pins +// InputPin Name = CONVRUN +// InputPin Description = CONVRUN (digital input). Convert Run. Drive high to start continuous conversions on all 4 channels. The device is idle when +// CONVRUN is low. +// InputPin Function = Configuration + DigitalOut &m_CONVRUN_pin; +// +// InputPin Name = SHDN +// InputPin Description = Shutdown (digital input). Active-High Shutdown Input. Drive high to shut down the MAX11043. +// InputPin Function = Configuration + DigitalOut &m_SHDN_pin; +// +// InputPin Name = DACSTEP +// InputPin Description = DACSTEP (digital input). DAC Step Input. Drive high to move the DAC output in the direction of UP/DWN on the next rising +// edge of the system clock. +// InputPin Function = Configuration + DigitalOut &m_DACSTEP_pin; +// +// InputPin Name = UP/DWN# +// InputPin Description = UP/DWN# (digital input). DAC Step Direction Select. Drive high to step up, drive low to step down when DACSTEP is toggled. +// InputPin Function = Configuration + DigitalOut &m_UP_slash_DWNb_pin; +// +// CODE GENERATOR: class member data for gpio OutputPin pins +// OutputPin Name = EOC +// OutputPin Description = End of Conversion Output. Active-Low End-of-Conversion Indicator. EOC asserts low to indicate that new data is ready. +// OutputPin Function = Event + DigitalIn &m_EOC_pin; +// + + // Identifies which IC variant is being used + MAX11043_ic_t m_ic_variant; + +public: + +// CODE GENERATOR: class member function declarations + //---------------------------------------- + /// Menu item '!' + /// Initialize device + /// @return 1 on success; 0 on failure + uint8_t Init(void); + +// CODE GENERATOR: looks like this is a register access function because 'regAdd' +// CODE GENERATOR: looks like this is a 'write' register access function +// CODE GENERATOR: looks like this is a register access function because 'regAdd' +// CODE GENERATOR: looks like this is a 'write' register access function: omit this function from test menu + //---------------------------------------- + /// Write a MAX11043 register. + /// + /// CMD_1aaa_aaaa_REGISTER_READ bit is cleared 0 indicating a write operation. + /// + /// MAX11043 register length can be determined by function RegSize. + /// + /// For 8-bit register size: + /// + /// SPI 16-bit transfer + /// + /// SPI MOSI = 0aaa_aaaa_dddd_dddd + /// + /// SPI MISO = xxxx_xxxx_xxxx_xxxx + /// + /// For 16-bit register size: + /// + /// SPI 24-bit or 32-bit transfer + /// + /// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd + /// + /// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx + /// + /// For 24-bit register size: + /// + /// SPI 32-bit transfer + /// + /// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd_dddd_dddd + /// + /// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx + /// + /// @return 1 on success; 0 on failure + uint8_t RegWrite(MAX11043_CMD_enum_t commandByte, uint32_t regData); + +// CODE GENERATOR: looks like this is a register access function because 'regAdd' +// CODE GENERATOR: looks like this is a 'read' register access function +// CODE GENERATOR: looks like this is a register access function because 'regAdd' +// CODE GENERATOR: looks like this is a 'read' register access function: omit this function from test menu + //---------------------------------------- + /// Read an 8-bit MAX11043 register + /// + /// CMD_1aaa_aaaa_REGISTER_READ bit is set 1 indicating a read operation. + /// + /// MAX11043 register length can be determined by function RegSize. + /// + /// For 8-bit register size: + /// + /// SPI 16-bit transfer + /// + /// SPI MOSI = 1aaa_aaaa_0000_0000 + /// + /// SPI MISO = xxxx_xxxx_dddd_dddd + /// + /// For 16-bit register size: + /// + /// SPI 24-bit or 32-bit transfer + /// + /// SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000 + /// + /// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd + /// + /// For 24-bit register size: + /// + /// SPI 32-bit transfer + /// + /// SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000_0000_0000 + /// + /// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd_dddd_dddd + /// + /// + /// @return 1 on success; 0 on failure + uint8_t RegRead(MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData); + +// CODE GENERATOR: looks like this is a register access function because 'regAdd' +// CODE GENERATOR: looks like this is a 'size' register access function + //---------------------------------------- + /// Return the size of a MAX11043 register + /// + /// @return 8 for 8-bit, 16 for 16-bit, 24 for 24-bit, else 0 for undefined register size + uint8_t RegSize(MAX11043_CMD_enum_t commandByte); + +// CODE GENERATOR: looks like this is a register access function because 'regAdd' + //---------------------------------------- + /// Return the address field of a MAX11043 register + /// + /// @return register address field as given in datasheet + uint8_t RegAddrOfCommand(MAX11043_CMD_enum_t commandByte); + +// CODE GENERATOR: looks like this is a register access function because 'regAdd' +// CODE GENERATOR: looks like this is a 'read' register access function + //---------------------------------------- + /// Test whether a command byte is a register read command + /// + /// @return true if command byte is a register read command + uint8_t IsRegReadCommand(MAX11043_CMD_enum_t commandByte); + +// CODE GENERATOR: looks like this is a register access function because 'regAdd' +// CODE GENERATOR: looks like this is a 'name' register access function + //---------------------------------------- + /// Return the name of a MAX11043 register + /// + /// @return null-terminated constant C string containing register name or empty string + const char* RegName(MAX11043_CMD_enum_t commandByte); + +}; // end of class MAX11043 + +#endif // __MAX11043_H__ + +// End of file +
--- a/MAX11410.lib Wed Jan 22 07:57:46 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/teams/MaximIntegrated/code/MAX11410/#3a9dfa2e8234
--- a/MaximTinyTester.lib Wed Jan 22 07:57:46 2020 +0000 +++ b/MaximTinyTester.lib Tue Feb 11 01:16:34 2020 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/whismanoid/code/MaximTinyTester/#63d97c7be309 +https://os.mbed.com/users/whismanoid/code/MaximTinyTester/#67a1cd5a67cc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Test_Main_MAX11043.cpp Tue Feb 11 01:16:34 2020 +0000 @@ -0,0 +1,2165 @@ +// /******************************************************************************* +// * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved. +// * +// * Permission is hereby granted, free of charge, to any person obtaining a +// * copy of this software and associated documentation files (the "Software"), +// * to deal in the Software without restriction, including without limitation +// * the rights to use, copy, modify, merge, publish, distribute, sublicense, +// * and/or sell copies of the Software, and to permit persons to whom the +// * Software is furnished to do so, subject to the following conditions: +// * +// * The above copyright notice and this permission notice shall be included +// * in all copies or substantial portions of the Software. +// * +// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +// * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// * OTHER DEALINGS IN THE SOFTWARE. +// * +// * Except as contained in this notice, the name of Maxim Integrated +// * Products, Inc. shall not be used except as stated in the Maxim Integrated +// * Products, Inc. Branding Policy. +// * +// * The mere transfer of this software does not imply any licenses +// * of trade secrets, proprietary technology, copyrights, patents, +// * trademarks, maskwork rights, or any other form of intellectual +// * property whatsoever. Maxim Integrated Products, Inc. retains all +// * ownership rights. +// ******************************************************************************* +// */ +//---------- CODE GENERATOR: testMainCppCodeList +// CODE GENERATOR: example code includes + +// example code includes +// standard include for target platform -- Platform_Include_Boilerplate +#include "mbed.h" +// Platforms: +// - MAX32625MBED +// - supports mbed-os-5.11, requires USBDevice library +// - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - MAX32600MBED +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board. +// - NUCLEO_F446RE +// - remove USBDevice library +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - NUCLEO_F401RE +// - remove USBDevice library +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - MAX32630FTHR +// - #include "max32630fthr.h" +// - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/ +// - remove MAX32620FTHR library (if present) +// - MAX32620FTHR +// - #include "MAX32620FTHR.h" +// - remove max32630fthr library (if present) +// - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/ +// - not tested yet +// - MAX32625PICO +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - not tested yet +// +// end Platform_Include_Boilerplate +#include "MAX11043.h" +#include "CmdLine.h" +#include "MaximTinyTester.h" + +// optional: serial port +// note: some platforms such as Nucleo-F446RE do not support the USBSerial library. +// In those cases, remove the USBDevice lib from the project and rebuild. +#if defined(TARGET_MAX32625MBED) +#include "USBSerial.h" +USBSerial serial; // virtual serial port over USB (DEV connector) +#elif defined(TARGET_MAX32630MBED) +#include "USBSerial.h" +USBSerial serial; // virtual serial port over USB (DEV connector) +#else +//#include "USBSerial.h" +Serial serial(USBTX, USBRX); // tx, rx +#endif + +void on_immediate_0x21(); // Unicode (U+0021) ! EXCLAMATION MARK +void on_immediate_0x7b(); // Unicode (U+007B) { LEFT CURLY BRACKET +void on_immediate_0x7d(); // Unicode (U+007D) } RIGHT CURLY BRACKET + +#include "CmdLine.h" + +# if HAS_DAPLINK_SERIAL +CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK"); +# endif // HAS_DAPLINK_SERIAL +CmdLine cmdLine_serial(serial, "serial"); + + +//-------------------------------------------------- + + +#if defined(TARGET) +// TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h +// Create a string definition for the TARGET +#define STRING_ARG(arg) #arg +#define STRING_NAME(name) STRING_ARG(name) +#define TARGET_NAME STRING_NAME(TARGET) +#elif defined(TARGET_MAX32600) +#define TARGET_NAME "MAX32600" +#elif defined(TARGET_LPC1768) +#define TARGET_NAME "LPC1768" +#elif defined(TARGET_NUCLEO_F446RE) +#define TARGET_NAME "NUCLEO_F446RE" +#elif defined(TARGET_NUCLEO_F401RE) +#define TARGET_NAME "NUCLEO_F401RE" +#else +#error TARGET NOT DEFINED +#endif +#if defined(TARGET_MAX32630) +//-------------------------------------------------- +// TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM +// +-------------[microUSB]-------------+ +// | J1 MAX32630FTHR J2 | +// ______ | [ ] RST GND [ ] | +// ______ | [ ] 3V3 BAT+[ ] | +// ______ | [ ] 1V8 reset SW1 | +// ______ | [ ] GND J4 J3 | +// analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+ +// analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn +// analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power +// analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9 +// (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8 +// (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7 +// D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6 +// D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5 +// D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4 +// D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3 +// D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2 +// ______ | [ ] GND SDA P3_4 [d] | D8 dig1 +// | | +// | XIP Flash MAX14690N | +// | XIP_SCLK P1_0 SDA2 P5_7 | +// | XIP_MOSI P1_1 SCL2 P6_0 | +// | XIP_MISO P1_2 PMIC_INIT P3_7 | +// | XIP_SSEL P1_3 MPC P2_7 | +// | XIP_DIO2 P1_4 MON AIN_0 | +// | XIP_DIO3 P1_5 | +// | | +// | PAN1326B MicroSD LED | +// | BT_RX P0_0 SD_SCLK P0_4 r P2_4 | +// | BT_TX P0_1 SD_MOSI P0_5 g P2_5 | +// | BT_CTS P0_2 SD_MISO P0_6 b P2_6 | +// | BT_RTS P0_3 SD_SSEL P0_7 | +// | BT_RST P1_6 DETECT P2_2 | +// | BT_CLK P1_7 SW2 P2_3 | +// +------------------------------------+ +// 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). +// 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). +// AIN_0 = AIN0 pin fullscale is 1.2V +// AIN_1 = AIN1 pin fullscale is 1.2V +// AIN_2 = AIN2 pin fullscale is 1.2V +// AIN_3 = AIN3 pin fullscale is 1.2V +// AIN_4 = AIN0 / 5.0 fullscale is 6.0V +// AIN_5 = AIN1 / 5.0 fullscale is 6.0V +// AIN_6 = VDDB / 4.0 fullscale is 4.8V +// AIN_7 = VDD18 fullscale is 1.2V +// AIN_8 = VDD12 fullscale is 1.2V +// AIN_9 = VRTC / 2.0 fullscale is 2.4V +// AIN_10 = x undefined? +// AIN_11 = VDDIO / 4.0 fullscale is 4.8V +// AIN_12 = VDDIOH / 4.0 fullscale is 4.8V +// + #include "max32630fthr.h" +MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); +#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 +// MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15 +const float ADC_FULL_SCALE_VOLTAGE = 1.200; +// Arduino connector +#ifndef A0 +#define A0 AIN_0 +#endif +#ifndef A1 +#define A1 AIN_1 +#endif +#ifndef A2 +#define A2 AIN_2 +#endif +#ifndef A3 +#define A3 AIN_3 +#endif +#ifndef D0 +#define D0 P4_0 +#endif +#ifndef D1 +#define D1 P5_6 +#endif +#ifndef D2 +#define D2 P5_5 +#endif +#ifndef D3 +#define D3 P5_4 +#endif +#ifndef D4 +#define D4 P5_3 +#endif +#ifndef D5 +#define D5 P3_3 +#endif +#ifndef D6 +#define D6 P3_2 +#endif +#ifndef D7 +#define D7 P3_5 +#endif +#ifndef D8 +#define D8 P3_4 +#endif +#ifndef D9 +#define D9 P3_1 +#endif +#ifndef D10 +#define D10 P3_0 +#endif +#ifndef D11 +#define D11 P5_1 +#endif +#ifndef D12 +#define D12 P5_2 +#endif +#ifndef D13 +#define D13 P5_0 +#endif +//-------------------------------------------------- +#elif defined(TARGET_MAX32625MBED) +//-------------------------------------------------- +// TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM +// +-------------------------------------+ +// | MAX32625MBED Arduino UNO header | +// | | +// | A5/SCL[ ] | P1_7 dig15 +// | A4/SDA[ ] | P1_6 dig14 +// | AREF=N/C[ ] | +// | GND[ ] | +// | [ ]N/C SCK/13[ ] | P1_0 dig13 +// | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12 +// | [ ]RST MOSI/11[ ]~| P1_1 dig11 +// | [ ]3V3 CS/10[ ]~| P1_3 dig10 +// | [ ]5V0 9[ ]~| P1_5 dig9 +// | [ ]GND 8[ ] | P1_4 dig8 +// | [ ]GND | +// | [ ]Vin 7[ ] | P0_7 dig7 +// | 6[ ]~| P0_6 dig6 +// AIN_0 | [ ]A0 5[ ]~| P0_5 dig5 +// AIN_1 | [ ]A1 4[ ] | P0_4 dig4 +// AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3 +// AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2 +// dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1 +// dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0 +// | [ ] [ ] [ ] | +// | UNO_R3 GND MOSI 5V ____________/ +// \_______________________/ +// +// +------------------------+ +// | | +// | MicroSD LED | +// | SD_SCLK P2_4 r P3_0 | +// | SD_MOSI P2_5 g P3_1 | +// | SD_MISO P2_6 b P3_2 | +// | SD_SSEL P2_7 y P3_3 | +// | | +// | DAPLINK BUTTONS | +// | TX P2_1 SW3 P2_3 | +// | RX P2_0 SW2 P2_2 | +// +------------------------+ +// +// AIN_0 = AIN0 pin fullscale is 1.2V +// AIN_1 = AIN1 pin fullscale is 1.2V +// AIN_2 = AIN2 pin fullscale is 1.2V +// AIN_3 = AIN3 pin fullscale is 1.2V +// AIN_4 = AIN0 / 5.0 fullscale is 6.0V +// AIN_5 = AIN1 / 5.0 fullscale is 6.0V +// AIN_6 = VDDB / 4.0 fullscale is 4.8V +// AIN_7 = VDD18 fullscale is 1.2V +// AIN_8 = VDD12 fullscale is 1.2V +// AIN_9 = VRTC / 2.0 fullscale is 2.4V +// AIN_10 = x undefined? +// AIN_11 = VDDIO / 4.0 fullscale is 4.8V +// AIN_12 = VDDIOH / 4.0 fullscale is 4.8V +// +//#include "max32625mbed.h" // ? +//MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ? +#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 +// MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15 +const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico? +// Arduino connector +#ifndef A0 +#define A0 AIN_0 +#endif +#ifndef A1 +#define A1 AIN_1 +#endif +#ifndef A2 +#define A2 AIN_2 +#endif +#ifndef A3 +#define A3 AIN_3 +#endif +#ifndef D0 +#define D0 P0_0 +#endif +#ifndef D1 +#define D1 P0_1 +#endif +#ifndef D2 +#define D2 P0_2 +#endif +#ifndef D3 +#define D3 P0_3 +#endif +#ifndef D4 +#define D4 P0_4 +#endif +#ifndef D5 +#define D5 P0_5 +#endif +#ifndef D6 +#define D6 P0_6 +#endif +#ifndef D7 +#define D7 P0_7 +#endif +#ifndef D8 +#define D8 P1_4 +#endif +#ifndef D9 +#define D9 P1_5 +#endif +#ifndef D10 +#define D10 P1_3 +#endif +#ifndef D11 +#define D11 P1_1 +#endif +#ifndef D12 +#define D12 P1_2 +#endif +#ifndef D13 +#define D13 P1_0 +#endif +//-------------------------------------------------- +#elif defined(TARGET_MAX32600) +// target MAX32600 +// +#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 +const float ADC_FULL_SCALE_VOLTAGE = 1.500; +// +//-------------------------------------------------- +#elif defined(TARGET_MAX32620FTHR) +#warning "TARGET_MAX32620FTHR not previously tested; need to define pins..." +#include "MAX32620FTHR.h" +// Initialize I/O voltages on MAX32620FTHR board +MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3); +//#define USE_LEDS 0 ? +#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 +#warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..." +const float ADC_FULL_SCALE_VOLTAGE = 1.200; +// +//-------------------------------------------------- +#elif defined(TARGET_MAX32625PICO) +#warning "TARGET_MAX32625PICO not previously tested; need to define pins..." +//#define USE_LEDS 0 ? +#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 +#warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..." +const float ADC_FULL_SCALE_VOLTAGE = 1.200; +// +//-------------------------------------------------- +#elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) +// TODO1: target NUCLEO_F446RE +// +// USER_BUTTON PC13 +// LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1. +#define USE_LEDS 0 +// SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); +// Serial serial(SERIAL_TX, SERIAL_RX); +#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 +const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico? +// +//-------------------------------------------------- +#elif defined(TARGET_LPC1768) +//-------------------------------------------------- +// TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM +// +-------------[microUSB]-------------+ +// ______ | [ ] GND +3.3V VOUT [ ] | ______ +// ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______ +// ______ | [ ] VB USB.IF- [ ] | ______ +// ______ | [ ] nR USB.IF+ [ ] | ______ +// digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______ +// digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______ +// digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______ +// digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______ +// digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______ +// digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______ +// digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13 +// digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12 +// digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11 +// digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10 +// analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1 +// analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2 +// analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3 +// analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4 +// analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5 +// analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6 +// +------------------------------------+ +// AIN6 = P0.3 = TGT_SBL_RXD? +// AIN7 = P0.2 = TGT_SBL_TXD? +// +//-------------------------------------------------- +// LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14 +#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 +const float ADC_FULL_SCALE_VOLTAGE = 3.300; +#else // not defined(TARGET_LPC1768 etc.) +//-------------------------------------------------- +// unknown target +//-------------------------------------------------- +#endif // target definition + + + +// uncrustify-0.66.1 *INDENT-OFF* +//-------------------------------------------------- +// Declare the AnalogIn driver +// Optional analogIn support. If there is only one it should be analogIn1. +// A) analog input +#if defined(TARGET_MAX32630) + #define HAS_analogIn0 1 + #define HAS_analogIn1 1 + #define HAS_analogIn2 1 + #define HAS_analogIn3 1 + #define HAS_analogIn4 1 + #define HAS_analogIn5 1 + #define HAS_analogIn6 1 + #define HAS_analogIn7 1 + #define HAS_analogIn8 1 + #define HAS_analogIn9 1 +// #define HAS_analogIn10 0 +// #define HAS_analogIn11 0 +// #define HAS_analogIn12 0 +// #define HAS_analogIn13 0 +// #define HAS_analogIn14 0 +// #define HAS_analogIn15 0 +#if HAS_analogIn0 + AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V +#endif +#if HAS_analogIn1 + AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V +#endif +#if HAS_analogIn2 + AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V +#endif +#if HAS_analogIn3 + AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V +#endif +#if HAS_analogIn4 + AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V +#endif +#if HAS_analogIn5 + AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V +#endif +#if HAS_analogIn6 + AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V +#endif +#if HAS_analogIn7 + AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V +#endif +#if HAS_analogIn8 + AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V +#endif +#if HAS_analogIn9 + AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V +#endif +#if HAS_analogIn10 + AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined? +#endif +#if HAS_analogIn11 + AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V +#endif +#if HAS_analogIn12 + AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V +#endif +#if HAS_analogIn13 + AnalogIn analogIn13(____); +#endif +#if HAS_analogIn14 + AnalogIn analogIn14(____); +#endif +#if HAS_analogIn15 + AnalogIn analogIn15(____); +#endif +//-------------------------------------------------- +#elif defined(TARGET_MAX32625MBED) + #define HAS_analogIn0 1 + #define HAS_analogIn1 1 + #define HAS_analogIn2 1 + #define HAS_analogIn3 1 + #define HAS_analogIn4 1 + #define HAS_analogIn5 1 +#if HAS_analogIn0 + AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V +#endif +#if HAS_analogIn1 + AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V +#endif +#if HAS_analogIn2 + AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V +#endif +#if HAS_analogIn3 + AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V +#endif +#if HAS_analogIn4 + AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V +#endif +#if HAS_analogIn5 + AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V +#endif +//-------------------------------------------------- +#elif defined(TARGET_MAX32620FTHR) +#warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..." + #define HAS_analogIn0 1 + #define HAS_analogIn1 1 + #define HAS_analogIn2 1 + #define HAS_analogIn3 1 + #define HAS_analogIn4 1 + #define HAS_analogIn5 1 + #define HAS_analogIn6 1 + #define HAS_analogIn7 1 + #define HAS_analogIn8 1 + #define HAS_analogIn9 1 +// #define HAS_analogIn10 0 +// #define HAS_analogIn11 0 +// #define HAS_analogIn12 0 +// #define HAS_analogIn13 0 +// #define HAS_analogIn14 0 +// #define HAS_analogIn15 0 +#if HAS_analogIn0 + AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V +#endif +#if HAS_analogIn1 + AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V +#endif +#if HAS_analogIn2 + AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V +#endif +#if HAS_analogIn3 + AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V +#endif +#if HAS_analogIn4 + AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V +#endif +#if HAS_analogIn5 + AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V +#endif +#if HAS_analogIn6 + AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V +#endif +#if HAS_analogIn7 + AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V +#endif +#if HAS_analogIn8 + AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V +#endif +#if HAS_analogIn9 + AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V +#endif +#if HAS_analogIn10 + AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined? +#endif +#if HAS_analogIn11 + AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V +#endif +#if HAS_analogIn12 + AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V +#endif +#if HAS_analogIn13 + AnalogIn analogIn13(____); +#endif +#if HAS_analogIn14 + AnalogIn analogIn14(____); +#endif +#if HAS_analogIn15 + AnalogIn analogIn15(____); +#endif +//-------------------------------------------------- +#elif defined(TARGET_MAX32625PICO) +#warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..." + #define HAS_analogIn0 1 + #define HAS_analogIn1 1 + #define HAS_analogIn2 1 + #define HAS_analogIn3 1 + #define HAS_analogIn4 1 + #define HAS_analogIn5 1 +#if HAS_analogIn0 + AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V +#endif +#if HAS_analogIn1 + AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V +#endif +#if HAS_analogIn2 + AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V +#endif +#if HAS_analogIn3 + AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V +#endif +#if HAS_analogIn4 + AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V +#endif +#if HAS_analogIn5 + AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V +#endif +//-------------------------------------------------- +#elif defined(TARGET_MAX32600) + #define HAS_analogIn0 1 + #define HAS_analogIn1 1 + #define HAS_analogIn2 1 + #define HAS_analogIn3 1 + #define HAS_analogIn4 1 + #define HAS_analogIn5 1 +#if HAS_analogIn0 + AnalogIn analogIn0(A0); +#endif +#if HAS_analogIn1 + AnalogIn analogIn1(A1); +#endif +#if HAS_analogIn2 + AnalogIn analogIn2(A2); +#endif +#if HAS_analogIn3 + AnalogIn analogIn3(A3); +#endif +#if HAS_analogIn4 + AnalogIn analogIn4(A4); +#endif +#if HAS_analogIn5 + AnalogIn analogIn5(A5); +#endif +//-------------------------------------------------- +#elif defined(TARGET_NUCLEO_F446RE) + #define HAS_analogIn0 1 + #define HAS_analogIn1 1 + #define HAS_analogIn2 1 + #define HAS_analogIn3 1 + #define HAS_analogIn4 1 + #define HAS_analogIn5 1 +#if HAS_analogIn0 + AnalogIn analogIn0(A0); +#endif +#if HAS_analogIn1 + AnalogIn analogIn1(A1); +#endif +#if HAS_analogIn2 + AnalogIn analogIn2(A2); +#endif +#if HAS_analogIn3 + AnalogIn analogIn3(A3); +#endif +#if HAS_analogIn4 + AnalogIn analogIn4(A4); +#endif +#if HAS_analogIn5 + AnalogIn analogIn5(A5); +#endif +//-------------------------------------------------- +#elif defined(TARGET_NUCLEO_F401RE) + #define HAS_analogIn0 1 + #define HAS_analogIn1 1 + #define HAS_analogIn2 1 + #define HAS_analogIn3 1 + #define HAS_analogIn4 1 + #define HAS_analogIn5 1 +#if HAS_analogIn0 + AnalogIn analogIn0(A0); +#endif +#if HAS_analogIn1 + AnalogIn analogIn1(A1); +#endif +#if HAS_analogIn2 + AnalogIn analogIn2(A2); +#endif +#if HAS_analogIn3 + AnalogIn analogIn3(A3); +#endif +#if HAS_analogIn4 + AnalogIn analogIn4(A4); +#endif +#if HAS_analogIn5 + AnalogIn analogIn5(A5); +#endif +//-------------------------------------------------- +// TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM +#elif defined(TARGET_LPC1768) + #define HAS_analogIn0 1 + #define HAS_analogIn1 1 + #define HAS_analogIn2 1 + #define HAS_analogIn3 1 + #define HAS_analogIn4 1 + #define HAS_analogIn5 1 +// #define HAS_analogIn6 1 +// #define HAS_analogIn7 1 +// #define HAS_analogIn8 1 +// #define HAS_analogIn9 1 +// #define HAS_analogIn10 1 +// #define HAS_analogIn11 1 +// #define HAS_analogIn12 1 +// #define HAS_analogIn13 1 +// #define HAS_analogIn14 1 +// #define HAS_analogIn15 1 +#if HAS_analogIn0 + AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0 +#endif +#if HAS_analogIn1 + AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1 +#endif +#if HAS_analogIn2 + AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3 +#endif +#if HAS_analogIn3 + AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3 +#endif +#if HAS_analogIn4 + AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4 +#endif +#if HAS_analogIn5 + AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5 +#endif +#if HAS_analogIn6 + AnalogIn analogIn6(____); +#endif +#if HAS_analogIn7 + AnalogIn analogIn7(____); +#endif +#if HAS_analogIn8 + AnalogIn analogIn8(____); +#endif +#if HAS_analogIn9 + AnalogIn analogIn9(____); +#endif +#if HAS_analogIn10 + AnalogIn analogIn10(____); +#endif +#if HAS_analogIn11 + AnalogIn analogIn11(____); +#endif +#if HAS_analogIn12 + AnalogIn analogIn12(____); +#endif +#if HAS_analogIn13 + AnalogIn analogIn13(____); +#endif +#if HAS_analogIn14 + AnalogIn analogIn14(____); +#endif +#if HAS_analogIn15 + AnalogIn analogIn15(____); +#endif +#else + // unknown target +#endif +// uncrustify-0.66.1 *INDENT-ON* +#if HAS_analogIn0 || HAS_analogIn1 \ + || HAS_analogIn2 || HAS_analogIn3 \ + || HAS_analogIn4 || HAS_analogIn5 \ + || HAS_analogIn6 || HAS_analogIn7 \ + || HAS_analogIn8 || HAS_analogIn9 \ + || HAS_analogIn10 || HAS_analogIn11 \ + || HAS_analogIn12 || HAS_analogIn13 \ + || HAS_analogIn14 || HAS_analogIn15 +#define HAS_analogIns 1 +#endif + + + +// AnalogIn pin resource: search index +#if HAS_analogIns +AnalogIn& find_analogInPin(int cPinIndex) +{ + switch (cPinIndex) + { + default: // default to the first defined analogIn pin +#if HAS_analogIn0 + case '0': case 0x00: return analogIn0; +#endif +#if HAS_analogIn1 + case '1': case 0x01: return analogIn1; +#endif +#if HAS_analogIn2 + case '2': case 0x02: return analogIn2; +#endif +#if HAS_analogIn3 + case '3': case 0x03: return analogIn3; +#endif +#if HAS_analogIn4 + case '4': case 0x04: return analogIn4; +#endif +#if HAS_analogIn5 + case '5': case 0x05: return analogIn5; +#endif +#if HAS_analogIn6 + case '6': case 0x06: return analogIn6; +#endif +#if HAS_analogIn7 + case '7': case 0x07: return analogIn7; +#endif +#if HAS_analogIn8 + case '8': case 0x08: return analogIn8; +#endif +#if HAS_analogIn9 + case '9': case 0x09: return analogIn9; +#endif +#if HAS_analogIn10 + case 'a': case 0x0a: return analogIn10; +#endif +#if HAS_analogIn11 + case 'b': case 0x0b: return analogIn11; +#endif +#if HAS_analogIn12 + case 'c': case 0x0c: return analogIn12; +#endif +#if HAS_analogIn13 + case 'd': case 0x0d: return analogIn13; +#endif +#if HAS_analogIn14 + case 'e': case 0x0e: return analogIn14; +#endif +#if HAS_analogIn15 + case 'f': case 0x0f: return analogIn15; +#endif + } +} +#endif + +#if HAS_analogIns +const float analogInPin_fullScaleVoltage[] = { +# if defined(TARGET_MAX32630) + ADC_FULL_SCALE_VOLTAGE, // analogIn0 + ADC_FULL_SCALE_VOLTAGE, // analogIn1 + ADC_FULL_SCALE_VOLTAGE, // analogIn2 + ADC_FULL_SCALE_VOLTAGE, // analogIn3 + ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V + ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V + ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V + ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V + ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V + ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V + ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined? + ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V + ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V + ADC_FULL_SCALE_VOLTAGE, // analogIn13 + ADC_FULL_SCALE_VOLTAGE, // analogIn14 + ADC_FULL_SCALE_VOLTAGE // analogIn15 +# elif defined(TARGET_MAX32620FTHR) +#warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..." + ADC_FULL_SCALE_VOLTAGE, // analogIn0 + ADC_FULL_SCALE_VOLTAGE, // analogIn1 + ADC_FULL_SCALE_VOLTAGE, // analogIn2 + ADC_FULL_SCALE_VOLTAGE, // analogIn3 + ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V + ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V + ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V + ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V + ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V + ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V + ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined? + ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V + ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V + ADC_FULL_SCALE_VOLTAGE, // analogIn13 + ADC_FULL_SCALE_VOLTAGE, // analogIn14 + ADC_FULL_SCALE_VOLTAGE // analogIn15 +#elif defined(TARGET_MAX32625MBED) + ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V + ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V + ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V + ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V + ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V + ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V + ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V + ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V + ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V + ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V + ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined? + ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V + ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V + ADC_FULL_SCALE_VOLTAGE, // analogIn13 + ADC_FULL_SCALE_VOLTAGE, // analogIn14 + ADC_FULL_SCALE_VOLTAGE // analogIn15 +#elif defined(TARGET_NUCLEO_F446RE) + ADC_FULL_SCALE_VOLTAGE, // analogIn0 + ADC_FULL_SCALE_VOLTAGE, // analogIn1 + ADC_FULL_SCALE_VOLTAGE, // analogIn2 + ADC_FULL_SCALE_VOLTAGE, // analogIn3 + ADC_FULL_SCALE_VOLTAGE, // analogIn4 + ADC_FULL_SCALE_VOLTAGE, // analogIn5 + ADC_FULL_SCALE_VOLTAGE, // analogIn6 + ADC_FULL_SCALE_VOLTAGE, // analogIn7 + ADC_FULL_SCALE_VOLTAGE, // analogIn8 + ADC_FULL_SCALE_VOLTAGE, // analogIn9 + ADC_FULL_SCALE_VOLTAGE, // analogIn10 + ADC_FULL_SCALE_VOLTAGE, // analogIn11 + ADC_FULL_SCALE_VOLTAGE, // analogIn12 + ADC_FULL_SCALE_VOLTAGE, // analogIn13 + ADC_FULL_SCALE_VOLTAGE, // analogIn14 + ADC_FULL_SCALE_VOLTAGE // analogIn15 +#elif defined(TARGET_NUCLEO_F401RE) + ADC_FULL_SCALE_VOLTAGE, // analogIn0 + ADC_FULL_SCALE_VOLTAGE, // analogIn1 + ADC_FULL_SCALE_VOLTAGE, // analogIn2 + ADC_FULL_SCALE_VOLTAGE, // analogIn3 + ADC_FULL_SCALE_VOLTAGE, // analogIn4 + ADC_FULL_SCALE_VOLTAGE, // analogIn5 + ADC_FULL_SCALE_VOLTAGE, // analogIn6 + ADC_FULL_SCALE_VOLTAGE, // analogIn7 + ADC_FULL_SCALE_VOLTAGE, // analogIn8 + ADC_FULL_SCALE_VOLTAGE, // analogIn9 + ADC_FULL_SCALE_VOLTAGE, // analogIn10 + ADC_FULL_SCALE_VOLTAGE, // analogIn11 + ADC_FULL_SCALE_VOLTAGE, // analogIn12 + ADC_FULL_SCALE_VOLTAGE, // analogIn13 + ADC_FULL_SCALE_VOLTAGE, // analogIn14 + ADC_FULL_SCALE_VOLTAGE // analogIn15 +//#elif defined(TARGET_LPC1768) +#else + // unknown target + ADC_FULL_SCALE_VOLTAGE, // analogIn0 + ADC_FULL_SCALE_VOLTAGE, // analogIn1 + ADC_FULL_SCALE_VOLTAGE, // analogIn2 + ADC_FULL_SCALE_VOLTAGE, // analogIn3 + ADC_FULL_SCALE_VOLTAGE, // analogIn4 + ADC_FULL_SCALE_VOLTAGE, // analogIn5 + ADC_FULL_SCALE_VOLTAGE, // analogIn6 + ADC_FULL_SCALE_VOLTAGE, // analogIn7 + ADC_FULL_SCALE_VOLTAGE, // analogIn8 + ADC_FULL_SCALE_VOLTAGE, // analogIn9 + ADC_FULL_SCALE_VOLTAGE, // analogIn10 + ADC_FULL_SCALE_VOLTAGE, // analogIn11 + ADC_FULL_SCALE_VOLTAGE, // analogIn12 + ADC_FULL_SCALE_VOLTAGE, // analogIn13 + ADC_FULL_SCALE_VOLTAGE, // analogIn14 + ADC_FULL_SCALE_VOLTAGE // analogIn15 +# endif +}; +#endif + + + + +//-------------------------------------------------- +// Option to use LEDs to show status +#ifndef USE_LEDS +#define USE_LEDS 1 +#endif +#if USE_LEDS +#if defined(TARGET_MAX32630) +# define LED_ON 0 +# define LED_OFF 1 +//-------------------------------------------------- +#elif defined(TARGET_MAX32625MBED) +# define LED_ON 0 +# define LED_OFF 1 +//-------------------------------------------------- +// TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM +#elif defined(TARGET_LPC1768) +# define LED_ON 1 +# define LED_OFF 0 +#else // not defined(TARGET_LPC1768 etc.) +// USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768 +// bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined +# ifndef LED_ON +# define LED_ON 0 +# endif +# ifndef LED_OFF +# define LED_OFF 1 +# endif +//# define LED_ON 1 +//# define LED_OFF 0 +#endif // target definition +DigitalOut led1(LED1, LED_OFF); // MAX32630FTHR: LED1 = LED_RED +DigitalOut led2(LED2, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN +DigitalOut led3(LED3, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE +DigitalOut led4(LED4, LED_OFF); +#else // USE_LEDS=0 +// issue #41 support Nucleo_F446RE +// there are no LED indicators on the board, LED1 interferes with SPI; +// but we still need placeholders led1 led2 led3 led4. +// Declare DigitalOut led1 led2 led3 led4 targeting safe pins. +// PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false +# define LED_ON 0 +# define LED_OFF 1 +DigitalOut led1(NC, LED_OFF); +DigitalOut led2(NC, LED_OFF); +DigitalOut led3(NC, LED_OFF); +DigitalOut led4(NC, LED_OFF); +#endif // USE_LEDS +#define led1_RFailLED led1 +#define led2_GPassLED led2 +#define led3_BBusyLED led3 + +//-------------------------------------------------- + + +// example code board support +//MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); +//DigitalOut rLED(LED1); +//DigitalOut gLED(LED2); +//DigitalOut bLED(LED3); +// +// Arduino "shield" connector port definitions (MAX32625MBED shown) +#if defined(TARGET_MAX32625MBED) +#define A0 AIN_0 +#define A1 AIN_1 +#define A2 AIN_2 +#define A3 AIN_3 +#define D0 P0_0 +#define D1 P0_1 +#define D2 P0_2 +#define D3 P0_3 +#define D4 P0_4 +#define D5 P0_5 +#define D6 P0_6 +#define D7 P0_7 +#define D8 P1_4 +#define D9 P1_5 +#define D10 P1_3 +#define D11 P1_1 +#define D12 P1_2 +#define D13 P1_0 +#endif + +// example code declare SPI interface +#if defined(TARGET_MAX32625MBED) +SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13 +DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10 +#elif defined(TARGET_MAX32600MBED) +SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 +DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10 +#else +SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 +DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10 +#endif + +// example code declare GPIO interface pins +DigitalOut CONVRUN_pin(D9); // Digital Configuration Input to MAX11043 device +DigitalOut SHDN_pin(D8); // Digital Configuration Input to MAX11043 device +DigitalOut DACSTEP_pin(D7); // Digital Configuration Input to MAX11043 device +DigitalOut UP_slash_DWNb_pin(D6); // Digital Configuration Input to MAX11043 device +DigitalIn EOC_pin(D2); // Digital Event Output from MAX11043 device +// example code declare device instance +MAX11043 g_MAX11043_device(spi, spi_cs, CONVRUN_pin, SHDN_pin, DACSTEP_pin, UP_slash_DWNb_pin, EOC_pin, MAX11043::MAX11043_IC); + + +//---------------------------------------- +// Global SPI options +// + +//---------------------------------------- +// Global I2C options +// + +#define APPLICATION_ArduinoPinsMonitor 1 + +//-------------------------------------------------- +// use BUTTON1 trigger some action +#if defined(TARGET_MAX32630) +#define HAS_BUTTON1_DEMO_INTERRUPT 1 +#define HAS_BUTTON2_DEMO 0 +#define HAS_BUTTON2_DEMO_INTERRUPT 0 +#elif defined(TARGET_MAX32625PICO) +#warning "TARGET_MAX32625PICO not previously tested; need to define buttons..." +#define HAS_BUTTON1_DEMO_INTERRUPT 1 +#define HAS_BUTTON2_DEMO 0 +#define HAS_BUTTON2_DEMO_INTERRUPT 0 +#elif defined(TARGET_MAX32625) +#define HAS_BUTTON1_DEMO_INTERRUPT 1 +#define HAS_BUTTON2_DEMO_INTERRUPT 1 +#elif defined(TARGET_MAX32620FTHR) +#warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..." +#define BUTTON1 SW1 +#define HAS_BUTTON1_DEMO_INTERRUPT 1 +#define HAS_BUTTON2_DEMO 0 +#define HAS_BUTTON2_DEMO_INTERRUPT 0 +#elif defined(TARGET_NUCLEO_F446RE) +#define HAS_BUTTON1_DEMO_INTERRUPT 0 +#define HAS_BUTTON2_DEMO_INTERRUPT 0 +#elif defined(TARGET_NUCLEO_F401RE) +#define HAS_BUTTON1_DEMO_INTERRUPT 0 +#define HAS_BUTTON2_DEMO_INTERRUPT 0 +#else +#warning "target not previously tested; need to define buttons..." +#endif +// +#ifndef HAS_BUTTON1_DEMO +#define HAS_BUTTON1_DEMO 0 +#endif +#ifndef HAS_BUTTON2_DEMO +#define HAS_BUTTON2_DEMO 0 +#endif +// +// avoid runtime error on button1 press [mbed-os-5.11] +// instead of using InterruptIn, use DigitalIn and poll in main while(1) +#ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING +#define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1 +#endif +// +#ifndef HAS_BUTTON1_DEMO_INTERRUPT +#define HAS_BUTTON1_DEMO_INTERRUPT 1 +#endif +#ifndef HAS_BUTTON2_DEMO_INTERRUPT +#define HAS_BUTTON2_DEMO_INTERRUPT 1 +#endif +// +#if HAS_BUTTON1_DEMO_INTERRUPT +# if HAS_BUTTON1_DEMO_INTERRUPT_POLLING +// avoid runtime error on button1 press [mbed-os-5.11] +// instead of using InterruptIn, use DigitalIn and poll in main while(1) +DigitalIn button1(BUTTON1); +# else +InterruptIn button1(BUTTON1); +# endif +#elif HAS_BUTTON1_DEMO +DigitalIn button1(BUTTON1); +#endif +#if HAS_BUTTON2_DEMO_INTERRUPT +# if HAS_BUTTON1_DEMO_INTERRUPT_POLLING +// avoid runtime error on button1 press [mbed-os-5.11] +// instead of using InterruptIn, use DigitalIn and poll in main while(1) +DigitalIn button2(BUTTON2); +# else +InterruptIn button2(BUTTON2); +# endif +#elif HAS_BUTTON2_DEMO +DigitalIn button2(BUTTON2); +#endif + +//-------------------------------------------------- +// When user presses button BUTTON1, perform self test +#if HAS_BUTTON1_DEMO_INTERRUPT +void onButton1FallingEdge(void) +{ + void SelfTest(CmdLine & cmdLine); + SelfTest(cmdLine_serial); +} +#endif // HAS_BUTTON1_DEMO_INTERRUPT + +//-------------------------------------------------- +// When user presses button BUTTON2, perform demo configuration +#if HAS_BUTTON2_DEMO_INTERRUPT +void onButton2FallingEdge(void) +{ + // TBD demo configuration + // TODO diagnostic LED +} +#endif // HAS_BUTTON2_DEMO_INTERRUPT + +//-------------------------------------------------- +void SelfTest(CmdLine & cmdLine) +{ + //-------------------------------------------------- +#if analogIn4_IS_HIGH_RANGE_OF_analogIn0 + // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. + MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4, led1_RFailLED, led2_GPassLED, led3_BBusyLED); + tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support + tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support + tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support + tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support + tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support + tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support + // low range channels AIN0, AIN1, AIN2, AIN3 +#else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 + // Platform board uses simple analog inputs + MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5, led1_RFailLED, led2_GPassLED, led3_BBusyLED); + tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support + tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support + tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support + tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support + tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support + tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support +#endif + tinyTester.clear(); + + // CODE GENERATOR: generate SelfTest based on function docstrings @test lines + + // +#if INJECT_SELFTEST_FAIL + // Test of the pass/fail report mechanism + tinyTester.FAIL(); + cmdLine.serial().print(F("injecting one false failure for test reporting")); +#endif + // + // Report number of pass and number of fail test results + tinyTester.Report_Summary(); +} + + +//-------------------------------------------------- +inline void print_command_prompt() +{ + cmdLine_serial.serial().printf("\r\n> "); + +} + + +//-------------------------------------------------- +void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine) +{ + // % diagnostic commands submenu + // %Hpin -- digital output high + // %Lpin -- digital output low + // %?pin -- digital input + // %A %Apin -- analog input + // %Ppin df=xx -- pwm output + // %Wpin -- measure high pulsewidth input in usec + // %wpin -- measure low pulsewidth input in usec + // %I... -- I2C diagnostics + // %IP -- I2C probe + // %IC scl=100khz ADDR=? -- I2C configure + // %IW byte byte ... byte RD=? ADDR=0x -- write + // %IR ADDR=? RD=? -- read + // %I^ cmd=? -- i2c_smbus_read_word_data + // %S... -- SPI diagnostics + // %SC sclk=1Mhz -- SPI configure + // %SW -- write (write and read) + // %SR -- read (alias for %SW because SPI always write and read) + // A-Z,a-z,0-9 reserved for application use + // + char strPinIndex[3]; + strPinIndex[0] = cmdLine[2]; + strPinIndex[1] = cmdLine[3]; + strPinIndex[2] = '\0'; + int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value + //cmdLine.serial().printf(" pinIndex=%d ", pinIndex); + // + // get next character + switch (cmdLine[1]) + { +#if HAS_digitalInOuts + case 'H': case 'h': + { + // %Hpin -- digital output high +#if ARDUINO_STYLE + pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 + digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 +#else + DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); + digitalInOutPin.output(); + digitalInOutPin.write(1); +#endif + cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex); + } + break; + case 'L': case 'l': + { + // %Lpin -- digital output low +#if ARDUINO_STYLE + pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 + digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 +#else + DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); + digitalInOutPin.output(); + digitalInOutPin.write(0); +#endif + cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex); + } + break; + case '?': + { + // %?pin -- digital input +#if ARDUINO_STYLE + pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 +#else + DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); + digitalInOutPin.input(); +#endif + serial.printf(" digitalInOutPin %d Input ", pinIndex); +#if ARDUINO_STYLE + int value = digitalRead(pinIndex); +#else + int value = digitalInOutPin.read(); +#endif + cmdLine.serial().printf("%d ", value); + } + break; +#endif + // +#if HAS_analogIns + case 'A': case 'a': + { + // %A %Apin -- analog input +#if analogIn4_IS_HIGH_RANGE_OF_analogIn0 + // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. + for (int pinIndex = 0; pinIndex < 2; pinIndex++) + { + int cPinIndex = '0' + pinIndex; + AnalogIn& analogInPin = find_analogInPin(cPinIndex); + float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; + float normValue_0_1 = analogInPin.read(); + // + int pinIndexH = pinIndex + 4; + int cPinIndexH = '0' + pinIndexH; + AnalogIn& analogInPinH = find_analogInPin(cPinIndexH); + float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH]; + float normValueH_0_1 = analogInPinH.read(); + // + cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV \r\n", + cPinIndex, + normValue_0_1 * 100.0, + normValue_0_1 * adc_full_scale_voltage, + cPinIndexH, + normValueH_0_1 * 100.0, + normValueH_0_1 * adc_full_scale_voltageH + ); + } + for (int pinIndex = 2; pinIndex < 4; pinIndex++) + { + int cPinIndex = '0' + pinIndex; + AnalogIn& analogInPin = find_analogInPin(cPinIndex); + float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; + float normValue_0_1 = analogInPin.read(); + // + cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n", + cPinIndex, + normValue_0_1 * 100.0, + normValue_0_1 * adc_full_scale_voltage + ); + } +#else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 + // Platform board uses simple analog inputs + // assume standard Arduino analog inputs A0-A5 + for (int pinIndex = 0; pinIndex < 6; pinIndex++) + { + int cPinIndex = '0' + pinIndex; + AnalogIn& analogInPin = find_analogInPin(cPinIndex); + float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; + float normValue_0_1 = analogInPin.read(); + // + cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n", + cPinIndex, + normValue_0_1 * 100.0, + normValue_0_1 * adc_full_scale_voltage + ); + } +#endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0 + } + break; +#endif + // +#if HAS_SPI2_MAX541 + case 'D': case 'd': + { + // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV) + // MAX541 max541(spi2_max541, spi2_max541_cs); + float voltageV = max541.Get_Voltage(); + // if (cmdLine[2] == '+') { + // // %D+ + // voltageV = voltageV * 1.25f; + // if (voltageV >= max541.VRef) voltageV = max541.VRef; + // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); + // } + // else if (cmdLine[2] == '-') { + // // %D- + // voltageV = voltageV * 0.75f; + // if (voltageV < 0.1f) voltageV = 0.1f; + // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); + // } + if (cmdLine.parse_float("V", voltageV)) + { + // %D V=1.234 -- set voltage + max541.Set_Voltage(voltageV); + } + else if (cmdLine.parse_float("TEST", voltageV)) + { + // %D TEST=1.234 -- set voltage and compare with AIN0 + SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); + } + else if (cmdLine.parse_float("CAL", voltageV)) + { + // %D CAL=1.234 -- calibrate VRef and compare with AIN0 + + max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale + double max541_midscale_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V + const int average_count = 100; + const double average_K = 0.25; + for (int count = 0; count < average_count; count++) { + double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V + max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V); + } + max541.VRef = 2.0 * max541_midscale_V; + cmdLine.serial().printf( + "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV", + max541_midscale_V, max541.VRef); + // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4 + voltageV = 1.0f; + SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); + } + else { + // %D -- print MAX541 DAC status + cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n", + max541.Get_Code(), max541.Get_Voltage(), max541.VRef); + } + } + break; +#endif + + // +#if HAS_I2C // SUPPORT_I2C + case 'I': case 'i': + // %I... -- I2C diagnostics + // %IP -- I2C probe + // %IC scl=100khz ADDR=? -- I2C configure + // %IW byte byte ... byte RD=? ADDR=0x -- write + // %IR ADDR=? RD=? -- read + // %I^ cmd=? -- i2c_smbus_read_word_data + // get next character + // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7 + cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7); + // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count + g_I2C_read_count = 0; // read count must be reset every command + cmdLine.parse_byte_dec("RD", g_I2C_read_count); + // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress + cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress); + switch (cmdLine[2]) + { + case 'P': case 'p': + { + // %IP -- I2C probe + HuntAttachedI2CDevices(cmdLine, 0x03, 0x77); + } + break; + case 'C': case 'c': + { + bool isUpdatedI2CConfig = false; + // %IC scl=100khz ADDR=? -- I2C configure + // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz + if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz)) + { + isUpdatedI2CConfig = true; + // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU + if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz) + { + g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz; + } + if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz) + { + g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz; + } + } + if (isUpdatedI2CConfig) + { + // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) + I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header + i2cMaster.frequency(g_I2C_SCL_Hz); + i2cMaster.start(); + i2cMaster.stop(); + i2cMaster.frequency(g_I2C_SCL_Hz); + cmdLine.serial().printf( + "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config", + g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz, + (g_I2C_SCL_Hz / 1000.)); + i2cMaster.start(); + i2cMaster.stop(); + } + } + break; + case 'W': case 'w': + { + // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) + I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header + i2cMaster.frequency(g_I2C_SCL_Hz); + // %IW byte byte ... byte RD=? ADDR=0x -- write + // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; + #define MAX_I2C_BYTE_COUNT 32 + size_t byteCount = byteCount; + static char mosiData[MAX_I2C_BYTE_COUNT]; + static char misoData[MAX_I2C_BYTE_COUNT]; + if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, + MAX_I2C_BYTE_COUNT)) + { + // hex dump mosiData[0..byteCount-1] + cmdLine.serial().printf( + "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->", + g_I2C_deviceAddress7, + (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count); + for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) + { + cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]); + } + // + // TODO: i2c transfer + //const int addr7bit = 0x48; // 7 bit I2C address + //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 + // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. + // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. + // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. + // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. + // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. + // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. + // /* 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... + // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... + const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90 + unsigned int misoLength = 0; + bool repeated = (g_I2C_read_count > 0); + // + int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated); + switch (writeStatus) + { + case 0: cmdLine.serial().printf(" ack "); break; + case 1: cmdLine.serial().printf(" nack "); break; + default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ", + writeStatus); + } + if (repeated) + { + int readStatus = + i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false); + switch (readStatus) + { + case 1: cmdLine.serial().printf(" nack "); break; + case 0: cmdLine.serial().printf(" ack "); break; + default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ", + readStatus); + } + } + // + if (misoLength > 0) + { + // hex dump misoData[0..byteCount-1] + cmdLine.serial().printf(" MISO<-"); + for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count; + byteIndex++) + { + cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]); + } + } + cmdLine.serial().printf(" "); + } + } + break; + case 'R': case 'r': + { + // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) + I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header + i2cMaster.frequency(g_I2C_SCL_Hz); + // %IR ADDR=? RD=? -- read + // TODO: i2c transfer + //const int addr7bit = 0x48; // 7 bit I2C address + //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 + // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. + // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. + // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. + // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. + // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. + // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. + // /* 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... + // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... + } + break; + case '^': + { + // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) + I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header + i2cMaster.frequency(g_I2C_SCL_Hz); + // %I^ cmd=? -- i2c_smbus_read_word_data + // TODO: i2c transfer + //const int addr7bit = 0x48; // 7 bit I2C address + //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 + // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. + // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. + // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. + // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. + // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. + // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. + // /* 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... + // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... + } + break; + } // switch(cmdLine[2]) + break; +#endif + // +#if HAS_SPI // SUPPORT_SPI + case 'S': case 's': + { + // %S... -- SPI diagnostics + // %SC sclk=1Mhz -- SPI configure + // %SW -- write (write and read) + // %SR -- read (alias for %SW because SPI always write and read) + // + // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d + bool isUpdatedSPIConfig = false; + // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2 + // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1 + if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2)) + { + isUpdatedSPIConfig = true; + } + if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1)) + { + isUpdatedSPIConfig = true; + } + if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1)) + { + isUpdatedSPIConfig = true; + } + // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz + if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz)) + { + isUpdatedSPIConfig = true; + // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU + if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz) + { + g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz; + } + if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz) + { + g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz; + } + } + // Update SPI configuration + if (isUpdatedSPIConfig) + { + // %SC sclk=1Mhz -- SPI configure + spi_cs = g_SPI_cs_state; + spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 +#if APPLICATION_MAX5715 + g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz); +#elif APPLICATION_MAX11131 + g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz); +#elif APPLICATION_MAX5171 + g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz); +#elif APPLICATION_MAX11410 + g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz); +#elif APPLICATION_MAX12345 + g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz); +#else + spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default) +#endif + // + double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz; + int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate + double actual_SCLK_Hz = SystemCoreClock / actual_divisor; + // + // 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=] + cmdLine.serial().printf( + "\r\n %%SC CPOL=%d CPHA=%d CS=%d SCLK=%ld=%1.3fMHz (%1.1fMHz/%1.2f = actual %1.3fMHz) -- SPI config", + ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0), + ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0), + g_SPI_cs_state, + g_SPI_SCLK_Hz, + (g_SPI_SCLK_Hz / 1000000.), + ((double)(SystemCoreClock / 1000000.)), + ideal_divisor, + (actual_SCLK_Hz / 1000000.) + ); + } + // get next character + switch (cmdLine[2]) + { + case 'C': case 's': + // %SC sclk=1Mhz -- SPI configure + break; + case 'W': case 'R': case 'w': case 'r': + { + // %SW -- write (write and read) + // %SR -- read (alias for %SW because SPI always write and read) + // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; + #define MAX_SPI_BYTE_COUNT 32 + size_t byteCount = byteCount; + static char mosiData[MAX_SPI_BYTE_COUNT]; + static char misoData[MAX_SPI_BYTE_COUNT]; + if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, + MAX_SPI_BYTE_COUNT)) + { + // hex dump mosiData[0..byteCount-1] + cmdLine.serial().printf("\r\nSPI"); + if (byteCount > 7) { + cmdLine.serial().printf(" byteCount:%d", byteCount); + } + cmdLine.serial().printf(" MOSI->"); + for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) + { + cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]); + } + spi_cs = 0; + unsigned int numBytesTransferred = + spi.write(mosiData, byteCount, misoData, byteCount); + spi_cs = 1; + // hex dump misoData[0..byteCount-1] + cmdLine.serial().printf(" MISO<-"); + for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; + byteIndex++) + { + cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]); + } + cmdLine.serial().printf(" "); + } + } + break; + } // switch(cmdLine[2]) + } // case 'S': // %S... -- SPI diagnostics + break; +#endif + // + // A-Z,a-z,0-9 reserved for application use + } // switch(cmdLine[1]) +} // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine) + + +//-------------------------------------------------- +void main_menu_status(CmdLine & cmdLine) +{ + cmdLine.serial().printf("\r\nMain menu"); + + cmdLine.serial().printf(" MAX11043 24-bit 200ksps Delta-Sigma ADC"); + + //cmdLine.serial().print(" %s", TARGET_NAME); + if (cmdLine.nameStr()) + { + cmdLine.serial().printf(" [%s]", cmdLine.nameStr()); + + } + cmdLine.serial().printf("\r\n ? -- help"); + +} + + +//-------------------------------------------------- +void main_menu_help(CmdLine & cmdLine) +{ + // ? -- help + //~ cmdLine.serial().print(F("\r\nMenu:")); + cmdLine.serial().printf("\r\n # -- lines beginning with # are comments"); + + cmdLine.serial().printf("\r\n . -- SelfTest"); + + //cmdLine.serial().print(F("\r\n ! -- Initial Configuration")); + // + // % standardize diagnostic commands + // %Hpin -- digital output high + // %Lpin -- digital output low + // %?pin -- digital input + // %A %Apin -- analog input + // %Ppin df=xx -- pwm output + // %Wpin -- measure high pulsewidth input in usec + // %wpin -- measure low pulsewidth input in usec + // %I... -- I2C diagnostics + // %IP -- I2C probe + // %IC scl=100khz ADDR=? -- I2C configure + // %IW ADDR=? cmd=? data,data,data -- write + // %IR ADDR=? RD=? -- read + // %I^ cmd=? -- i2c_smbus_read_word_data + // %S... -- SPI diagnostics + // %SC sclk=1Mhz -- SPI configure + // %SW -- write (write and read) + // %SR -- read (alias for %SW because SPI always write and read) + // A-Z,a-z,0-9 reserved for application use + // +#if HAS_digitalInOuts + // %Hpin -- digital output high + // %Lpin -- digital output low + // %?pin -- digital input + cmdLine.serial().printf("\r\n %%Hn {pin:"); + list_digitalInOutPins(cmdLine.serial()); + cmdLine.serial().printf("} -- High Output"); + cmdLine.serial().printf("\r\n %%Ln {pin:"); + list_digitalInOutPins(cmdLine.serial()); + cmdLine.serial().printf("} -- Low Output"); + cmdLine.serial().printf("\r\n %%?n {pin:"); + list_digitalInOutPins(cmdLine.serial()); + cmdLine.serial().printf("} -- Input"); +#endif + +#if HAS_analogIns + // Menu A) analogRead A0..7 + // %A %Apin -- analog input + // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0) + cmdLine.serial().printf("\r\n %%A -- analogRead"); +#endif + +#if HAS_SPI2_MAX541 + // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs); + cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)"); +#endif + +#if HAS_I2C // SUPPORT_I2C + // TODO: support I2C HAS_I2C // SUPPORT_I2C + // VERIFY: I2C utility commands SUPPORT_I2C + // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz); + // %I... -- I2C diagnostics + // %IP -- I2C probe + // %IC scl=100khz ADDR=? -- I2C configure + // %IW byte byte ... byte RD=? ADDR=0x -- write + // %IR ADDR=? RD=? -- read + // %I^ cmd=? -- i2c_smbus_read_word_data + //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope + cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config", + g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz, + (g_I2C_SCL_Hz / 1000.)); + cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read", + g_I2C_deviceAddress7); + // +#if SUPPORT_I2C + // Menu ^ cmd=?) i2c_smbus_read_word_data + cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data"); + // test low-level I2C i2c_smbus_read_word_data +#endif // SUPPORT_I2C + //cmdLine.serial().printf(" H) Hunt for attached I2C devices"); + cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices"); + // cmdLine.serial().printf(" s) search i2c address"); +#endif // SUPPORT_I2C + +#if HAS_SPI // SUPPORT_SPI + // TODO: support SPI HAS_SPI // SUPPORT_SPI + // SPI test command S (mosiData)+ + // %S... -- SPI diagnostics + // %SC sclk=1Mhz -- SPI configure + // %SW -- write (write and read) + // %SR -- read (alias for %SW because SPI always write and read) + // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default) + // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default) + // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default) + // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default) + // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default) + // mode | POL PHA + // -----+-------- + // 0 | 0 0 + // 1 | 0 1 + // 2 | 1 0 + // 3 | 1 1 + //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0"); + // 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=] + cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config", + g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.), + ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0), + ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0)); + cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes"); + // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0 +#endif // SUPPORT_SPI + // + // Application-specific commands (help text) here + // +#if APPLICATION_ArduinoPinsMonitor + cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor +#endif // APPLICATION_ArduinoPinsMonitor + // + + extern bool MAX11043_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11043.cpp\n + MAX11043_menu_help(cmdLine); +} + + + +//-------------------------------------------------- +// main menu command-line parser +// invoked by CmdLine::append(char ch) or CmdLine::idleAppendIfReadable() +void main_menu_onEOLcommandParser(CmdLine & cmdLine) +{ + // DIAGNOSTIC: print line buffer + //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str()); + // + switch (cmdLine[0]) + { + case '?': + main_menu_status(cmdLine); + main_menu_help(cmdLine); + // print command prompt + //cmdLine.serial().printf("\r\n>"); + break; + case '\r': case '\n': // ignore blank line + case '\0': // ignore empty line + case '#': // ignore comment line + // # -- lines beginning with # are comments + main_menu_status(cmdLine); + //~ main_menu_help(cmdLine); + // print command prompt + //cmdLine.serial().printf("\r\n>"); + break; +#if ECHO_EOF_ON_EOL + case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file + cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting + diagnostic_led_EOF(); + break; + case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file + cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting + diagnostic_led_EOF(); + break; +#endif +#if APPLICATION_ArduinoPinsMonitor + case '.': + { + // . -- SelfTest + cmdLine.serial().printf("SelfTest()"); + SelfTest(cmdLine); + } + break; + case '%': + { + pinsMonitor_submenu_onEOLcommandParser(cmdLine); + } + break; // case '%' +#endif // APPLICATION_ArduinoPinsMonitor + // + // Application-specific commands here + // alphanumeric command codes A-Z,a-z,0-9 reserved for application use + // +#if APPLICATION_ArduinoPinsMonitor +#endif // APPLICATION_ArduinoPinsMonitor + + // + // add new commands here + // + default: + extern bool MAX11043_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11043.cpp + if (!MAX11043_menu_onEOLcommandParser(cmdLine)) + { // not_handled_by_device_submenu + cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str()); + +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str()); + +# endif // HAS_DAPLINK_SERIAL + } + } // switch (cmdLine[0]) +// +// print command prompt + cmdLine.serial().printf("\r\nMAX11043 > "); + +} // end void main_menu_onEOLcommandParser(CmdLine & cmdLine) + +//-------------------------------------------------- +void InitializeConfiguration() +{ + // CODE GENERATOR: example code: member function Init +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("\r\nMAX11043_Init()"); + +# endif + cmdLine_serial.serial().printf("\r\nMAX11043_Init()"); + + int initResult = g_MAX11043_device.Init(); // defined in #include MAX11043.h +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("\r\nMAX11043_Init() returned %d\r\n", initResult); + +# endif + cmdLine_serial.serial().printf("\r\nMAX11043_Init() returned %d\r\n", initResult); + +# if MAX11043_ONSPIPRINT + // Optional Diagnostic function to print SPI transactions + g_MAX11043_device.onSPIprint = onSPIprint_handler; +# endif +} + +//-------------------------------------------------- +// diagnostic rbg led GREEN +void diagnostic_led_EOF() +{ +#if USE_LEDS + led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW + // 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] + ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); + led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN + ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); + led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW + ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); + led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN + ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); +#endif // USE_LEDS +} + +//-------------------------------------------------- +// Support commands that get handled immediately w/o waiting for EOL +// handled as immediate command, do not append to buffer +void on_immediate_0x21() // Unicode (U+0021) ! EXCLAMATION MARK +{ +#if USE_LEDS + led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE +#endif // USE_LEDS + InitializeConfiguration(); + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); +} + +//-------------------------------------------------- +// Support commands that get handled immediately w/o waiting for EOL +// handled as immediate command, do not append to buffer +void on_immediate_0x7b() // Unicode (U+007B) { LEFT CURLY BRACKET +{ +#if HAS_BUTTON2_DEMO_INTERRUPT + onButton2FallingEdge(); +#endif +} + +//-------------------------------------------------- +// Support commands that get handled immediately w/o waiting for EOL +// handled as immediate command, do not append to buffer +void on_immediate_0x7d() // Unicode (U+007D) } RIGHT CURLY BRACKET +{ +#if HAS_BUTTON1_DEMO_INTERRUPT + onButton1FallingEdge(); +#endif +} + +//---------------------------------------- +// example code main function +int main() +{ + // Configure serial ports + cmdLine_serial.clear(); + //~ cmdLine_serial.serial().printf("\r\n cmdLine_serial.serial().printf test\r\n"); + cmdLine_serial.onEOLcommandParser = main_menu_onEOLcommandParser; + cmdLine_serial.diagnostic_led_EOF = diagnostic_led_EOF; + /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21); + cmdLine_serial.on_immediate_0x21 = on_immediate_0x21; + cmdLine_serial.on_immediate_0x7b = on_immediate_0x7b; + cmdLine_serial.on_immediate_0x7d = on_immediate_0x7d; +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.clear(); + //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n"); + cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser; + /// @todo CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21); + cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21; + cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b; + cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d; +# endif + + + //print_banner(); + + + +#if USE_LEDS +#if defined(TARGET_MAX32630) + led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); +#elif defined(TARGET_MAX32625MBED) + led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); + led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK + ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); +#else // not defined(TARGET_LPC1768 etc.) + led1 = LED_ON; + led2 = LED_OFF; + led3 = LED_OFF; + led4 = LED_OFF; + ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); + //led1 = LED_ON; + led2 = LED_ON; + ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); + led1 = LED_OFF; + //led2 = LED_ON; + led3 = LED_ON; + ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); + led2 = LED_OFF; + //led3 = LED_ON; + led4 = LED_ON; + ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); + led3 = LED_OFF; + led4 = LED_ON; + // +#endif // target definition +#endif + + // cmd_TE(); + +// #if USE_LEDS +// rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE +// #endif // USE_LEDS + led1 = LED_ON; + led2 = LED_ON; + led3 = LED_ON; + + InitializeConfiguration(); + // CODE GENERATOR: example code: member function Init + g_MAX11043_device.Init(); + + // example code: serial port banner message + #if defined(TARGET_MAX32625MBED) + serial.printf("MAX32625MBED "); + #elif defined(TARGET_MAX32600MBED) + serial.printf("MAX32600MBED "); + #elif defined(TARGET_NUCLEO_F446RE) + serial.printf("NUCLEO_F446RE "); + #endif + serial.printf("MAX11043BOB\r\n"); + + + while (1) { +#if HAS_BUTTON1_DEMO_INTERRUPT_POLLING + // avoid runtime error on button1 press [mbed-os-5.11] + // instead of using InterruptIn, use DigitalIn and poll in main while(1) +# if HAS_BUTTON1_DEMO_INTERRUPT + static int button1_value_prev = 1; + static int button1_value_now = 1; + button1_value_prev = button1_value_now; + button1_value_now = button1.read(); + if ((button1_value_prev - button1_value_now) == 1) + { + // on button1 falling edge (button1 press) + onButton1FallingEdge(); + } +# endif // HAS_BUTTON1_DEMO_INTERRUPT +# if HAS_BUTTON2_DEMO_INTERRUPT + static int button2_value_prev = 1; + static int button2_value_now = 1; + button2_value_prev = button2_value_now; + button2_value_now = button2.read(); + if ((button2_value_prev - button2_value_now) == 1) + { + // on button2 falling edge (button2 press) + onButton2FallingEdge(); + } +# endif // HAS_BUTTON2_DEMO_INTERRUPT +#endif + # if HAS_DAPLINK_SERIAL + if (DAPLINKserial.readable()) { + cmdLine_DAPLINKserial.append(DAPLINKserial.getc()); + } + # endif // HAS_DAPLINK_SERIAL + if (serial.readable()) { + int c = serial.getc(); + cmdLine_serial.append(c); +#if IGNORE_AT_COMMANDS +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("%c", c); +# endif // HAS_DAPLINK_SERIAL +#endif // IGNORE_AT_COMMANDS + // + } + } // while(1) +} +//---------- CODE GENERATOR: end testMainCppCodeList +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Test_Menu_MAX11043.cpp Tue Feb 11 01:16:34 2020 +0000 @@ -0,0 +1,630 @@ +// /******************************************************************************* +// * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved. +// * +// * Permission is hereby granted, free of charge, to any person obtaining a +// * copy of this software and associated documentation files (the "Software"), +// * to deal in the Software without restriction, including without limitation +// * the rights to use, copy, modify, merge, publish, distribute, sublicense, +// * and/or sell copies of the Software, and to permit persons to whom the +// * Software is furnished to do so, subject to the following conditions: +// * +// * The above copyright notice and this permission notice shall be included +// * in all copies or substantial portions of the Software. +// * +// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +// * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// * OTHER DEALINGS IN THE SOFTWARE. +// * +// * Except as contained in this notice, the name of Maxim Integrated +// * Products, Inc. shall not be used except as stated in the Maxim Integrated +// * Products, Inc. Branding Policy. +// * +// * The mere transfer of this software does not imply any licenses +// * of trade secrets, proprietary technology, copyrights, patents, +// * trademarks, maskwork rights, or any other form of intellectual +// * property whatsoever. Maxim Integrated Products, Inc. retains all +// * ownership rights. +// ******************************************************************************* +// */ +#include "CmdLine.h" +#include "MaximTinyTester.h" +// CODE GENERATOR: class declaration and docstrings +// CODE GENERATOR: example code includes +// example code includes +// standard include for target platform -- Platform_Include_Boilerplate +#include "mbed.h" +// Platforms: +// - MAX32625MBED +// - supports mbed-os-5.11, requires USBDevice library +// - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - MAX32600MBED +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board. +// - NUCLEO_F446RE +// - remove USBDevice library +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - NUCLEO_F401RE +// - remove USBDevice library +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - MAX32630FTHR +// - #include "max32630fthr.h" +// - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/ +// - remove MAX32620FTHR library (if present) +// - MAX32620FTHR +// - #include "MAX32620FTHR.h" +// - remove max32630fthr library (if present) +// - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/ +// - not tested yet +// - MAX32625PICO +// - remove max32630fthr library (if present) +// - remove MAX32620FTHR library (if present) +// - not tested yet +// +// end Platform_Include_Boilerplate +#include "MAX11043.h" +#include "CmdLine.h" +#include "MaximTinyTester.h" +// CODE GENERATOR: class declaration statement open + +// CODE GENERATOR: Test_Menu externs +#include "MAX11043.h" +extern MAX11043 g_MAX11043_device; // defined in main.cpp + +// CODE GENERATOR: build testMenuCommand list +// CODE GENERATOR: build testMenuGlobalArgsDict common/global argument list +// CODE GENERATOR: class member function declarations +// CODE GENERATOR: MAX11043 Command Name = Init (void) --> uint8_t +// CODE GENERATOR: Menu item hint description Menu item '!' +// CODE GENERATOR: Menu item '!' -- Menu item ! +// CODE GENERATOR: test menu case '!': +// CODE GENERATOR: helpString '! -- Init' +// CODE GENERATOR: CMD_ 'None' +// CODE GENERATOR: CommandName 'Init' +// CODE GENERATOR: CommandParamIn 'void' +// CODE GENERATOR: CommandReturnType 'uint8_t' +// CODE GENERATOR: CommandPre '' +// CODE GENERATOR: CommandDocParamIn '' +// CODE GENERATOR: CommandDocParamOut '' +// CODE GENERATOR: CommandPost '' +// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' +// CODE GENERATOR: MAX11043 Command Name = RegWrite (MAX11043_CMD_enum_t commandByte, uint32_t regData) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: CommandDescriptionCMDWord = CMD_1aaa_aaaa_REGISTER_READ +// CODE GENERATOR: MAX11043 Command Name = RegWrite CMD_1aaa_aaaa_REGISTER_READ (MAX11043_CMD_enum_t commandByte, uint32_t regData) --> uint8_t +// CODE GENERATOR: MAX11043 Command Name = RegRead (MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: CommandDescriptionCMDWord = CMD_1aaa_aaaa_REGISTER_READ +// CODE GENERATOR: MAX11043 Command Name = RegRead CMD_1aaa_aaaa_REGISTER_READ (MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData) --> uint8_t +// CODE GENERATOR: MAX11043 Command Name = RegSize (MAX11043_CMD_enum_t commandByte) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11043 Command Name = RegAddrOfCommand (MAX11043_CMD_enum_t commandByte) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11043 Command Name = IsRegReadCommand (MAX11043_CMD_enum_t commandByte) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11043 Command Name = RegName (MAX11043_CMD_enum_t commandByte) --> const char* +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: testMenuGlobalArgsDict scan global property list g_MAX11043_device + +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.VRef_xxxxxx +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.VRef_xxxxxx argname = VRef_xxxxxx +// CODE GENERATOR: testMenuGlobalArgsDict['VRef_xxxxxx']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef_xxxxxx']['argtype'] = 'double' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef_xxxxxx']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef_xxxxxx']['usedBytestMenuItemName'] = 'None' + +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.ctrl +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.ctrl shadow of argname = ctrl +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.ctrl argname = ctrl +// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['argtype'] = 'uint32_t' +// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['usedBytestMenuItemName'] = 'None' + +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.pgaGain +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.pgaGain argname = pgaGain +// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['argtype'] = 'uint8_t' +// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['usedBytestMenuItemName'] = 'None' + +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status shadow of argname = status +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status argname = status +// CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint32_t' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None' + +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.data0 +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.data0 shadow of argname = data0 +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.data0 argname = data0 +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['argtype'] = 'uint32_t' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedBytestMenuItemName'] = 'None' + +// CODE GENERATOR: testMenuGlobalArgsDict skip array property g_MAX11043_device.AINcode[11] + +// CODE GENERATOR: scan testMenuCommand list for items that can be shortened to single character +// CODE GENERATOR: shorten testMenuCommand to single character if unambiguous +// CODE GENERATOR: testMenuCommand '!' already single character + +// CODE GENERATOR: help menu +bool MAX11043_menu_help(CmdLine & cmdLine) +{ + // CODE GENERATOR: command: ! + // CODE GENERATOR: help: ! -- Init + cmdLine.serial().printf("\r\n ! -- Init"); + // + cmdLine.serial().printf("\r\n @ -- print MAX11043 configuration"); + +// CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register + cmdLine.serial().printf("\r\n *regname? -- read register\r\n *regname=regvalue -- write register"); + + // +// CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names (menu_help) + // case 'G'..'Z','g'..'z' are reserved for GPIO commands + // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands +// CODE GENERATOR: TODO1: prevent conflict ExternFunctionGPIOPinCommand with reserved case 'A'..'F','a'..'f' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue' + +// CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN' +#warning "No command case for 'CONVRUN' 'PinName' 'CONVRUN' due to conflict with reserved commands A-F, try changing pin name" +#warning "Randomly assigned command 'G' for 'CONVRUN' due to name conflict" +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue' + +// CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP' +#warning "No command case for 'DACSTEP' 'PinName' 'DACSTEP' due to conflict with reserved commands A-F, try changing pin name" +#warning "Randomly assigned command 'H' for 'DACSTEP' due to name conflict" +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue' + +// CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC' +#warning "No command case for 'EOC' 'PinName' 'EOC' due to conflict with reserved commands A-F, try changing pin name" +#warning "Randomly assigned command 'I' for 'EOC' due to name conflict" +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue' + +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue' + +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'A' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'B' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'C' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'D' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'E' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'F' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'G' 'CONVRUN' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue' + cmdLine.serial().printf("\r\n G -- CONVRUN output GH high GL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'H' 'DACSTEP' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue' + cmdLine.serial().printf("\r\n H -- DACSTEP output HH high HL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'I' 'EOC' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue' + cmdLine.serial().printf("\r\n I -- EOC input value"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'S' 'SHDN' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue' + cmdLine.serial().printf("\r\n S -- SHDN output SH high SL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'U' 'UP_slash_DWNb' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue' + cmdLine.serial().printf("\r\n U -- UP_slash_DWNb output UH high UL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'a' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'b' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'c' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'd' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'e' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'f' 'None' + + // +} + +bool MAX11043_menu_onEOLcommandParser(CmdLine & cmdLine) +{ + +// CODE GENERATOR: testMenuGlobalArgsDict Consolidate common/global argument parsing + +// CODE GENERATOR: testMenuGlobalArgsDict['VRef_xxxxxx']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef_xxxxxx']['argtype'] = 'double' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef_xxxxxx']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef_xxxxxx']['usedBytestMenuItemName'] = 'None' + // parse argument double VRef_xxxxxx + double VRef_xxxxxx = g_MAX11043_device.VRef_xxxxxx; // default to global property value + if (cmdLine.parse_double("VRef_xxxxxx", VRef_xxxxxx)) + { + g_MAX11043_device.VRef_xxxxxx = VRef_xxxxxx; // update global property value + } + +// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['argtype'] = 'uint32_t' +// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['usedBytestMenuItemName'] = 'None' + // parse argument uint32_t ctrl + uint32_t ctrl = g_MAX11043_device.ctrl; // default to global property value + if (cmdLine.parse_uint32_dec("ctrl", ctrl)) + { + g_MAX11043_device.ctrl = ctrl; // update global property value + } + +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['argtype'] = 'uint32_t' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedBytestMenuItemName'] = 'None' + // parse argument uint32_t data0 + uint32_t data0 = g_MAX11043_device.data0; // default to global property value + if (cmdLine.parse_uint32_dec("data0", data0)) + { + g_MAX11043_device.data0 = data0; // update global property value + } + +// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['argtype'] = 'uint8_t' +// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['usedBytestMenuItemName'] = 'None' + // parse argument uint8_t pgaGain + uint8_t pgaGain = g_MAX11043_device.pgaGain; // default to global property value + if (cmdLine.parse_uint8_dec("pgaGain", pgaGain)) + { + g_MAX11043_device.pgaGain = pgaGain; // update global property value + } + +// CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint32_t' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None' + // parse argument uint32_t status + uint32_t status = g_MAX11043_device.status; // default to global property value + if (cmdLine.parse_uint32_dec("status", status)) + { + g_MAX11043_device.status = status; // update global property value + } + + switch (cmdLine[0]) + { +// CODE GENERATOR: generate * command read/write reg *reg? *reg=value + case '*': + { + // if buffer starts with a regName: + // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))): + cmdLine.serial().printf(" scan RegName...\r\n"); + for (uint8_t regAddress = 0; regAddress < 0x80; regAddress++) + { + uint32_t regData = 0; + bool is_regname_query = false; + bool is_regname_assignment = false; + if (cmdLine.parse_uint32_dec(g_MAX11043_device.RegName((MAX11043::MAX11043_CMD_enum_t)regAddress), regData)) + { + cmdLine.serial().printf(" regAddress=0x%2.2X\r\n", (regAddress & 0xFF)); + cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11043_device.RegName((MAX11043::MAX11043_CMD_enum_t)regAddress)); + // accept regName "?" as "RegRead" by name + is_regname_query = (cmdLine.chSeparator == '?'); + is_regname_assignment = (cmdLine.chSeparator == '='); + if (is_regname_query) + { + cmdLine.serial().printf(" RegRead"); + g_MAX11043_device.RegRead((MAX11043::MAX11043_CMD_enum_t)regAddress, ®Data); + cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF)); + return true; // command handled by MAX11043 + } + // accept regName "=0x123456" as "RegWrite" by name + if (is_regname_assignment) + { + cmdLine.serial().printf(" RegWrite"); + cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF)); + g_MAX11043_device.RegWrite((MAX11043::MAX11043_CMD_enum_t)regAddress, regData); + return true; // command handled by MAX11043 + } + } + } // end for regAddr + // not a valid register name + // read "all" registers by name + const uint8_t readAllRegFirst = 0x00; // first MAX11043 register address for read-all block + const uint8_t readAllRegLast = 0x39; // last MAX11043 register address for read-all block + Callback<void(size_t, uint8_t*, uint8_t*)> saved_onSPIprint_handler = g_MAX11043_device.onSPIprint; + g_MAX11043_device.onSPIprint = NULL; + for (uint8_t regAddress = readAllRegFirst; regAddress <= readAllRegLast; regAddress++) + { + uint32_t regData = 0; + if (g_MAX11043_device.RegSize((MAX11043::MAX11043_CMD_enum_t)regAddress) == 0) continue; // skip undefined regs + if (g_MAX11043_device.RegRead((MAX11043::MAX11043_CMD_enum_t)regAddress, ®Data) == 0) continue; // skip unreadable regs + cmdLine.serial().printf("%s=0x%6.6x\r\n", g_MAX11043_device.RegName((MAX11043::MAX11043_CMD_enum_t)regAddress), regData); + } // end for regAddr + g_MAX11043_device.onSPIprint = saved_onSPIprint_handler; + return true; // command handled by MAX11043 + } + break; + +// CODE GENERATOR: generate @ command print global property values of g_MAX11043_device + case '@': + { +// CODE GENERATOR: @ command print double g_MAX11043_device.VRef_xxxxxx + cmdLine.serial().printf("VRef_xxxxxx = "); + cmdLine.serial().printf("%f\r\n", g_MAX11043_device.VRef_xxxxxx); +// CODE GENERATOR: @ command print uint32_t g_MAX11043_device.ctrl + cmdLine.serial().printf("ctrl = "); + cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.ctrl, g_MAX11043_device.ctrl); +// CODE GENERATOR: @ command print uint8_t g_MAX11043_device.pgaGain + cmdLine.serial().printf("pgaGain = "); + cmdLine.serial().printf("%d = 0x%2.2x\r\n", g_MAX11043_device.pgaGain, g_MAX11043_device.pgaGain); +// CODE GENERATOR: @ command print uint32_t g_MAX11043_device.status + cmdLine.serial().printf("status = "); + cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.status, g_MAX11043_device.status); +// CODE GENERATOR: @ command print uint32_t g_MAX11043_device.data0 + cmdLine.serial().printf("data0 = "); + cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.data0, g_MAX11043_device.data0); +// CODE GENERATOR: @ command print uint32_t array g_MAX11043_device.AINcode[0..10] + for(int index = 0; (index < 11) && (index < 16); index++) { + cmdLine.serial().printf("AINcode[%d] = ", index); + cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.AINcode[index], g_MAX11043_device.AINcode[index]); + } + return true; // command handled by MAX11043 + break; + } +// CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names + // case 'G'..'Z','g'..'z' are reserved for GPIO commands + // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'A' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'B' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'C' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'D' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'E' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'F' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'G' 'CONVRUN' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue' + case 'G': + { + switch (cmdLine[1]) + { + case 'H': + { + g_MAX11043_device.CONVRUNoutputValue(1); + break; + } + case 'L': + { + g_MAX11043_device.CONVRUNoutputValue(0); + break; + } + } + return true; // command handled by MAX11043 + break; + } + +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'H' 'DACSTEP' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue' + case 'H': + { + switch (cmdLine[1]) + { + case 'H': + { + g_MAX11043_device.DACSTEPoutputValue(1); + break; + } + case 'L': + { + g_MAX11043_device.DACSTEPoutputValue(0); + break; + } + } + return true; // command handled by MAX11043 + break; + } + +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'I' 'EOC' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue' + case 'I': + { + // TODO capture and print input Value + cmdLine.serial().printf("%d", g_MAX11043_device.EOCinputValue()); + return true; // command handled by MAX11043 + break; + } + +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'S' 'SHDN' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue' + case 'S': + { + switch (cmdLine[1]) + { + case 'H': + { + g_MAX11043_device.SHDNoutputValue(1); + break; + } + case 'L': + { + g_MAX11043_device.SHDNoutputValue(0); + break; + } + } + return true; // command handled by MAX11043 + break; + } + +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'U' 'UP_slash_DWNb' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value' +// CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue' + case 'U': + { + switch (cmdLine[1]) + { + case 'H': + { + g_MAX11043_device.UP_slash_DWNboutputValue(1); + break; + } + case 'L': + { + g_MAX11043_device.UP_slash_DWNboutputValue(0); + break; + } + } + return true; // command handled by MAX11043 + break; + } + +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'a' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'b' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'c' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'd' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'e' 'None' +// CODE GENERATOR: ExternFunctionGPIOPinCommand 'f' 'None' + +// CODE GENERATOR: test menu + // case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands + // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands +// CODE GENERATOR: top of loop: testMenuCommand="!", testMenuFirstCharHandler="None" +// CODE GENERATOR: test menu case '!': +// CODE GENERATOR: helpString '! -- Init' +// CODE GENERATOR: CMD_ 'None' +// CODE GENERATOR: CommandName 'Init' +// CODE GENERATOR: CommandParamIn 'void' +// CODE GENERATOR: CommandReturnType 'uint8_t' +// CODE GENERATOR: CommandPre '' +// CODE GENERATOR: CommandDocParamIn '' +// CODE GENERATOR: CommandDocParamOut '' +// CODE GENERATOR: CommandPost '' +// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' + // case '!': // (single character) (testMenuFirstCharHandler="None") + case '!': + { + // test menu command '!' handler: + // helpString='! -- Init' + // CMD_='None' + // CommandName='Init' + // CommandParamIn='void' + // CommandReturnType='uint8_t' + // @Pre='' + // @Param[in]='' + // @Param[out]='' + // @Post='' + // displayPost='' + // @Return='@return 1 on success; 0 on failure' + cmdLine.serial().printf("Init"); + // call function Init + uint8_t result = g_MAX11043_device.Init(); + cmdLine.serial().printf(" =%d", result); + return true; // command handled by MAX11043 +// CODE GENERATOR: bottom of loop: testMenuCommand="!", testMenuFirstCharHandler="None" + } // end case '!' + break; + + // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + { + // hexadecimal codes get parsed as bytecodes + // + // parse_byteCount_byteList_dec() assumes all keyword args have already been removed from the buffer + // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; + #define MAX_SPI_BYTE_COUNT 32 + size_t byteCount = byteCount; + static char mosiData[MAX_SPI_BYTE_COUNT]; + static char misoData[MAX_SPI_BYTE_COUNT]; + if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, + MAX_SPI_BYTE_COUNT)) + { + // if length is 1 byte then operation is RegRead, otherwise RegWrite + // register_read_function 'IsRegReadCommand' + // register_write_function 'RegWrite' + // register_name_function 'RegName' + // register_size_function 'RegSize' +// CODE GENERATOR: does the chip have a defined CMD_1aaa_aaaa_REGISTER_READ bit? + // MAX11043::MAX11043_CMD_enum_t regAddress = (MAX11043::MAX11043_CMD_enum_t)((mosiData[0] &~ MAX11043::CMD_1aaa_aaaa_REGISTER_READ) & 0xFF); + MAX11043::MAX11043_CMD_enum_t commandByte = (MAX11043::MAX11043_CMD_enum_t)(mosiData[0]); + int regAddress = g_MAX11043_device.RegAddrOfCommand(commandByte); + cmdLine.serial().printf(" regAddress=0x%2.2x\r\n", (regAddress & 0xFF)); + cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11043_device.RegName(commandByte)); + uint32_t regData = 0; + int regSize = g_MAX11043_device.RegSize(commandByte); + cmdLine.serial().printf(" RegSize=%d\r\n", regSize); + switch(regSize) + { + case 8: + regData = ((uint32_t)mosiData[1] & 0xFF); + break; + case 16: + regData = (((uint32_t)mosiData[1] & 0xFF) << 8) + ((uint32_t)mosiData[2] & 0xFF); + break; + case 24: + regData = (((uint32_t)mosiData[1] & 0xFF) << 16) + (((uint32_t)mosiData[2] & 0xFF) << 8) + ((uint32_t)mosiData[3] & 0xFF); + break; + } +// CODE GENERATOR: does the chip have a defined CMD_1aaa_aaaa_REGISTER_READ bit? + // if ((byteCount == 1) || (regAddress & MAX11043::CMD_1aaa_aaaa_REGISTER_READ)) + if ((byteCount == 1) || g_MAX11043_device.IsRegReadCommand(commandByte)) + { + cmdLine.serial().printf(" RegRead"); + g_MAX11043_device.RegRead(commandByte, ®Data); + cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF)); + } + else + { + cmdLine.serial().printf(" RegWrite regData=0x%6.6X\r\n", (regData & 0x00FFFFFF)); + g_MAX11043_device.RegWrite(commandByte, regData); + } + // is there support function shadow regValue of regAddr? + } + return true; // command handled by MAX11043 + // + } // end case '0'..'9','A'..'F','a'..'f' + break; + } // end switch (cmdLine[0]) + return false; // command not handled by MAX11043 +} // end bool MAX11043_menu_onEOLcommandParser(CmdLine & cmdLine) + +// CODE GENERATOR: class declaration statement close +
--- a/Test_Menu_MAX11410.cpp Wed Jan 22 07:57:46 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2036 +0,0 @@ -// /******************************************************************************* -// * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved. -// * -// * Permission is hereby granted, free of charge, to any person obtaining a -// * copy of this software and associated documentation files (the "Software"), -// * to deal in the Software without restriction, including without limitation -// * the rights to use, copy, modify, merge, publish, distribute, sublicense, -// * and/or sell copies of the Software, and to permit persons to whom the -// * Software is furnished to do so, subject to the following conditions: -// * -// * The above copyright notice and this permission notice shall be included -// * in all copies or substantial portions of the Software. -// * -// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES -// * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -// * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// * OTHER DEALINGS IN THE SOFTWARE. -// * -// * Except as contained in this notice, the name of Maxim Integrated -// * Products, Inc. shall not be used except as stated in the Maxim Integrated -// * Products, Inc. Branding Policy. -// * -// * The mere transfer of this software does not imply any licenses -// * of trade secrets, proprietary technology, copyrights, patents, -// * trademarks, maskwork rights, or any other form of intellectual -// * property whatsoever. Maxim Integrated Products, Inc. retains all -// * ownership rights. -// ******************************************************************************* -// */ -#include "CmdLine.h" -// CODE GENERATOR: class declaration and docstrings -// CODE GENERATOR: example code includes -// example code includes -// standard include for target platform -- Platform_Include_Boilerplate -#include "mbed.h" -// Platforms: -// - MAX32625MBED -// - supports mbed-os-5.11, requires USBDevice library -// - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ -// - remove max32630fthr library (if present) -// - remove MAX32620FTHR library (if present) -// - MAX32600MBED -// - remove max32630fthr library (if present) -// - remove MAX32620FTHR library (if present) -// - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board. -// - NUCLEO_F446RE -// - remove USBDevice library -// - remove max32630fthr library (if present) -// - remove MAX32620FTHR library (if present) -// - NUCLEO_F401RE -// - remove USBDevice library -// - remove max32630fthr library (if present) -// - remove MAX32620FTHR library (if present) -// - MAX32630FTHR -// - #include "max32630fthr.h" -// - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/ -// - remove MAX32620FTHR library (if present) -// - MAX32620FTHR -// - #include "MAX32620FTHR.h" -// - remove max32630fthr library (if present) -// - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/ -// - not tested yet -// - MAX32625PICO -// - remove max32630fthr library (if present) -// - remove MAX32620FTHR library (if present) -// - not tested yet -// -// end Platform_Include_Boilerplate -#include "MAX11410.h" -#include "CmdLine.h" -// CODE GENERATOR: class declaration statement open - -// CODE GENERATOR: Test_Menu externs -#include "MAX11410.h" -extern MAX11410 g_MAX11410_device; // defined in main.cpp - -// CODE GENERATOR: build testMenuCommand list -// CODE GENERATOR: build testMenuGlobalArgsDict common/global argument list -// CODE GENERATOR: class member function declarations -// CODE GENERATOR: MAX11410 Command Name = Init (void) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item '!' -// CODE GENERATOR: Menu item '!' -- Menu item ! -// CODE GENERATOR: test menu case '!': -// CODE GENERATOR: helpString '! -- Init' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Init' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = VoltageOfCode_Unipolar (uint32_t value_u24) --> double -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: MAX11410 Command Name = VoltageOfCode_Bipolar_OffsetBinary (uint32_t value_u24) --> double -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: MAX11410 Command Name = VoltageOfCode_Bipolar_2sComplement (uint32_t value_u24) --> double -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: MAX11410 Command Name = VoltageOfCode (uint32_t value_u24) --> double -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: MAX11410 Command Name = RegWrite (MAX11410_CMD_enum_t regAddress, uint32_t regData) --> uint8_t -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: CommandDescriptionCMDWord = CMD_1aaa_aaaa_REGISTER_READ -// CODE GENERATOR: MAX11410 Command Name = RegWrite CMD_1aaa_aaaa_REGISTER_READ (MAX11410_CMD_enum_t regAddress, uint32_t regData) --> uint8_t -// CODE GENERATOR: MAX11410 Command Name = RegRead (MAX11410_CMD_enum_t regAddress, uint32_t* ptrRegData) --> uint8_t -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: CommandDescriptionCMDWord = CMD_1aaa_aaaa_REGISTER_READ -// CODE GENERATOR: MAX11410 Command Name = RegRead CMD_1aaa_aaaa_REGISTER_READ (MAX11410_CMD_enum_t regAddress, uint32_t* ptrRegData) --> uint8_t -// CODE GENERATOR: MAX11410 Command Name = RegSize (MAX11410_CMD_enum_t regAddress) --> uint8_t -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: MAX11410 Command Name = RegName (MAX11410_CMD_enum_t regAddress) --> const char* -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: MAX11410 Command Name = Configure_FILTER (uint8_t linef, uint8_t rate) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'XF' -// CODE GENERATOR: Menu item 'XF' -- Menu item XF -// CODE GENERATOR: MAX11410 help: XF uint8_t linef, uint8_t rate -- Configure_FILTER -// CODE GENERATOR: MAX11410 helpString: 'XF linef=? rate=? -- Configure_FILTER' -// CODE GENERATOR: test menu case 'XF': -// CODE GENERATOR: helpString 'XF linef=? rate=? -- Configure_FILTER' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_FILTER' -// CODE GENERATOR: CommandParamIn 'uint8_t linef, uint8_t rate' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] linef = filter type, default=MAX11410::MAX11410_LINEF_enum_t::LINEF_11_SINC4' -// CODE GENERATOR: CommandDocParamIn '@param[in] rate = output data rate selection, default=MAX11410::MAX11410_RATE_enum_t::RATE_0100' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Configure_PGA (uint8_t sigpath, uint8_t gain) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'XP' -// CODE GENERATOR: Menu item 'XP' -- Menu item XP -// CODE GENERATOR: MAX11410 help: XP uint8_t sigpath, uint8_t gain -- Configure_PGA -// CODE GENERATOR: MAX11410 helpString: 'XP sigpath=? gain=? -- Configure_PGA' -// CODE GENERATOR: test menu case 'XP': -// CODE GENERATOR: helpString 'XP sigpath=? gain=? -- Configure_PGA' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_PGA' -// CODE GENERATOR: CommandParamIn 'uint8_t sigpath, uint8_t gain' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] sigpath = signal path, default=MAX11410::MAX11410_SIG_PATH_enum_t::SIG_PATH_00_BUFFERED' -// CODE GENERATOR: CommandDocParamIn '@param[in] gain = gain selection, default=MAX11410::MAX11410_GAIN_enum_t::GAIN_000_1' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Configure_CTRL (uint8_t extclk, uint8_t u_bn, uint8_t format, uint8_t refbufp_en, uint8_t refbufn_en, uint8_t ref_sel) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'XC' -// CODE GENERATOR: Menu item 'XC' -- Menu item XC -// CODE GENERATOR: MAX11410 help: XC uint8_t extclk, uint8_t u_bn, uint8_t format, uint8_t refbufp_en, uint8_t refbufn_en, uint8_t ref_sel -- Configure_CTRL -// CODE GENERATOR: MAX11410 helpString: 'XC extclk=? u_bn=? format=? refbufp_en=? refbufn_en=? ref_sel=? -- Configure_CTRL' -// CODE GENERATOR: test menu case 'XC': -// CODE GENERATOR: helpString 'XC extclk=? u_bn=? format=? refbufp_en=? refbufn_en=? ref_sel=? -- Configure_CTRL' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_CTRL' -// CODE GENERATOR: CommandParamIn 'uint8_t extclk, uint8_t u_bn, uint8_t format, uint8_t refbufp_en, uint8_t refbufn_en, uint8_t ref_sel' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] extclk = external clock enable, default=0' -// CODE GENERATOR: CommandDocParamIn '@param[in] u_bn = unipolar input range enable, default=0' -// CODE GENERATOR: CommandDocParamIn '@param[in] format = offset binary format enable, default=0' -// CODE GENERATOR: CommandDocParamIn '@param[in] refbufp_en = REFP reference buffer enable, default=0' -// CODE GENERATOR: CommandDocParamIn '@param[in] refbufn_en = REFN reference buffer enable, default=0' -// CODE GENERATOR: CommandDocParamIn '@param[in] ref_sel = reference selection, default=MAX11410::MAX11410_REF_SEL_enum_t::REF_SEL_001_REF1P_REF1N' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Configure_SOURCE (uint8_t vbias_mode, uint8_t brn_mode, uint8_t idac_mode) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'XS' -// CODE GENERATOR: Menu item 'XS' -- Menu item XS -// CODE GENERATOR: MAX11410 help: XS uint8_t vbias_mode, uint8_t brn_mode, uint8_t idac_mode -- Configure_SOURCE -// CODE GENERATOR: MAX11410 helpString: 'XS vbias_mode=? brn_mode=? idac_mode=? -- Configure_SOURCE' -// CODE GENERATOR: test menu case 'XS': -// CODE GENERATOR: helpString 'XS vbias_mode=? brn_mode=? idac_mode=? -- Configure_SOURCE' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_SOURCE' -// CODE GENERATOR: CommandParamIn 'uint8_t vbias_mode, uint8_t brn_mode, uint8_t idac_mode' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] vbias_mode = _______, default=MAX11410::MAX11410_VBIAS_MODE_enum_t::VBIAS_MODE_00_Active' -// CODE GENERATOR: CommandDocParamIn '@param[in] brn_mode = _______, default=MAX11410::MAX11410_BRN_MODE_enum_t::BRN_MODE_00_disabled' -// CODE GENERATOR: CommandDocParamIn '@param[in] idac_mode = _______, default=MAX11410::MAX11410_IDAC_MODE_enum_t::IDAC_MODE_0000_10uA' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Configure_MUX_CTRL0 (uint8_t ainp, uint8_t ainn) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'XM' -// CODE GENERATOR: Menu item 'XM' -- Menu item XM -// CODE GENERATOR: MAX11410 help: XM uint8_t ainp, uint8_t ainn -- Configure_MUX_CTRL0 -// CODE GENERATOR: MAX11410 helpString: 'XM ainp=? ainn=? -- Configure_MUX_CTRL0' -// CODE GENERATOR: test menu case 'XM': -// CODE GENERATOR: helpString 'XM ainp=? ainn=? -- Configure_MUX_CTRL0' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_MUX_CTRL0' -// CODE GENERATOR: CommandParamIn 'uint8_t ainp, uint8_t ainn' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] ainp = channel high side, default=MAX11410::MAX11410_AINP_SEL_enum_t::AINP_SEL_0000_AIN0' -// CODE GENERATOR: CommandDocParamIn '@param[in] ainn = channel low side, default=MAX11410::MAX11410_AINN_SEL_enum_t::AINN_SEL_1010_GND' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Configure_MUX_CTRL1 (uint8_t idac1_sel, uint8_t idac0_sel) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'XI' -// CODE GENERATOR: Menu item 'XI' -- Menu item XI -// CODE GENERATOR: MAX11410 help: XI uint8_t idac1_sel, uint8_t idac0_sel -- Configure_MUX_CTRL1 -// CODE GENERATOR: MAX11410 helpString: 'XI idac1_sel=? idac0_sel=? -- Configure_MUX_CTRL1' -// CODE GENERATOR: test menu case 'XI': -// CODE GENERATOR: helpString 'XI idac1_sel=? idac0_sel=? -- Configure_MUX_CTRL1' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_MUX_CTRL1' -// CODE GENERATOR: CommandParamIn 'uint8_t idac1_sel, uint8_t idac0_sel' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] idac1_sel = channel high side, default=MAX11410::MAX11410_IDAC1_SEL_enum_t::IDAC1_SEL_1111_unconnected' -// CODE GENERATOR: CommandDocParamIn '@param[in] idac0_sel = channel low side, default=MAX11410::MAX11410_IDAC0_SEL_enum_t::IDAC0_SEL_1111_unconnected' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Configure_MUX_CTRL2 (uint8_t vbias_ain7_ain0_bitmap) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'XV' -// CODE GENERATOR: Menu item 'XV' -- Menu item XV -// CODE GENERATOR: MAX11410 help: XV uint8_t vbias_ain7_ain0_bitmap -- Configure_MUX_CTRL2 -// CODE GENERATOR: MAX11410 helpString: 'XV vbias_ain7_ain0_bitmap=? -- Configure_MUX_CTRL2' -// CODE GENERATOR: test menu case 'XV': -// CODE GENERATOR: helpString 'XV vbias_ain7_ain0_bitmap=? -- Configure_MUX_CTRL2' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_MUX_CTRL2' -// CODE GENERATOR: CommandParamIn 'uint8_t vbias_ain7_ain0_bitmap' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] vbias_ain7_ain0_bitmap = bit map of AIN7..AIN0 enables for voltage bias, default=0' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Calibrate_Self_Offset_Gain (void) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'X0' -// CODE GENERATOR: Menu item 'X0' -- Menu item X0 -// CODE GENERATOR: test menu case 'X0': -// CODE GENERATOR: helpString 'X0 -- Calibrate_Self_Offset_Gain' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_Self_Offset_Gain' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Calibrate_PGA_Gain (void) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'X1' -// CODE GENERATOR: Menu item 'X1' -- Menu item X1 -// CODE GENERATOR: test menu case 'X1': -// CODE GENERATOR: helpString 'X1 -- Calibrate_PGA_Gain' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_PGA_Gain' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Calibrate_System_Offset_A (void) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'X4' -// CODE GENERATOR: Menu item 'X4' -- Menu item X4 -// CODE GENERATOR: test menu case 'X4': -// CODE GENERATOR: helpString 'X4 -- Calibrate_System_Offset_A' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_System_Offset_A' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Calibrate_System_Gain_A (void) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'X5' -// CODE GENERATOR: Menu item 'X5' -- Menu item X5 -// CODE GENERATOR: test menu case 'X5': -// CODE GENERATOR: helpString 'X5 -- Calibrate_System_Gain_A' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_System_Gain_A' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Calibrate_System_Offset_B (void) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'X6' -// CODE GENERATOR: Menu item 'X6' -- Menu item X6 -// CODE GENERATOR: test menu case 'X6': -// CODE GENERATOR: helpString 'X6 -- Calibrate_System_Offset_B' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_System_Offset_B' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Calibrate_System_Gain_B (void) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item 'X7' -// CODE GENERATOR: Menu item 'X7' -- Menu item X7 -// CODE GENERATOR: test menu case 'X7': -// CODE GENERATOR: helpString 'X7 -- Calibrate_System_Gain_B' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_System_Gain_B' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Configure_Voltage (MAX11410_AINP_SEL_enum_t ainp, MAX11410_AINN_SEL_enum_t ainn) --> uint8_t -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: MAX11410 Command Name = Read_All_Voltages (void) --> uint8_t -// CODE GENERATOR: Menu item hint description Menu item '$' -// CODE GENERATOR: Menu item '$' -- Menu item $ -// CODE GENERATOR: test menu case '$': -// CODE GENERATOR: helpString '$ -- Read_All_Voltages' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Read_All_Voltages' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '@post AINcode[0..10]: measurement result LSB code' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = Measure_Voltage (MAX11410_AINP_SEL_enum_t ainp, MAX11410_AINN_SEL_enum_t ainn) --> double -// CODE GENERATOR: Menu item hint description Menu item 'V' -// CODE GENERATOR: Menu item 'V' -- Menu item V -// CODE GENERATOR: MAX11410 help: V MAX11410_AINP_SEL_enum_t ainp, MAX11410_AINN_SEL_enum_t ainn -- Measure_Voltage -// CODE GENERATOR: MAX11410 helpString: 'V -- Measure_Voltage' -// CODE GENERATOR: test menu case 'V': -// CODE GENERATOR: helpString 'V -- Measure_Voltage' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Measure_Voltage' -// CODE GENERATOR: CommandParamIn 'MAX11410_AINP_SEL_enum_t ainp, MAX11410_AINN_SEL_enum_t ainn' -// CODE GENERATOR: CommandReturnType 'double' -// CODE GENERATOR: CommandPre '@pre external connection REF2P-REF2N is a reference voltage' -// CODE GENERATOR: CommandPre '@pre VRef = Voltage of REF input, in Volts' -// CODE GENERATOR: CommandDocParamIn '@param[in] ainp = channel high side, default=AINP_SEL_0000_AIN0' -// CODE GENERATOR: CommandDocParamIn '@param[in] ainn = channel low side, default=AINN_SEL_1010_GND' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '@post AINcode[ainp]: measurement result LSB code' -// CODE GENERATOR: CommandReturn '@return ideal voltage calculated from raw LSB code and reference voltage' -// CODE GENERATOR: MAX11410 Command Name = Configure_RTD (MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn) --> uint8_t -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: MAX11410 Command Name = Measure_RTD (MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn) --> double -// CODE GENERATOR: Menu item hint description Menu item 'R' -> rtd_resistance, RTD_Temperature -// CODE GENERATOR: Menu item 'R' -> rtd_resistance, RTD_Temperature -- Menu item R -// CODE GENERATOR: MAX11410 help: R MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn -- Measure_RTD -// CODE GENERATOR: MAX11410 helpString: 'R -- Measure_RTD' -// CODE GENERATOR: test menu case 'R': -// CODE GENERATOR: helpString 'R -- Measure_RTD' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Measure_RTD' -// CODE GENERATOR: CommandParamIn 'MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn' -// CODE GENERATOR: CommandReturnType 'double' -// CODE GENERATOR: CommandPre '@pre external connection REF1P-REF1N is a reference resistor' -// CODE GENERATOR: CommandPre '@pre VRef_REF1 = reference resistance in ohms, default=4999' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_iout = channel RTD high side force, default=AINP_SEL_0111_AIN7' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_ainp = channel RTD high side sense, default=AINP_SEL_1000_AIN8' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_ainn = channel RTD low side, default=AINN_SEL_1001_AIN9' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '@post AINcode[rtd_ainp]: measurement result LSB code' -// CODE GENERATOR: CommandPost '@post rtd_resistance: measurement result resistance in Ohms' -// CODE GENERATOR: CommandPost '@post RTD_Temperature: Temperature calculated from RTD Resistance; Thermocouple Cold Junction, in degrees C' -// CODE GENERATOR: CommandReturn '@return resistance calculated from raw LSB code and reference resistance' -// CODE GENERATOR: MAX11410 Command Name = TemperatureOfRTD_PT1000 (double rtd_resistance) --> double -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: MAX11410 Command Name = Configure_Thermocouple (MAX11410_AINP_SEL_enum_t tc_ainp, MAX11410_AINN_SEL_enum_t tc_ainn, MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn) --> uint8_t -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: MAX11410 Command Name = Measure_Thermocouple (MAX11410_AINP_SEL_enum_t tc_ainp, MAX11410_AINN_SEL_enum_t tc_ainn, MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn) --> double -// CODE GENERATOR: Menu item hint description Menu item 'TM' -// CODE GENERATOR: Menu item 'TM' -- Menu item TM -// CODE GENERATOR: MAX11410 help: TM MAX11410_AINP_SEL_enum_t tc_ainp, MAX11410_AINN_SEL_enum_t tc_ainn, MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn -- Measure_Thermocouple -// CODE GENERATOR: MAX11410 helpString: 'TM -- Measure_Thermocouple' -// CODE GENERATOR: test menu case 'TM': -// CODE GENERATOR: helpString 'TM -- Measure_Thermocouple' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Measure_Thermocouple' -// CODE GENERATOR: CommandParamIn 'MAX11410_AINP_SEL_enum_t tc_ainp, MAX11410_AINN_SEL_enum_t tc_ainn, MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn' -// CODE GENERATOR: CommandReturnType 'double' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] tc_ainp = channel of Thermocouple high side, default=AINP_SEL_0101_AIN5' -// CODE GENERATOR: CommandDocParamIn '@param[in] tc_ainn = channel of Thermocouple low side, default=AINN_SEL_0110_AIN6' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_iout = channel RTD high side force, default=AINP_SEL_0111_AIN7' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_ainp = channel RTD high side sense, default=AINP_SEL_1000_AIN8' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_ainn = channel RTD low side, default=AINN_SEL_1001_AIN9' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '@post AINcode[tc_ainp]: measurement result LSB code' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' -// CODE GENERATOR: MAX11410 Command Name = TemperatureOfTC_TypeK (double tc_voltage) --> double -// CODE GENERATOR: Menu item hint description Menu item 'TK' -// CODE GENERATOR: Menu item 'TK' -- Menu item TK -// CODE GENERATOR: MAX11410 help: TK double tc_voltage -- TemperatureOfTC_TypeK -// CODE GENERATOR: MAX11410 helpString: 'TK tc_voltage=? -- TemperatureOfTC_TypeK' -// CODE GENERATOR: test menu case 'TK': -// CODE GENERATOR: helpString 'TK tc_voltage=? -- TemperatureOfTC_TypeK' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'TemperatureOfTC_TypeK' -// CODE GENERATOR: CommandParamIn 'double tc_voltage' -// CODE GENERATOR: CommandReturnType 'double' -// CODE GENERATOR: CommandPre '@pre {0}.RTD_Temperature = cold junction temperature, in degrees C' -// CODE GENERATOR: CommandDocParamIn '@param[in] tc_voltage = Thermocouple voltage in volts, default=0.0254' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return ideal temperature in degrees C, calculated from RTD resistance in ohms' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(0.000e-3) expect 0.0 within 0.1 TC_TypeK at 0C = 0.000mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(0.039e-3) expect 1.0 within 0.1 TC_TypeK at 1C = 0.039mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(0.079e-3) expect 2.0 within 0.1 TC_TypeK at 2C = 0.079mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(0.119e-3) expect 3.0 within 0.1 TC_TypeK at 3C = 0.119mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(0.158e-3) expect 4.0 within 0.1 TC_TypeK at 4C = 0.158mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(0.198e-3) expect 5.0 within 0.1 TC_TypeK at 5C = 0.198mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(0.238e-3) expect 6.0 within 0.1 TC_TypeK at 6C = 0.238mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(0.2775e-3) expect 7.0 within 0.1 TC_TypeK at 7C = 0.2775mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(0.317e-3) expect 8.0 within 0.1 TC_TypeK at 8C = 0.317mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(0.357e-3) expect 9.0 within 0.1 TC_TypeK at 9C = 0.357mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(0.397e-3) expect 10.0 within 0.1 TC_TypeK at 10C = 0.397mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(0.798e-3) expect 20.0 within 0.1 TC_TypeK at 20C = 0.798mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(1.081e-3) expect 27.0 within 0.1 TC_TypeK at 27C = 1.081mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(1.203e-3) expect 30.0 within 0.1 TC_TypeK at 30C = 1.203mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(1.612e-3) expect 40.0 within 0.1 TC_TypeK at 40C = 1.612mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(2.023e-3) expect 50.0 within 0.1 TC_TypeK at 50C = 2.023mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(2.436e-3) expect 60.0 within 0.1 TC_TypeK at 60C = 2.436mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(2.851e-3) expect 70.0 within 0.1 TC_TypeK at 70C = 2.851mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(3.267e-3) expect 80.0 within 0.1 TC_TypeK at 80C = 3.267mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(3.682e-3) expect 90.0 within 0.1 TC_TypeK at 90C = 3.682mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(4.096e-3) expect 100.0 within 0.1 TC_TypeK at 100C = 4.096mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(4.509e-3) expect 110.0 within 0.1 TC_TypeK at 110C = 4.509mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(4.920e-3) expect 120.0 within 0.1 TC_TypeK at 120C = 4.920mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(5.328e-3) expect 130.0 within 0.1 TC_TypeK at 130C = 5.328mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(5.735e-3) expect 140.0 within 0.1 TC_TypeK at 140C = 5.735mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(6.138e-3) expect 150.0 within 0.1 TC_TypeK at 150C = 6.138mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(6.540e-3) expect 160.0 within 0.1 TC_TypeK at 160C = 6.540mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(6.941e-3) expect 170.0 within 0.1 TC_TypeK at 170C = 6.941mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(7.340e-3) expect 180.0 within 0.1 TC_TypeK at 180C = 7.340mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(7.739e-3) expect 190.0 within 0.1 TC_TypeK at 190C = 7.739mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(8.138e-3) expect 200.0 within 0.1 TC_TypeK at 200C = 8.138mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(8.539e-3) expect 210.0 within 0.1 TC_TypeK at 210C = 8.539mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(8.940e-3) expect 220.0 within 0.1 TC_TypeK at 220C = 8.940mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(9.343e-3) expect 230.0 within 0.1 TC_TypeK at 230C = 9.343mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(9.747e-3) expect 240.0 within 0.1 TC_TypeK at 240C = 9.747mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(10.153e-3) expect 250.0 within 0.1 TC_TypeK at 250C = 10.153mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(10.561e-3) expect 260.0 within 0.1 TC_TypeK at 260C = 10.561mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(10.971e-3) expect 270.0 within 0.1 TC_TypeK at 270C = 10.971mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(11.382e-3) expect 280.0 within 0.1 TC_TypeK at 280C = 11.382mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(11.795e-3) expect 290.0 within 0.1 TC_TypeK at 290C = 11.795mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(12.209e-3) expect 300.0 within 0.1 TC_TypeK at 300C = 12.209mV' -// CODE GENERATOR: CommandDocTest '@test group TC_2 TemperatureOfTC_TypeK(14.293e-3) expect 350.0 within 0.1 TC_TypeK at 350C = 14.293mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(16.397e-3) expect 400.0 within 0.1 TC_TypeK at 400C = 16.397mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(18.516e-3) expect 450.0 within 0.1 TC_TypeK at 450C = 18.516mV' -// CODE GENERATOR: CommandDocTest '@test group TC_1 TemperatureOfTC_TypeK(20.218e-3) expect 490.0 TC_TypeK at 490C = 20.218mV' -// CODE GENERATOR: MAX11410 Command Name = temperatureDegC_polynomial (double thermocouple_voltage_uV, int num_coefficients, double coefficients[]) --> double -// CODE GENERATOR: no Menu item hint in description -// CODE GENERATOR: testMenuGlobalArgsDict scan global property list g_MAX11410_device - -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.VRef_REF0 -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.VRef_REF0 argname = VRef_REF0 -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF0']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF0']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF0']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF0']['usedBytestMenuItemName'] = 'None' - -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.VRef_REF1 -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.VRef_REF1 argname = VRef_REF1 -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF1']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF1']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF1']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF1']['usedBytestMenuItemName'] = 'None' - -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.VRef_REF2 -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.VRef_REF2 argname = VRef_REF2 -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF2']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF2']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF2']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF2']['usedBytestMenuItemName'] = 'None' - -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.VRef_AVDD -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.VRef_AVDD argname = VRef_AVDD -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_AVDD']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_AVDD']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_AVDD']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_AVDD']['usedBytestMenuItemName'] = 'None' - -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.rtd_resistance -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.rtd_resistance argname = rtd_resistance -// CODE GENERATOR: testMenuGlobalArgsDict['rtd_resistance']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['rtd_resistance']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['rtd_resistance']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['rtd_resistance']['usedBytestMenuItemName'] = 'None' - -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.RTD_Temperature -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.RTD_Temperature argname = RTD_Temperature -// CODE GENERATOR: testMenuGlobalArgsDict['RTD_Temperature']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['RTD_Temperature']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['RTD_Temperature']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['RTD_Temperature']['usedBytestMenuItemName'] = 'None' - -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.ctrl -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.ctrl shadow of argname = ctrl -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.ctrl argname = ctrl -// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['argtype'] = 'uint32_t' -// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['usedBytestMenuItemName'] = 'None' - -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.pgaGain -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.pgaGain argname = pgaGain -// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['argtype'] = 'uint8_t' -// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['usedBytestMenuItemName'] = 'None' - -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.status -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.status shadow of argname = status -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.status argname = status -// CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint32_t' -// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None' - -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.data0 -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.data0 shadow of argname = data0 -// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.data0 argname = data0 -// CODE GENERATOR: testMenuGlobalArgsDict['data0']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['data0']['argtype'] = 'uint32_t' -// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedBytestMenuItemName'] = 'None' - -// CODE GENERATOR: testMenuGlobalArgsDict skip array property g_MAX11410_device.AINcode[11] - -// CODE GENERATOR: scan testMenuCommand list for items that can be shortened to single character -// CODE GENERATOR: multiple commands begin with character 'T' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: multiple commands begin with character 'X' -// CODE GENERATOR: shorten testMenuCommand to single character if unambiguous -// CODE GENERATOR: testMenuCommand '!' already single character -// CODE GENERATOR: testMenuCommand '$' already single character -// CODE GENERATOR: testMenuCommand 'R' already single character -// CODE GENERATOR: cannot shorten testMenuCommand 'TK' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'TM' to single character due to duplicates -// CODE GENERATOR: testMenuCommand 'V' already single character -// CODE GENERATOR: cannot shorten testMenuCommand 'X0' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'X1' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'X4' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'X5' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'X6' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'X7' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'XC' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'XF' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'XI' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'XM' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'XP' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'XS' to single character due to duplicates -// CODE GENERATOR: cannot shorten testMenuCommand 'XV' to single character due to duplicates - -// CODE GENERATOR: help menu -bool MAX11410_menu_help(CmdLine & cmdLine) -{ - // CODE GENERATOR: command: ! - // CODE GENERATOR: help: ! -- Init - cmdLine.serial().printf("\r\n ! -- Init"); - // CODE GENERATOR: command: $ - // CODE GENERATOR: help: $ -- Read_All_Voltages - cmdLine.serial().printf("\r\n $ -- Read_All_Voltages"); - // CODE GENERATOR: command: R - // CODE GENERATOR: help: R -- Measure_RTD - cmdLine.serial().printf("\r\n R -- Measure_RTD"); - // CODE GENERATOR: command: TK - // CODE GENERATOR: help: TK tc_voltage=? -- TemperatureOfTC_TypeK - cmdLine.serial().printf("\r\n TK tc_voltage=? -- TemperatureOfTC_TypeK"); - // CODE GENERATOR: command: TM - // CODE GENERATOR: help: TM -- Measure_Thermocouple - cmdLine.serial().printf("\r\n TM -- Measure_Thermocouple"); - // CODE GENERATOR: command: V - // CODE GENERATOR: help: V -- Measure_Voltage - cmdLine.serial().printf("\r\n V -- Measure_Voltage"); - // CODE GENERATOR: command: X0 - // CODE GENERATOR: help: X0 -- Calibrate_Self_Offset_Gain - cmdLine.serial().printf("\r\n X0 -- Calibrate_Self_Offset_Gain"); - // CODE GENERATOR: command: X1 - // CODE GENERATOR: help: X1 -- Calibrate_PGA_Gain - cmdLine.serial().printf("\r\n X1 -- Calibrate_PGA_Gain"); - // CODE GENERATOR: command: X4 - // CODE GENERATOR: help: X4 -- Calibrate_System_Offset_A - cmdLine.serial().printf("\r\n X4 -- Calibrate_System_Offset_A"); - // CODE GENERATOR: command: X5 - // CODE GENERATOR: help: X5 -- Calibrate_System_Gain_A - cmdLine.serial().printf("\r\n X5 -- Calibrate_System_Gain_A"); - // CODE GENERATOR: command: X6 - // CODE GENERATOR: help: X6 -- Calibrate_System_Offset_B - cmdLine.serial().printf("\r\n X6 -- Calibrate_System_Offset_B"); - // CODE GENERATOR: command: X7 - // CODE GENERATOR: help: X7 -- Calibrate_System_Gain_B - cmdLine.serial().printf("\r\n X7 -- Calibrate_System_Gain_B"); - // CODE GENERATOR: command: XC - // CODE GENERATOR: help: XC extclk=? u_bn=? format=? refbufp_en=? refbufn_en=? ref_sel=? -- Configure_CTRL - cmdLine.serial().printf("\r\n XC extclk=? u_bn=? format=? refbufp_en=? refbufn_en=? ref_sel=? -- Configure_CTRL"); - // CODE GENERATOR: command: XF - // CODE GENERATOR: help: XF linef=? rate=? -- Configure_FILTER - cmdLine.serial().printf("\r\n XF linef=? rate=? -- Configure_FILTER"); - // CODE GENERATOR: command: XI - // CODE GENERATOR: help: XI idac1_sel=? idac0_sel=? -- Configure_MUX_CTRL1 - cmdLine.serial().printf("\r\n XI idac1_sel=? idac0_sel=? -- Configure_MUX_CTRL1"); - // CODE GENERATOR: command: XM - // CODE GENERATOR: help: XM ainp=? ainn=? -- Configure_MUX_CTRL0 - cmdLine.serial().printf("\r\n XM ainp=? ainn=? -- Configure_MUX_CTRL0"); - // CODE GENERATOR: command: XP - // CODE GENERATOR: help: XP sigpath=? gain=? -- Configure_PGA - cmdLine.serial().printf("\r\n XP sigpath=? gain=? -- Configure_PGA"); - // CODE GENERATOR: command: XS - // CODE GENERATOR: help: XS vbias_mode=? brn_mode=? idac_mode=? -- Configure_SOURCE - cmdLine.serial().printf("\r\n XS vbias_mode=? brn_mode=? idac_mode=? -- Configure_SOURCE"); - // CODE GENERATOR: command: XV - // CODE GENERATOR: help: XV vbias_ain7_ain0_bitmap=? -- Configure_MUX_CTRL2 - cmdLine.serial().printf("\r\n XV vbias_ain7_ain0_bitmap=? -- Configure_MUX_CTRL2"); - // - cmdLine.serial().printf("\r\n @ -- print MAX11410 configuration"); - -// CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register - cmdLine.serial().printf("\r\n *regname? -- read register\r\n *regname=regvalue -- write register"); - - // -// CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names (menu_help) - // case 'G'..'Z','g'..'z' are reserved for GPIO commands - // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands - - // -} - -bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine) -{ - -// CODE GENERATOR: testMenuGlobalArgsDict Consolidate common/global argument parsing - -// CODE GENERATOR: testMenuGlobalArgsDict['RTD_Temperature']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['RTD_Temperature']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['RTD_Temperature']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['RTD_Temperature']['usedBytestMenuItemName'] = 'None' - // parse argument double RTD_Temperature - double RTD_Temperature = g_MAX11410_device.RTD_Temperature; // default to global property value - if (cmdLine.parse_double("RTD_Temperature", RTD_Temperature)) - { - g_MAX11410_device.RTD_Temperature = RTD_Temperature; // update global property value - } - -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_AVDD']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_AVDD']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_AVDD']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_AVDD']['usedBytestMenuItemName'] = 'None' - // parse argument double VRef_AVDD - double VRef_AVDD = g_MAX11410_device.VRef_AVDD; // default to global property value - if (cmdLine.parse_double("VRef_AVDD", VRef_AVDD)) - { - g_MAX11410_device.VRef_AVDD = VRef_AVDD; // update global property value - } - -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF0']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF0']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF0']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF0']['usedBytestMenuItemName'] = 'None' - // parse argument double VRef_REF0 - double VRef_REF0 = g_MAX11410_device.VRef_REF0; // default to global property value - if (cmdLine.parse_double("VRef_REF0", VRef_REF0)) - { - g_MAX11410_device.VRef_REF0 = VRef_REF0; // update global property value - } - -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF1']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF1']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF1']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF1']['usedBytestMenuItemName'] = 'None' - // parse argument double VRef_REF1 - double VRef_REF1 = g_MAX11410_device.VRef_REF1; // default to global property value - if (cmdLine.parse_double("VRef_REF1", VRef_REF1)) - { - g_MAX11410_device.VRef_REF1 = VRef_REF1; // update global property value - } - -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF2']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF2']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF2']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['VRef_REF2']['usedBytestMenuItemName'] = 'None' - // parse argument double VRef_REF2 - double VRef_REF2 = g_MAX11410_device.VRef_REF2; // default to global property value - if (cmdLine.parse_double("VRef_REF2", VRef_REF2)) - { - g_MAX11410_device.VRef_REF2 = VRef_REF2; // update global property value - } - -// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['argtype'] = 'uint32_t' -// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['ctrl']['usedBytestMenuItemName'] = 'None' - // parse argument uint32_t ctrl - uint32_t ctrl = g_MAX11410_device.ctrl; // default to global property value - if (cmdLine.parse_uint32_dec("ctrl", ctrl)) - { - g_MAX11410_device.ctrl = ctrl; // update global property value - } - -// CODE GENERATOR: testMenuGlobalArgsDict['data0']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['data0']['argtype'] = 'uint32_t' -// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedBytestMenuItemName'] = 'None' - // parse argument uint32_t data0 - uint32_t data0 = g_MAX11410_device.data0; // default to global property value - if (cmdLine.parse_uint32_dec("data0", data0)) - { - g_MAX11410_device.data0 = data0; // update global property value - } - -// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['argtype'] = 'uint8_t' -// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['pgaGain']['usedBytestMenuItemName'] = 'None' - // parse argument uint8_t pgaGain - uint8_t pgaGain = g_MAX11410_device.pgaGain; // default to global property value - if (cmdLine.parse_uint8_dec("pgaGain", pgaGain)) - { - g_MAX11410_device.pgaGain = pgaGain; // update global property value - } - -// CODE GENERATOR: testMenuGlobalArgsDict['rtd_resistance']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['rtd_resistance']['argtype'] = 'double' -// CODE GENERATOR: testMenuGlobalArgsDict['rtd_resistance']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['rtd_resistance']['usedBytestMenuItemName'] = 'None' - // parse argument double rtd_resistance - double rtd_resistance = g_MAX11410_device.rtd_resistance; // default to global property value - if (cmdLine.parse_double("rtd_resistance", rtd_resistance)) - { - g_MAX11410_device.rtd_resistance = rtd_resistance; // update global property value - } - -// CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint32_t' -// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None' -// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None' - // parse argument uint32_t status - uint32_t status = g_MAX11410_device.status; // default to global property value - if (cmdLine.parse_uint32_dec("status", status)) - { - g_MAX11410_device.status = status; // update global property value - } - - switch (cmdLine[0]) - { -// CODE GENERATOR: generate * command read/write reg *reg? *reg=value - case '*': - { - // if buffer starts with a regName: - // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))): - cmdLine.serial().printf(" scan RegName... "); - for (uint8_t regAddress = 0; regAddress < 0x80; regAddress++) - { - uint32_t regData = 0; - bool is_regname_query = false; - bool is_regname_assignment = false; - if (cmdLine.parse_uint32_dec(g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress), regData)) - { - cmdLine.serial().printf(" regAddress=0x%2.2X\r\n", (regAddress & 0xFF)); - cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress)); - // accept regName "?" as "RegRead" by name - is_regname_query = (cmdLine.chSeparator == '?'); - is_regname_assignment = (cmdLine.chSeparator == '='); - if (is_regname_query) - { - cmdLine.serial().printf(" RegRead"); - g_MAX11410_device.RegRead((MAX11410::MAX11410_CMD_enum_t)regAddress, ®Data); - cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF)); - return true; // command handled by MAX11410 - } - // accept regName "=0x123456" as "RegWrite" by name - if (is_regname_assignment) - { - cmdLine.serial().printf(" RegWrite"); - cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF)); - g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData); - return true; // command handled by MAX11410 - } - } - } // end for regAddr - // not a valid register name - // read "all" registers by name - const uint8_t readAllRegFirst = 0x00; // first MAX11410 register address for read-all block - const uint8_t readAllRegLast = 0x39; // last MAX11410 register address for read-all block - Callback<void(size_t, uint8_t*, uint8_t*)> saved_onSPIprint_handler = g_MAX11410_device.onSPIprint; - g_MAX11410_device.onSPIprint = NULL; - for (uint8_t regAddress = readAllRegFirst; regAddress <= readAllRegLast; regAddress++) - { - uint32_t regData = 0; - if (g_MAX11410_device.RegSize((MAX11410::MAX11410_CMD_enum_t)regAddress) == 0) continue; // skip undefined regs - if (g_MAX11410_device.RegRead((MAX11410::MAX11410_CMD_enum_t)regAddress, ®Data) == 0) continue; // skip unreadable regs - cmdLine.serial().printf("%s=0x%6.6x\r\n", g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress), regData); - } // end for regAddr - g_MAX11410_device.onSPIprint = saved_onSPIprint_handler; - return true; // command handled by MAX11410 - } - break; - -// CODE GENERATOR: generate @ command print global property values of g_MAX11410_device - case '@': - { -// CODE GENERATOR: @ command print double g_MAX11410_device.VRef_REF0 - cmdLine.serial().printf("VRef_REF0 = "); - cmdLine.serial().printf("%f\n", g_MAX11410_device.VRef_REF0); -// CODE GENERATOR: @ command print double g_MAX11410_device.VRef_REF1 - cmdLine.serial().printf("VRef_REF1 = "); - cmdLine.serial().printf("%f\n", g_MAX11410_device.VRef_REF1); -// CODE GENERATOR: @ command print double g_MAX11410_device.VRef_REF2 - cmdLine.serial().printf("VRef_REF2 = "); - cmdLine.serial().printf("%f\n", g_MAX11410_device.VRef_REF2); -// CODE GENERATOR: @ command print double g_MAX11410_device.VRef_AVDD - cmdLine.serial().printf("VRef_AVDD = "); - cmdLine.serial().printf("%f\n", g_MAX11410_device.VRef_AVDD); -// CODE GENERATOR: @ command print double g_MAX11410_device.rtd_resistance - cmdLine.serial().printf("rtd_resistance = "); - cmdLine.serial().printf("%f\n", g_MAX11410_device.rtd_resistance); -// CODE GENERATOR: @ command print double g_MAX11410_device.RTD_Temperature - cmdLine.serial().printf("RTD_Temperature = "); - cmdLine.serial().printf("%f\n", g_MAX11410_device.RTD_Temperature); -// CODE GENERATOR: @ command print uint32_t g_MAX11410_device.ctrl - cmdLine.serial().printf("ctrl = "); - cmdLine.serial().printf("%d = 0x%8.8x\n", g_MAX11410_device.ctrl, g_MAX11410_device.ctrl); -// CODE GENERATOR: @ command print uint8_t g_MAX11410_device.pgaGain - cmdLine.serial().printf("pgaGain = "); - cmdLine.serial().printf("%d = 0x%2.2x\n", g_MAX11410_device.pgaGain, g_MAX11410_device.pgaGain); -// CODE GENERATOR: @ command print uint32_t g_MAX11410_device.status - cmdLine.serial().printf("status = "); - cmdLine.serial().printf("%d = 0x%8.8x\n", g_MAX11410_device.status, g_MAX11410_device.status); -// CODE GENERATOR: @ command print uint32_t g_MAX11410_device.data0 - cmdLine.serial().printf("data0 = "); - cmdLine.serial().printf("%d = 0x%8.8x\n", g_MAX11410_device.data0, g_MAX11410_device.data0); -// CODE GENERATOR: @ command print uint32_t array g_MAX11410_device.AINcode[0..10] - for(int index = 0; (index < 11) && (index < 16); index++) { - cmdLine.serial().printf("AINcode[%d] = ", index); - cmdLine.serial().printf("%d = 0x%8.8x\n", g_MAX11410_device.AINcode[index], g_MAX11410_device.AINcode[index]); - } - return true; // command handled by MAX11410 - break; - } -// CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names - // case 'G'..'Z','g'..'z' are reserved for GPIO commands - // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands - -// CODE GENERATOR: test menu - // case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands - // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands -// CODE GENERATOR: top of loop: testMenuCommand="!", testMenuFirstCharHandler="None" -// CODE GENERATOR: test menu case '!': -// CODE GENERATOR: helpString '! -- Init' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Init' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - // case '!': // (single character) (testMenuFirstCharHandler="None") - case '!': - { - // test menu command '!' handler: - // helpString='! -- Init' - // CMD_='None' - // CommandName='Init' - // CommandParamIn='void' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - cmdLine.serial().printf("Init"); - // call function Init - uint8_t result = g_MAX11410_device.Init(); - cmdLine.serial().printf(" =%d", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="!", testMenuFirstCharHandler="None" - } // end case '!' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="$", testMenuFirstCharHandler="None" -// CODE GENERATOR: test menu case '$': -// CODE GENERATOR: helpString '$ -- Read_All_Voltages' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Read_All_Voltages' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '@post AINcode[0..10]: measurement result LSB code' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - // case '$': // (single character) (testMenuFirstCharHandler="None") - case '$': - { - // test menu command '$' handler: - // helpString='$ -- Read_All_Voltages' - // CMD_='None' - // CommandName='Read_All_Voltages' - // CommandParamIn='void' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='' - // @Param[out]='' - // @Post='@post AINcode[0..10]: measurement result LSB code' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - cmdLine.serial().printf("Read_All_Voltages"); - // call function Read_All_Voltages - uint8_t result = g_MAX11410_device.Read_All_Voltages(); - cmdLine.serial().printf(" =%d", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="$", testMenuFirstCharHandler="None" - } // end case '$' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="R", testMenuFirstCharHandler="None" -// CODE GENERATOR: test menu case 'R': -// CODE GENERATOR: helpString 'R -- Measure_RTD' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Measure_RTD' -// CODE GENERATOR: CommandParamIn 'MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn' -// CODE GENERATOR: CommandReturnType 'double' -// CODE GENERATOR: CommandPre '@pre external connection REF1P-REF1N is a reference resistor' -// CODE GENERATOR: CommandPre '@pre VRef_REF1 = reference resistance in ohms, default=4999' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_iout = channel RTD high side force, default=AINP_SEL_0111_AIN7' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_ainp = channel RTD high side sense, default=AINP_SEL_1000_AIN8' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_ainn = channel RTD low side, default=AINN_SEL_1001_AIN9' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '@post AINcode[rtd_ainp]: measurement result LSB code' -// CODE GENERATOR: CommandPost '@post rtd_resistance: measurement result resistance in Ohms' -// CODE GENERATOR: CommandPost '@post RTD_Temperature: Temperature calculated from RTD Resistance; Thermocouple Cold Junction, in degrees C' -// CODE GENERATOR: CommandReturn '@return resistance calculated from raw LSB code and reference resistance' - // case 'R': // (single character) (testMenuFirstCharHandler="None") - case 'R': - { - // test menu command 'R' handler: - // helpString='R -- Measure_RTD' - // CMD_='None' - // CommandName='Measure_RTD' - // CommandParamIn='MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn' - // CommandReturnType='double' - // @Pre='@pre external connection REF1P-REF1N is a reference resistor' - // @Pre='@pre VRef_REF1 = reference resistance in ohms, default=4999' - // @Param[in]='@param[in] rtd_iout = channel RTD high side force, default=AINP_SEL_0111_AIN7' - // @Param[in]='@param[in] rtd_ainp = channel RTD high side sense, default=AINP_SEL_1000_AIN8' - // @Param[in]='@param[in] rtd_ainn = channel RTD low side, default=AINN_SEL_1001_AIN9' - // @Param[out]='' - // @Post='@post AINcode[rtd_ainp]: measurement result LSB code' - // @Post='@post rtd_resistance: measurement result resistance in Ohms' - // @Post='@post RTD_Temperature: Temperature calculated from RTD Resistance; Thermocouple Cold Junction, in degrees C' - // displayPost='rtd_resistance, RTD_Temperature' - // @Return='@return resistance calculated from raw LSB code and reference resistance' - // parse argument list - // argname default_argvalue symbolic enum name specified in CommandDocParamIn @Param[in]='@param[in] rtd_iout = channel RTD high side force, default=AINP_SEL_0111_AIN7' - // parse argument MAX11410::MAX11410_AINP_SEL_enum_t rtd_iout - MAX11410::MAX11410_AINP_SEL_enum_t rtd_iout = MAX11410::AINP_SEL_0111_AIN7; // --- g_MAX11410_device.__WARNING_no_match_for_argname_rtd_iout_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("rtd_iout", (uint8_t&)rtd_iout)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_rtd_iout_in_MAX11410_device_t__ = rtd_iout; // update global property value - } - // argname default_argvalue symbolic enum name specified in CommandDocParamIn @Param[in]='@param[in] rtd_ainp = channel RTD high side sense, default=AINP_SEL_1000_AIN8' - // parse argument MAX11410::MAX11410_AINP_SEL_enum_t rtd_ainp - MAX11410::MAX11410_AINP_SEL_enum_t rtd_ainp = MAX11410::AINP_SEL_1000_AIN8; // --- g_MAX11410_device.__WARNING_no_match_for_argname_rtd_ainp_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("rtd_ainp", (uint8_t&)rtd_ainp)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_rtd_ainp_in_MAX11410_device_t__ = rtd_ainp; // update global property value - } - // argname default_argvalue symbolic enum name specified in CommandDocParamIn @Param[in]='@param[in] rtd_ainn = channel RTD low side, default=AINN_SEL_1001_AIN9' - // parse argument MAX11410::MAX11410_AINN_SEL_enum_t rtd_ainn - MAX11410::MAX11410_AINN_SEL_enum_t rtd_ainn = MAX11410::AINN_SEL_1001_AIN9; // --- g_MAX11410_device.__WARNING_no_match_for_argname_rtd_ainn_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("rtd_ainn", (uint8_t&)rtd_ainn)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_rtd_ainn_in_MAX11410_device_t__ = rtd_ainn; // update global property value - } - // print arguments - cmdLine.serial().printf("Measure_RTD"); - cmdLine.serial().printf(" rtd_iout=%d", rtd_iout); - cmdLine.serial().printf(" rtd_ainp=%d", rtd_ainp); - cmdLine.serial().printf(" rtd_ainn=%d", rtd_ainn); - cmdLine.serial().printf(" Measure_RTD"); // unique suffix - cmdLine.serial().printf("\r\n"); - // call function Measure_RTD(rtd_iout, rtd_ainp, rtd_ainn) - double result = g_MAX11410_device.Measure_RTD(rtd_iout, rtd_ainp, rtd_ainn); - cmdLine.serial().printf(" =%f\r\n", result); - // Menu item 'R' -> rtd_resistance, RTD_Temperature - cmdLine.serial().printf("%s=%f\r\n", "rtd_resistance", g_MAX11410_device.rtd_resistance); - cmdLine.serial().printf("%s=%f\r\n", "RTD_Temperature", g_MAX11410_device.RTD_Temperature); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="R", testMenuFirstCharHandler="None" - } // end case 'R' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="TK", testMenuFirstCharHandler="None" -// CODE GENERATOR: test menu case 'TK': -// CODE GENERATOR: helpString 'TK tc_voltage=? -- TemperatureOfTC_TypeK' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'TemperatureOfTC_TypeK' -// CODE GENERATOR: CommandParamIn 'double tc_voltage' -// CODE GENERATOR: CommandReturnType 'double' -// CODE GENERATOR: CommandPre '@pre {0}.RTD_Temperature = cold junction temperature, in degrees C' -// CODE GENERATOR: CommandDocParamIn '@param[in] tc_voltage = Thermocouple voltage in volts, default=0.0254' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return ideal temperature in degrees C, calculated from RTD resistance in ohms' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(0.000e-3) expect 0.0 within 0.1 TC_TypeK at 0C = 0.000mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(0.039e-3) expect 1.0 within 0.1 TC_TypeK at 1C = 0.039mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(0.079e-3) expect 2.0 within 0.1 TC_TypeK at 2C = 0.079mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(0.119e-3) expect 3.0 within 0.1 TC_TypeK at 3C = 0.119mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(0.158e-3) expect 4.0 within 0.1 TC_TypeK at 4C = 0.158mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(0.198e-3) expect 5.0 within 0.1 TC_TypeK at 5C = 0.198mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(0.238e-3) expect 6.0 within 0.1 TC_TypeK at 6C = 0.238mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(0.2775e-3) expect 7.0 within 0.1 TC_TypeK at 7C = 0.2775mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(0.317e-3) expect 8.0 within 0.1 TC_TypeK at 8C = 0.317mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(0.357e-3) expect 9.0 within 0.1 TC_TypeK at 9C = 0.357mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(0.397e-3) expect 10.0 within 0.1 TC_TypeK at 10C = 0.397mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(0.798e-3) expect 20.0 within 0.1 TC_TypeK at 20C = 0.798mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(1.081e-3) expect 27.0 within 0.1 TC_TypeK at 27C = 1.081mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(1.203e-3) expect 30.0 within 0.1 TC_TypeK at 30C = 1.203mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(1.612e-3) expect 40.0 within 0.1 TC_TypeK at 40C = 1.612mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(2.023e-3) expect 50.0 within 0.1 TC_TypeK at 50C = 2.023mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(2.436e-3) expect 60.0 within 0.1 TC_TypeK at 60C = 2.436mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(2.851e-3) expect 70.0 within 0.1 TC_TypeK at 70C = 2.851mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(3.267e-3) expect 80.0 within 0.1 TC_TypeK at 80C = 3.267mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(3.682e-3) expect 90.0 within 0.1 TC_TypeK at 90C = 3.682mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(4.096e-3) expect 100.0 within 0.1 TC_TypeK at 100C = 4.096mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(4.509e-3) expect 110.0 within 0.1 TC_TypeK at 110C = 4.509mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(4.920e-3) expect 120.0 within 0.1 TC_TypeK at 120C = 4.920mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(5.328e-3) expect 130.0 within 0.1 TC_TypeK at 130C = 5.328mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(5.735e-3) expect 140.0 within 0.1 TC_TypeK at 140C = 5.735mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(6.138e-3) expect 150.0 within 0.1 TC_TypeK at 150C = 6.138mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(6.540e-3) expect 160.0 within 0.1 TC_TypeK at 160C = 6.540mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(6.941e-3) expect 170.0 within 0.1 TC_TypeK at 170C = 6.941mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(7.340e-3) expect 180.0 within 0.1 TC_TypeK at 180C = 7.340mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(7.739e-3) expect 190.0 within 0.1 TC_TypeK at 190C = 7.739mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(8.138e-3) expect 200.0 within 0.1 TC_TypeK at 200C = 8.138mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(8.539e-3) expect 210.0 within 0.1 TC_TypeK at 210C = 8.539mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(8.940e-3) expect 220.0 within 0.1 TC_TypeK at 220C = 8.940mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(9.343e-3) expect 230.0 within 0.1 TC_TypeK at 230C = 9.343mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(9.747e-3) expect 240.0 within 0.1 TC_TypeK at 240C = 9.747mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(10.153e-3) expect 250.0 within 0.1 TC_TypeK at 250C = 10.153mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(10.561e-3) expect 260.0 within 0.1 TC_TypeK at 260C = 10.561mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(10.971e-3) expect 270.0 within 0.1 TC_TypeK at 270C = 10.971mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(11.382e-3) expect 280.0 within 0.1 TC_TypeK at 280C = 11.382mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(11.795e-3) expect 290.0 within 0.1 TC_TypeK at 290C = 11.795mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(12.209e-3) expect 300.0 within 0.1 TC_TypeK at 300C = 12.209mV' -// CODE GENERATOR: CommandTest '@test group TC_2 TemperatureOfTC_TypeK(14.293e-3) expect 350.0 within 0.1 TC_TypeK at 350C = 14.293mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(16.397e-3) expect 400.0 within 0.1 TC_TypeK at 400C = 16.397mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(18.516e-3) expect 450.0 within 0.1 TC_TypeK at 450C = 18.516mV' -// CODE GENERATOR: CommandTest '@test group TC_1 TemperatureOfTC_TypeK(20.218e-3) expect 490.0 TC_TypeK at 490C = 20.218mV' - case 'T': // (multiple characters) (testMenuFirstCharHandler="T"): - { - switch (cmdLine[1]) - { - case 'K': // (nested inside case 'T') - { - // test menu command 'TK' handler: - // helpString='TK tc_voltage=? -- TemperatureOfTC_TypeK' - // CMD_='None' - // CommandName='TemperatureOfTC_TypeK' - // CommandParamIn='double tc_voltage' - // CommandReturnType='double' - // @Pre='@pre {0}.RTD_Temperature = cold junction temperature, in degrees C' - // @Param[in]='@param[in] tc_voltage = Thermocouple voltage in volts, default=0.0254' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return ideal temperature in degrees C, calculated from RTD resistance in ohms' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(0.000e-3) expect 0.0 within 0.1 TC_TypeK at 0C = 0.000mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(0.039e-3) expect 1.0 within 0.1 TC_TypeK at 1C = 0.039mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(0.079e-3) expect 2.0 within 0.1 TC_TypeK at 2C = 0.079mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(0.119e-3) expect 3.0 within 0.1 TC_TypeK at 3C = 0.119mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(0.158e-3) expect 4.0 within 0.1 TC_TypeK at 4C = 0.158mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(0.198e-3) expect 5.0 within 0.1 TC_TypeK at 5C = 0.198mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(0.238e-3) expect 6.0 within 0.1 TC_TypeK at 6C = 0.238mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(0.2775e-3) expect 7.0 within 0.1 TC_TypeK at 7C = 0.2775mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(0.317e-3) expect 8.0 within 0.1 TC_TypeK at 8C = 0.317mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(0.357e-3) expect 9.0 within 0.1 TC_TypeK at 9C = 0.357mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(0.397e-3) expect 10.0 within 0.1 TC_TypeK at 10C = 0.397mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(0.798e-3) expect 20.0 within 0.1 TC_TypeK at 20C = 0.798mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(1.081e-3) expect 27.0 within 0.1 TC_TypeK at 27C = 1.081mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(1.203e-3) expect 30.0 within 0.1 TC_TypeK at 30C = 1.203mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(1.612e-3) expect 40.0 within 0.1 TC_TypeK at 40C = 1.612mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(2.023e-3) expect 50.0 within 0.1 TC_TypeK at 50C = 2.023mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(2.436e-3) expect 60.0 within 0.1 TC_TypeK at 60C = 2.436mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(2.851e-3) expect 70.0 within 0.1 TC_TypeK at 70C = 2.851mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(3.267e-3) expect 80.0 within 0.1 TC_TypeK at 80C = 3.267mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(3.682e-3) expect 90.0 within 0.1 TC_TypeK at 90C = 3.682mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(4.096e-3) expect 100.0 within 0.1 TC_TypeK at 100C = 4.096mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(4.509e-3) expect 110.0 within 0.1 TC_TypeK at 110C = 4.509mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(4.920e-3) expect 120.0 within 0.1 TC_TypeK at 120C = 4.920mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(5.328e-3) expect 130.0 within 0.1 TC_TypeK at 130C = 5.328mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(5.735e-3) expect 140.0 within 0.1 TC_TypeK at 140C = 5.735mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(6.138e-3) expect 150.0 within 0.1 TC_TypeK at 150C = 6.138mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(6.540e-3) expect 160.0 within 0.1 TC_TypeK at 160C = 6.540mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(6.941e-3) expect 170.0 within 0.1 TC_TypeK at 170C = 6.941mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(7.340e-3) expect 180.0 within 0.1 TC_TypeK at 180C = 7.340mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(7.739e-3) expect 190.0 within 0.1 TC_TypeK at 190C = 7.739mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(8.138e-3) expect 200.0 within 0.1 TC_TypeK at 200C = 8.138mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(8.539e-3) expect 210.0 within 0.1 TC_TypeK at 210C = 8.539mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(8.940e-3) expect 220.0 within 0.1 TC_TypeK at 220C = 8.940mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(9.343e-3) expect 230.0 within 0.1 TC_TypeK at 230C = 9.343mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(9.747e-3) expect 240.0 within 0.1 TC_TypeK at 240C = 9.747mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(10.153e-3) expect 250.0 within 0.1 TC_TypeK at 250C = 10.153mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(10.561e-3) expect 260.0 within 0.1 TC_TypeK at 260C = 10.561mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(10.971e-3) expect 270.0 within 0.1 TC_TypeK at 270C = 10.971mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(11.382e-3) expect 280.0 within 0.1 TC_TypeK at 280C = 11.382mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(11.795e-3) expect 290.0 within 0.1 TC_TypeK at 290C = 11.795mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(12.209e-3) expect 300.0 within 0.1 TC_TypeK at 300C = 12.209mV' - // @Test='@test group TC_2 TemperatureOfTC_TypeK(14.293e-3) expect 350.0 within 0.1 TC_TypeK at 350C = 14.293mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(16.397e-3) expect 400.0 within 0.1 TC_TypeK at 400C = 16.397mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(18.516e-3) expect 450.0 within 0.1 TC_TypeK at 450C = 18.516mV' - // @Test='@test group TC_1 TemperatureOfTC_TypeK(20.218e-3) expect 490.0 TC_TypeK at 490C = 20.218mV' - // parse argument list - // argname default_argvalue numeric literal specified in CommandDocParamIn @Param[in]='@param[in] tc_voltage = Thermocouple voltage in volts, default=0.0254' - // parse argument double tc_voltage - double tc_voltage = (double)0; // --- g_MAX11410_device.__WARNING_no_match_for_argname_tc_voltage_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_double("tc_voltage", tc_voltage)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_tc_voltage_in_MAX11410_device_t__ = tc_voltage; // update global property value - } - // print arguments - cmdLine.serial().printf("TemperatureOfTC_TypeK"); - cmdLine.serial().printf(" tc_voltage=%d", tc_voltage); - cmdLine.serial().printf("\r\n"); - // call function TemperatureOfTC_TypeK(tc_voltage) - double result = g_MAX11410_device.TemperatureOfTC_TypeK(tc_voltage); - cmdLine.serial().printf(" =%f\r\n", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="TK", testMenuFirstCharHandler="T" - } // end nested case 'TK' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="TM", testMenuFirstCharHandler="T" -// CODE GENERATOR: top of loop: nested switch "T" is currently open -// CODE GENERATOR: test menu case 'TM': -// CODE GENERATOR: helpString 'TM -- Measure_Thermocouple' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Measure_Thermocouple' -// CODE GENERATOR: CommandParamIn 'MAX11410_AINP_SEL_enum_t tc_ainp, MAX11410_AINN_SEL_enum_t tc_ainn, MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn' -// CODE GENERATOR: CommandReturnType 'double' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] tc_ainp = channel of Thermocouple high side, default=AINP_SEL_0101_AIN5' -// CODE GENERATOR: CommandDocParamIn '@param[in] tc_ainn = channel of Thermocouple low side, default=AINN_SEL_0110_AIN6' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_iout = channel RTD high side force, default=AINP_SEL_0111_AIN7' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_ainp = channel RTD high side sense, default=AINP_SEL_1000_AIN8' -// CODE GENERATOR: CommandDocParamIn '@param[in] rtd_ainn = channel RTD low side, default=AINN_SEL_1001_AIN9' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '@post AINcode[tc_ainp]: measurement result LSB code' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case 'M': // (nested inside case 'T') - { - // test menu command 'TM' handler: - // helpString='TM -- Measure_Thermocouple' - // CMD_='None' - // CommandName='Measure_Thermocouple' - // CommandParamIn='MAX11410_AINP_SEL_enum_t tc_ainp, MAX11410_AINN_SEL_enum_t tc_ainn, MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn' - // CommandReturnType='double' - // @Pre='' - // @Param[in]='@param[in] tc_ainp = channel of Thermocouple high side, default=AINP_SEL_0101_AIN5' - // @Param[in]='@param[in] tc_ainn = channel of Thermocouple low side, default=AINN_SEL_0110_AIN6' - // @Param[in]='@param[in] rtd_iout = channel RTD high side force, default=AINP_SEL_0111_AIN7' - // @Param[in]='@param[in] rtd_ainp = channel RTD high side sense, default=AINP_SEL_1000_AIN8' - // @Param[in]='@param[in] rtd_ainn = channel RTD low side, default=AINN_SEL_1001_AIN9' - // @Param[out]='' - // @Post='@post AINcode[tc_ainp]: measurement result LSB code' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - // parse argument list - // argname default_argvalue symbolic enum name specified in CommandDocParamIn @Param[in]='@param[in] tc_ainp = channel of Thermocouple high side, default=AINP_SEL_0101_AIN5' - // parse argument MAX11410::MAX11410_AINP_SEL_enum_t tc_ainp - MAX11410::MAX11410_AINP_SEL_enum_t tc_ainp = MAX11410::AINP_SEL_0101_AIN5; // --- g_MAX11410_device.__WARNING_no_match_for_argname_tc_ainp_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("tc_ainp", (uint8_t&)tc_ainp)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_tc_ainp_in_MAX11410_device_t__ = tc_ainp; // update global property value - } - // argname default_argvalue symbolic enum name specified in CommandDocParamIn @Param[in]='@param[in] tc_ainn = channel of Thermocouple low side, default=AINN_SEL_0110_AIN6' - // parse argument MAX11410::MAX11410_AINN_SEL_enum_t tc_ainn - MAX11410::MAX11410_AINN_SEL_enum_t tc_ainn = MAX11410::AINN_SEL_0110_AIN6; // --- g_MAX11410_device.__WARNING_no_match_for_argname_tc_ainn_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("tc_ainn", (uint8_t&)tc_ainn)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_tc_ainn_in_MAX11410_device_t__ = tc_ainn; // update global property value - } - // argname default_argvalue symbolic enum name specified in CommandDocParamIn @Param[in]='@param[in] rtd_iout = channel RTD high side force, default=AINP_SEL_0111_AIN7' - // parse argument MAX11410::MAX11410_AINP_SEL_enum_t rtd_iout - MAX11410::MAX11410_AINP_SEL_enum_t rtd_iout = MAX11410::AINP_SEL_0111_AIN7; // --- g_MAX11410_device.__WARNING_no_match_for_argname_rtd_iout_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("rtd_iout", (uint8_t&)rtd_iout)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_rtd_iout_in_MAX11410_device_t__ = rtd_iout; // update global property value - } - // argname default_argvalue symbolic enum name specified in CommandDocParamIn @Param[in]='@param[in] rtd_ainp = channel RTD high side sense, default=AINP_SEL_1000_AIN8' - // parse argument MAX11410::MAX11410_AINP_SEL_enum_t rtd_ainp - MAX11410::MAX11410_AINP_SEL_enum_t rtd_ainp = MAX11410::AINP_SEL_1000_AIN8; // --- g_MAX11410_device.__WARNING_no_match_for_argname_rtd_ainp_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("rtd_ainp", (uint8_t&)rtd_ainp)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_rtd_ainp_in_MAX11410_device_t__ = rtd_ainp; // update global property value - } - // argname default_argvalue symbolic enum name specified in CommandDocParamIn @Param[in]='@param[in] rtd_ainn = channel RTD low side, default=AINN_SEL_1001_AIN9' - // parse argument MAX11410::MAX11410_AINN_SEL_enum_t rtd_ainn - MAX11410::MAX11410_AINN_SEL_enum_t rtd_ainn = MAX11410::AINN_SEL_1001_AIN9; // --- g_MAX11410_device.__WARNING_no_match_for_argname_rtd_ainn_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("rtd_ainn", (uint8_t&)rtd_ainn)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_rtd_ainn_in_MAX11410_device_t__ = rtd_ainn; // update global property value - } - // print arguments - cmdLine.serial().printf("Measure_Thermocouple"); - cmdLine.serial().printf(" tc_ainp=%d", tc_ainp); - cmdLine.serial().printf(" tc_ainn=%d", tc_ainn); - cmdLine.serial().printf(" rtd_iout=%d", rtd_iout); - cmdLine.serial().printf(" rtd_ainp=%d", rtd_ainp); - cmdLine.serial().printf(" rtd_ainn=%d", rtd_ainn); - cmdLine.serial().printf(" Measure_Thermocouple"); // unique suffix - cmdLine.serial().printf("\r\n"); - // call function Measure_Thermocouple(tc_ainp, tc_ainn, rtd_iout, rtd_ainp, rtd_ainn) - double result = g_MAX11410_device.Measure_Thermocouple(tc_ainp, tc_ainn, rtd_iout, rtd_ainp, rtd_ainn); - cmdLine.serial().printf(" =%f\r\n", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="TM", testMenuFirstCharHandler="T" - } // end nested case 'TM' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="V", testMenuFirstCharHandler="T" -// CODE GENERATOR: top of loop: nested switch "T" is currently open -// CODE GENERATOR: top of loop: need to close nested switch "T" - } // end nested switch (cmdLine[1]) inside case 'T' - break; - } // end case 'T' -// CODE GENERATOR: test menu case 'V': -// CODE GENERATOR: helpString 'V -- Measure_Voltage' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Measure_Voltage' -// CODE GENERATOR: CommandParamIn 'MAX11410_AINP_SEL_enum_t ainp, MAX11410_AINN_SEL_enum_t ainn' -// CODE GENERATOR: CommandReturnType 'double' -// CODE GENERATOR: CommandPre '@pre external connection REF2P-REF2N is a reference voltage' -// CODE GENERATOR: CommandPre '@pre VRef = Voltage of REF input, in Volts' -// CODE GENERATOR: CommandDocParamIn '@param[in] ainp = channel high side, default=AINP_SEL_0000_AIN0' -// CODE GENERATOR: CommandDocParamIn '@param[in] ainn = channel low side, default=AINN_SEL_1010_GND' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '@post AINcode[ainp]: measurement result LSB code' -// CODE GENERATOR: CommandReturn '@return ideal voltage calculated from raw LSB code and reference voltage' - // case 'V': // (single character) (testMenuFirstCharHandler="None") - case 'V': - { - // test menu command 'V' handler: - // helpString='V -- Measure_Voltage' - // CMD_='None' - // CommandName='Measure_Voltage' - // CommandParamIn='MAX11410_AINP_SEL_enum_t ainp, MAX11410_AINN_SEL_enum_t ainn' - // CommandReturnType='double' - // @Pre='@pre external connection REF2P-REF2N is a reference voltage' - // @Pre='@pre VRef = Voltage of REF input, in Volts' - // @Param[in]='@param[in] ainp = channel high side, default=AINP_SEL_0000_AIN0' - // @Param[in]='@param[in] ainn = channel low side, default=AINN_SEL_1010_GND' - // @Param[out]='' - // @Post='@post AINcode[ainp]: measurement result LSB code' - // displayPost='' - // @Return='@return ideal voltage calculated from raw LSB code and reference voltage' - // parse argument list - // argname default_argvalue symbolic enum name specified in CommandDocParamIn @Param[in]='@param[in] ainp = channel high side, default=AINP_SEL_0000_AIN0' - // parse argument MAX11410::MAX11410_AINP_SEL_enum_t ainp - MAX11410::MAX11410_AINP_SEL_enum_t ainp = MAX11410::AINP_SEL_0000_AIN0; // --- g_MAX11410_device.__WARNING_no_match_for_argname_ainp_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("ainp", (uint8_t&)ainp)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_ainp_in_MAX11410_device_t__ = ainp; // update global property value - } - // argname default_argvalue symbolic enum name specified in CommandDocParamIn @Param[in]='@param[in] ainn = channel low side, default=AINN_SEL_1010_GND' - // parse argument MAX11410::MAX11410_AINN_SEL_enum_t ainn - MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND; // --- g_MAX11410_device.__WARNING_no_match_for_argname_ainn_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("ainn", (uint8_t&)ainn)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_ainn_in_MAX11410_device_t__ = ainn; // update global property value - } - // print arguments - cmdLine.serial().printf("Measure_Voltage"); - cmdLine.serial().printf(" ainp=%d", ainp); - cmdLine.serial().printf(" ainn=%d", ainn); - cmdLine.serial().printf(" Measure_Voltage"); // unique suffix - cmdLine.serial().printf("\r\n"); - // call function Measure_Voltage(ainp, ainn) - double result = g_MAX11410_device.Measure_Voltage(ainp, ainn); - cmdLine.serial().printf(" =%f\r\n", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="V", testMenuFirstCharHandler="None" - } // end case 'V' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="X0", testMenuFirstCharHandler="None" -// CODE GENERATOR: test menu case 'X0': -// CODE GENERATOR: helpString 'X0 -- Calibrate_Self_Offset_Gain' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_Self_Offset_Gain' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case 'X': // (multiple characters) (testMenuFirstCharHandler="X"): - { - switch (cmdLine[1]) - { - case '0': // (nested inside case 'X') - { - // test menu command 'X0' handler: - // helpString='X0 -- Calibrate_Self_Offset_Gain' - // CMD_='None' - // CommandName='Calibrate_Self_Offset_Gain' - // CommandParamIn='void' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - cmdLine.serial().printf("Calibrate_Self_Offset_Gain"); - // call function Calibrate_Self_Offset_Gain - uint8_t result = g_MAX11410_device.Calibrate_Self_Offset_Gain(); - cmdLine.serial().printf(" =%d", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="X0", testMenuFirstCharHandler="X" - } // end nested case 'X0' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="X1", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'X1': -// CODE GENERATOR: helpString 'X1 -- Calibrate_PGA_Gain' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_PGA_Gain' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case '1': // (nested inside case 'X') - { - // test menu command 'X1' handler: - // helpString='X1 -- Calibrate_PGA_Gain' - // CMD_='None' - // CommandName='Calibrate_PGA_Gain' - // CommandParamIn='void' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - cmdLine.serial().printf("Calibrate_PGA_Gain"); - // call function Calibrate_PGA_Gain - uint8_t result = g_MAX11410_device.Calibrate_PGA_Gain(); - cmdLine.serial().printf(" =%d", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="X1", testMenuFirstCharHandler="X" - } // end nested case 'X1' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="X4", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'X4': -// CODE GENERATOR: helpString 'X4 -- Calibrate_System_Offset_A' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_System_Offset_A' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case '4': // (nested inside case 'X') - { - // test menu command 'X4' handler: - // helpString='X4 -- Calibrate_System_Offset_A' - // CMD_='None' - // CommandName='Calibrate_System_Offset_A' - // CommandParamIn='void' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - cmdLine.serial().printf("Calibrate_System_Offset_A"); - // call function Calibrate_System_Offset_A - uint8_t result = g_MAX11410_device.Calibrate_System_Offset_A(); - cmdLine.serial().printf(" =%d", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="X4", testMenuFirstCharHandler="X" - } // end nested case 'X4' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="X5", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'X5': -// CODE GENERATOR: helpString 'X5 -- Calibrate_System_Gain_A' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_System_Gain_A' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case '5': // (nested inside case 'X') - { - // test menu command 'X5' handler: - // helpString='X5 -- Calibrate_System_Gain_A' - // CMD_='None' - // CommandName='Calibrate_System_Gain_A' - // CommandParamIn='void' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - cmdLine.serial().printf("Calibrate_System_Gain_A"); - // call function Calibrate_System_Gain_A - uint8_t result = g_MAX11410_device.Calibrate_System_Gain_A(); - cmdLine.serial().printf(" =%d", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="X5", testMenuFirstCharHandler="X" - } // end nested case 'X5' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="X6", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'X6': -// CODE GENERATOR: helpString 'X6 -- Calibrate_System_Offset_B' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_System_Offset_B' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case '6': // (nested inside case 'X') - { - // test menu command 'X6' handler: - // helpString='X6 -- Calibrate_System_Offset_B' - // CMD_='None' - // CommandName='Calibrate_System_Offset_B' - // CommandParamIn='void' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - cmdLine.serial().printf("Calibrate_System_Offset_B"); - // call function Calibrate_System_Offset_B - uint8_t result = g_MAX11410_device.Calibrate_System_Offset_B(); - cmdLine.serial().printf(" =%d", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="X6", testMenuFirstCharHandler="X" - } // end nested case 'X6' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="X7", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'X7': -// CODE GENERATOR: helpString 'X7 -- Calibrate_System_Gain_B' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Calibrate_System_Gain_B' -// CODE GENERATOR: CommandParamIn 'void' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case '7': // (nested inside case 'X') - { - // test menu command 'X7' handler: - // helpString='X7 -- Calibrate_System_Gain_B' - // CMD_='None' - // CommandName='Calibrate_System_Gain_B' - // CommandParamIn='void' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - cmdLine.serial().printf("Calibrate_System_Gain_B"); - // call function Calibrate_System_Gain_B - uint8_t result = g_MAX11410_device.Calibrate_System_Gain_B(); - cmdLine.serial().printf(" =%d", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="X7", testMenuFirstCharHandler="X" - } // end nested case 'X7' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="XC", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'XC': -// CODE GENERATOR: helpString 'XC extclk=? u_bn=? format=? refbufp_en=? refbufn_en=? ref_sel=? -- Configure_CTRL' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_CTRL' -// CODE GENERATOR: CommandParamIn 'uint8_t extclk, uint8_t u_bn, uint8_t format, uint8_t refbufp_en, uint8_t refbufn_en, uint8_t ref_sel' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] extclk = external clock enable, default=0' -// CODE GENERATOR: CommandDocParamIn '@param[in] u_bn = unipolar input range enable, default=0' -// CODE GENERATOR: CommandDocParamIn '@param[in] format = offset binary format enable, default=0' -// CODE GENERATOR: CommandDocParamIn '@param[in] refbufp_en = REFP reference buffer enable, default=0' -// CODE GENERATOR: CommandDocParamIn '@param[in] refbufn_en = REFN reference buffer enable, default=0' -// CODE GENERATOR: CommandDocParamIn '@param[in] ref_sel = reference selection, default=MAX11410::MAX11410_REF_SEL_enum_t::REF_SEL_001_REF1P_REF1N' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case 'C': // (nested inside case 'X') - { - // test menu command 'XC' handler: - // helpString='XC extclk=? u_bn=? format=? refbufp_en=? refbufn_en=? ref_sel=? -- Configure_CTRL' - // CMD_='None' - // CommandName='Configure_CTRL' - // CommandParamIn='uint8_t extclk, uint8_t u_bn, uint8_t format, uint8_t refbufp_en, uint8_t refbufn_en, uint8_t ref_sel' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='@param[in] extclk = external clock enable, default=0' - // @Param[in]='@param[in] u_bn = unipolar input range enable, default=0' - // @Param[in]='@param[in] format = offset binary format enable, default=0' - // @Param[in]='@param[in] refbufp_en = REFP reference buffer enable, default=0' - // @Param[in]='@param[in] refbufn_en = REFN reference buffer enable, default=0' - // @Param[in]='@param[in] ref_sel = reference selection, default=MAX11410::MAX11410_REF_SEL_enum_t::REF_SEL_001_REF1P_REF1N' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - // parse argument list - // argname default_argvalue numeric literal specified in CommandDocParamIn @Param[in]='@param[in] extclk = external clock enable, default=0' - // parse argument uint8_t extclk - uint8_t extclk = (uint8_t)0; // --- g_MAX11410_device.__WARNING_no_match_for_argname_extclk_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("extclk", extclk)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_extclk_in_MAX11410_device_t__ = extclk; // update global property value - } - // argname default_argvalue numeric literal specified in CommandDocParamIn @Param[in]='@param[in] u_bn = unipolar input range enable, default=0' - // parse argument uint8_t u_bn - uint8_t u_bn = (uint8_t)0; // --- g_MAX11410_device.__WARNING_no_match_for_argname_u_bn_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("u_bn", u_bn)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_u_bn_in_MAX11410_device_t__ = u_bn; // update global property value - } - // argname default_argvalue numeric literal specified in CommandDocParamIn @Param[in]='@param[in] format = offset binary format enable, default=0' - // parse argument uint8_t format - uint8_t format = (uint8_t)0; // --- g_MAX11410_device.__WARNING_no_match_for_argname_format_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("format", format)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_format_in_MAX11410_device_t__ = format; // update global property value - } - // argname default_argvalue numeric literal specified in CommandDocParamIn @Param[in]='@param[in] refbufp_en = REFP reference buffer enable, default=0' - // parse argument uint8_t refbufp_en - uint8_t refbufp_en = (uint8_t)0; // --- g_MAX11410_device.__WARNING_no_match_for_argname_refbufp_en_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("refbufp_en", refbufp_en)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_refbufp_en_in_MAX11410_device_t__ = refbufp_en; // update global property value - } - // argname default_argvalue numeric literal specified in CommandDocParamIn @Param[in]='@param[in] refbufn_en = REFN reference buffer enable, default=0' - // parse argument uint8_t refbufn_en - uint8_t refbufn_en = (uint8_t)0; // --- g_MAX11410_device.__WARNING_no_match_for_argname_refbufn_en_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("refbufn_en", refbufn_en)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_refbufn_en_in_MAX11410_device_t__ = refbufn_en; // update global property value - } - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] ref_sel = reference selection, default=MAX11410::MAX11410_REF_SEL_enum_t::REF_SEL_001_REF1P_REF1N' - // parse argument uint8_t ref_sel - uint8_t ref_sel = (uint8_t)MAX11410::REF_SEL_001_REF1P_REF1N; // --- g_MAX11410_device.__WARNING_no_match_for_argname_ref_sel_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("ref_sel", ref_sel)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_ref_sel_in_MAX11410_device_t__ = ref_sel; // update global property value - } - // print arguments - cmdLine.serial().printf("Configure_CTRL"); - cmdLine.serial().printf(" extclk=%d", extclk); - cmdLine.serial().printf(" u_bn=%d", u_bn); - cmdLine.serial().printf(" format=%d", format); - cmdLine.serial().printf(" refbufp_en=%d", refbufp_en); - cmdLine.serial().printf(" refbufn_en=%d", refbufn_en); - cmdLine.serial().printf(" ref_sel=%d", ref_sel); - cmdLine.serial().printf("\r\n"); - // call function Configure_CTRL(extclk, u_bn, format, refbufp_en, refbufn_en, ref_sel) - uint8_t result = g_MAX11410_device.Configure_CTRL(extclk, u_bn, format, refbufp_en, refbufn_en, ref_sel); - cmdLine.serial().printf(" =%d\r\n", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="XC", testMenuFirstCharHandler="X" - } // end nested case 'XC' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="XF", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'XF': -// CODE GENERATOR: helpString 'XF linef=? rate=? -- Configure_FILTER' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_FILTER' -// CODE GENERATOR: CommandParamIn 'uint8_t linef, uint8_t rate' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] linef = filter type, default=MAX11410::MAX11410_LINEF_enum_t::LINEF_11_SINC4' -// CODE GENERATOR: CommandDocParamIn '@param[in] rate = output data rate selection, default=MAX11410::MAX11410_RATE_enum_t::RATE_0100' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case 'F': // (nested inside case 'X') - { - // test menu command 'XF' handler: - // helpString='XF linef=? rate=? -- Configure_FILTER' - // CMD_='None' - // CommandName='Configure_FILTER' - // CommandParamIn='uint8_t linef, uint8_t rate' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='@param[in] linef = filter type, default=MAX11410::MAX11410_LINEF_enum_t::LINEF_11_SINC4' - // @Param[in]='@param[in] rate = output data rate selection, default=MAX11410::MAX11410_RATE_enum_t::RATE_0100' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - // parse argument list - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] linef = filter type, default=MAX11410::MAX11410_LINEF_enum_t::LINEF_11_SINC4' - // parse argument uint8_t linef - uint8_t linef = (uint8_t)MAX11410::LINEF_11_SINC4; // --- g_MAX11410_device.__WARNING_no_match_for_argname_linef_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("linef", linef)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_linef_in_MAX11410_device_t__ = linef; // update global property value - } - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] rate = output data rate selection, default=MAX11410::MAX11410_RATE_enum_t::RATE_0100' - // parse argument uint8_t rate - uint8_t rate = (uint8_t)MAX11410::RATE_0100; // --- g_MAX11410_device.__WARNING_no_match_for_argname_rate_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("rate", rate)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_rate_in_MAX11410_device_t__ = rate; // update global property value - } - // print arguments - cmdLine.serial().printf("Configure_FILTER"); - cmdLine.serial().printf(" linef=%d", linef); - cmdLine.serial().printf(" rate=%d", rate); - cmdLine.serial().printf("\r\n"); - // call function Configure_FILTER(linef, rate) - uint8_t result = g_MAX11410_device.Configure_FILTER(linef, rate); - cmdLine.serial().printf(" =%d\r\n", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="XF", testMenuFirstCharHandler="X" - } // end nested case 'XF' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="XI", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'XI': -// CODE GENERATOR: helpString 'XI idac1_sel=? idac0_sel=? -- Configure_MUX_CTRL1' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_MUX_CTRL1' -// CODE GENERATOR: CommandParamIn 'uint8_t idac1_sel, uint8_t idac0_sel' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] idac1_sel = channel high side, default=MAX11410::MAX11410_IDAC1_SEL_enum_t::IDAC1_SEL_1111_unconnected' -// CODE GENERATOR: CommandDocParamIn '@param[in] idac0_sel = channel low side, default=MAX11410::MAX11410_IDAC0_SEL_enum_t::IDAC0_SEL_1111_unconnected' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case 'I': // (nested inside case 'X') - { - // test menu command 'XI' handler: - // helpString='XI idac1_sel=? idac0_sel=? -- Configure_MUX_CTRL1' - // CMD_='None' - // CommandName='Configure_MUX_CTRL1' - // CommandParamIn='uint8_t idac1_sel, uint8_t idac0_sel' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='@param[in] idac1_sel = channel high side, default=MAX11410::MAX11410_IDAC1_SEL_enum_t::IDAC1_SEL_1111_unconnected' - // @Param[in]='@param[in] idac0_sel = channel low side, default=MAX11410::MAX11410_IDAC0_SEL_enum_t::IDAC0_SEL_1111_unconnected' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - // parse argument list - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] idac1_sel = channel high side, default=MAX11410::MAX11410_IDAC1_SEL_enum_t::IDAC1_SEL_1111_unconnected' - // parse argument uint8_t idac1_sel - uint8_t idac1_sel = (uint8_t)MAX11410::IDAC1_SEL_1111_unconnected; // --- g_MAX11410_device.__WARNING_no_match_for_argname_idac1_sel_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("idac1_sel", idac1_sel)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_idac1_sel_in_MAX11410_device_t__ = idac1_sel; // update global property value - } - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] idac0_sel = channel low side, default=MAX11410::MAX11410_IDAC0_SEL_enum_t::IDAC0_SEL_1111_unconnected' - // parse argument uint8_t idac0_sel - uint8_t idac0_sel = (uint8_t)MAX11410::IDAC0_SEL_1111_unconnected; // --- g_MAX11410_device.__WARNING_no_match_for_argname_idac0_sel_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("idac0_sel", idac0_sel)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_idac0_sel_in_MAX11410_device_t__ = idac0_sel; // update global property value - } - // print arguments - cmdLine.serial().printf("Configure_MUX_CTRL1"); - cmdLine.serial().printf(" idac1_sel=%d", idac1_sel); - cmdLine.serial().printf(" idac0_sel=%d", idac0_sel); - cmdLine.serial().printf("\r\n"); - // call function Configure_MUX_CTRL1(idac1_sel, idac0_sel) - uint8_t result = g_MAX11410_device.Configure_MUX_CTRL1(idac1_sel, idac0_sel); - cmdLine.serial().printf(" =%d\r\n", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="XI", testMenuFirstCharHandler="X" - } // end nested case 'XI' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="XM", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'XM': -// CODE GENERATOR: helpString 'XM ainp=? ainn=? -- Configure_MUX_CTRL0' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_MUX_CTRL0' -// CODE GENERATOR: CommandParamIn 'uint8_t ainp, uint8_t ainn' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] ainp = channel high side, default=MAX11410::MAX11410_AINP_SEL_enum_t::AINP_SEL_0000_AIN0' -// CODE GENERATOR: CommandDocParamIn '@param[in] ainn = channel low side, default=MAX11410::MAX11410_AINN_SEL_enum_t::AINN_SEL_1010_GND' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case 'M': // (nested inside case 'X') - { - // test menu command 'XM' handler: - // helpString='XM ainp=? ainn=? -- Configure_MUX_CTRL0' - // CMD_='None' - // CommandName='Configure_MUX_CTRL0' - // CommandParamIn='uint8_t ainp, uint8_t ainn' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='@param[in] ainp = channel high side, default=MAX11410::MAX11410_AINP_SEL_enum_t::AINP_SEL_0000_AIN0' - // @Param[in]='@param[in] ainn = channel low side, default=MAX11410::MAX11410_AINN_SEL_enum_t::AINN_SEL_1010_GND' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - // parse argument list - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] ainp = channel high side, default=MAX11410::MAX11410_AINP_SEL_enum_t::AINP_SEL_0000_AIN0' - // parse argument uint8_t ainp - uint8_t ainp = (uint8_t)MAX11410::AINP_SEL_0000_AIN0; // --- g_MAX11410_device.__WARNING_no_match_for_argname_ainp_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("ainp", ainp)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_ainp_in_MAX11410_device_t__ = ainp; // update global property value - } - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] ainn = channel low side, default=MAX11410::MAX11410_AINN_SEL_enum_t::AINN_SEL_1010_GND' - // parse argument uint8_t ainn - uint8_t ainn = (uint8_t)MAX11410::AINN_SEL_1010_GND; // --- g_MAX11410_device.__WARNING_no_match_for_argname_ainn_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("ainn", ainn)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_ainn_in_MAX11410_device_t__ = ainn; // update global property value - } - // print arguments - cmdLine.serial().printf("Configure_MUX_CTRL0"); - cmdLine.serial().printf(" ainp=%d", ainp); - cmdLine.serial().printf(" ainn=%d", ainn); - cmdLine.serial().printf("\r\n"); - // call function Configure_MUX_CTRL0(ainp, ainn) - uint8_t result = g_MAX11410_device.Configure_MUX_CTRL0(ainp, ainn); - cmdLine.serial().printf(" =%d\r\n", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="XM", testMenuFirstCharHandler="X" - } // end nested case 'XM' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="XP", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'XP': -// CODE GENERATOR: helpString 'XP sigpath=? gain=? -- Configure_PGA' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_PGA' -// CODE GENERATOR: CommandParamIn 'uint8_t sigpath, uint8_t gain' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] sigpath = signal path, default=MAX11410::MAX11410_SIG_PATH_enum_t::SIG_PATH_00_BUFFERED' -// CODE GENERATOR: CommandDocParamIn '@param[in] gain = gain selection, default=MAX11410::MAX11410_GAIN_enum_t::GAIN_000_1' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case 'P': // (nested inside case 'X') - { - // test menu command 'XP' handler: - // helpString='XP sigpath=? gain=? -- Configure_PGA' - // CMD_='None' - // CommandName='Configure_PGA' - // CommandParamIn='uint8_t sigpath, uint8_t gain' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='@param[in] sigpath = signal path, default=MAX11410::MAX11410_SIG_PATH_enum_t::SIG_PATH_00_BUFFERED' - // @Param[in]='@param[in] gain = gain selection, default=MAX11410::MAX11410_GAIN_enum_t::GAIN_000_1' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - // parse argument list - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] sigpath = signal path, default=MAX11410::MAX11410_SIG_PATH_enum_t::SIG_PATH_00_BUFFERED' - // parse argument uint8_t sigpath - uint8_t sigpath = (uint8_t)MAX11410::SIG_PATH_00_BUFFERED; // --- g_MAX11410_device.__WARNING_no_match_for_argname_sigpath_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("sigpath", sigpath)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_sigpath_in_MAX11410_device_t__ = sigpath; // update global property value - } - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] gain = gain selection, default=MAX11410::MAX11410_GAIN_enum_t::GAIN_000_1' - // parse argument uint8_t gain - uint8_t gain = (uint8_t)MAX11410::GAIN_000_1; // --- g_MAX11410_device.__WARNING_no_match_for_argname_gain_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("gain", gain)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_gain_in_MAX11410_device_t__ = gain; // update global property value - } - // print arguments - cmdLine.serial().printf("Configure_PGA"); - cmdLine.serial().printf(" sigpath=%d", sigpath); - cmdLine.serial().printf(" gain=%d", gain); - cmdLine.serial().printf("\r\n"); - // call function Configure_PGA(sigpath, gain) - uint8_t result = g_MAX11410_device.Configure_PGA(sigpath, gain); - cmdLine.serial().printf(" =%d\r\n", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="XP", testMenuFirstCharHandler="X" - } // end nested case 'XP' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="XS", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'XS': -// CODE GENERATOR: helpString 'XS vbias_mode=? brn_mode=? idac_mode=? -- Configure_SOURCE' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_SOURCE' -// CODE GENERATOR: CommandParamIn 'uint8_t vbias_mode, uint8_t brn_mode, uint8_t idac_mode' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] vbias_mode = _______, default=MAX11410::MAX11410_VBIAS_MODE_enum_t::VBIAS_MODE_00_Active' -// CODE GENERATOR: CommandDocParamIn '@param[in] brn_mode = _______, default=MAX11410::MAX11410_BRN_MODE_enum_t::BRN_MODE_00_disabled' -// CODE GENERATOR: CommandDocParamIn '@param[in] idac_mode = _______, default=MAX11410::MAX11410_IDAC_MODE_enum_t::IDAC_MODE_0000_10uA' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case 'S': // (nested inside case 'X') - { - // test menu command 'XS' handler: - // helpString='XS vbias_mode=? brn_mode=? idac_mode=? -- Configure_SOURCE' - // CMD_='None' - // CommandName='Configure_SOURCE' - // CommandParamIn='uint8_t vbias_mode, uint8_t brn_mode, uint8_t idac_mode' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='@param[in] vbias_mode = _______, default=MAX11410::MAX11410_VBIAS_MODE_enum_t::VBIAS_MODE_00_Active' - // @Param[in]='@param[in] brn_mode = _______, default=MAX11410::MAX11410_BRN_MODE_enum_t::BRN_MODE_00_disabled' - // @Param[in]='@param[in] idac_mode = _______, default=MAX11410::MAX11410_IDAC_MODE_enum_t::IDAC_MODE_0000_10uA' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - // parse argument list - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] vbias_mode = _______, default=MAX11410::MAX11410_VBIAS_MODE_enum_t::VBIAS_MODE_00_Active' - // parse argument uint8_t vbias_mode - uint8_t vbias_mode = (uint8_t)MAX11410::VBIAS_MODE_00_Active; // --- g_MAX11410_device.__WARNING_no_match_for_argname_vbias_mode_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("vbias_mode", vbias_mode)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_vbias_mode_in_MAX11410_device_t__ = vbias_mode; // update global property value - } - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] brn_mode = _______, default=MAX11410::MAX11410_BRN_MODE_enum_t::BRN_MODE_00_disabled' - // parse argument uint8_t brn_mode - uint8_t brn_mode = (uint8_t)MAX11410::BRN_MODE_00_disabled; // --- g_MAX11410_device.__WARNING_no_match_for_argname_brn_mode_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("brn_mode", brn_mode)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_brn_mode_in_MAX11410_device_t__ = brn_mode; // update global property value - } - // argname default_argvalue symbolic name specified in CommandDocParamIn @Param[in]='@param[in] idac_mode = _______, default=MAX11410::MAX11410_IDAC_MODE_enum_t::IDAC_MODE_0000_10uA' - // parse argument uint8_t idac_mode - uint8_t idac_mode = (uint8_t)MAX11410::IDAC_MODE_0000_10uA; // --- g_MAX11410_device.__WARNING_no_match_for_argname_idac_mode_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("idac_mode", idac_mode)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_idac_mode_in_MAX11410_device_t__ = idac_mode; // update global property value - } - // print arguments - cmdLine.serial().printf("Configure_SOURCE"); - cmdLine.serial().printf(" vbias_mode=%d", vbias_mode); - cmdLine.serial().printf(" brn_mode=%d", brn_mode); - cmdLine.serial().printf(" idac_mode=%d", idac_mode); - cmdLine.serial().printf("\r\n"); - // call function Configure_SOURCE(vbias_mode, brn_mode, idac_mode) - uint8_t result = g_MAX11410_device.Configure_SOURCE(vbias_mode, brn_mode, idac_mode); - cmdLine.serial().printf(" =%d\r\n", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="XS", testMenuFirstCharHandler="X" - } // end nested case 'XS' - break; - -// CODE GENERATOR: top of loop: testMenuCommand="XV", testMenuFirstCharHandler="X" -// CODE GENERATOR: top of loop: nested switch "X" is currently open -// CODE GENERATOR: test menu case 'XV': -// CODE GENERATOR: helpString 'XV vbias_ain7_ain0_bitmap=? -- Configure_MUX_CTRL2' -// CODE GENERATOR: CMD_ 'None' -// CODE GENERATOR: CommandName 'Configure_MUX_CTRL2' -// CODE GENERATOR: CommandParamIn 'uint8_t vbias_ain7_ain0_bitmap' -// CODE GENERATOR: CommandReturnType 'uint8_t' -// CODE GENERATOR: CommandPre '' -// CODE GENERATOR: CommandDocParamIn '@param[in] vbias_ain7_ain0_bitmap = bit map of AIN7..AIN0 enables for voltage bias, default=0' -// CODE GENERATOR: CommandDocParamOut '' -// CODE GENERATOR: CommandPost '' -// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' - case 'V': // (nested inside case 'X') - { - // test menu command 'XV' handler: - // helpString='XV vbias_ain7_ain0_bitmap=? -- Configure_MUX_CTRL2' - // CMD_='None' - // CommandName='Configure_MUX_CTRL2' - // CommandParamIn='uint8_t vbias_ain7_ain0_bitmap' - // CommandReturnType='uint8_t' - // @Pre='' - // @Param[in]='@param[in] vbias_ain7_ain0_bitmap = bit map of AIN7..AIN0 enables for voltage bias, default=0' - // @Param[out]='' - // @Post='' - // displayPost='' - // @Return='@return 1 on success; 0 on failure' - // parse argument list - // argname default_argvalue numeric literal specified in CommandDocParamIn @Param[in]='@param[in] vbias_ain7_ain0_bitmap = bit map of AIN7..AIN0 enables for voltage bias, default=0' - // parse argument uint8_t vbias_ain7_ain0_bitmap - uint8_t vbias_ain7_ain0_bitmap = (uint8_t)0; // --- g_MAX11410_device.__WARNING_no_match_for_argname_vbias_ain7_ain0_bitmap_in_MAX11410_device_t__; // default to global property value - if (cmdLine.parse_uint8_dec("vbias_ain7_ain0_bitmap", vbias_ain7_ain0_bitmap)) - { - // g_MAX11410_device.__WARNING_no_match_for_argname_vbias_ain7_ain0_bitmap_in_MAX11410_device_t__ = vbias_ain7_ain0_bitmap; // update global property value - } - // print arguments - cmdLine.serial().printf("Configure_MUX_CTRL2"); - cmdLine.serial().printf(" vbias_ain7_ain0_bitmap=%d", vbias_ain7_ain0_bitmap); - cmdLine.serial().printf("\r\n"); - // call function Configure_MUX_CTRL2(vbias_ain7_ain0_bitmap) - uint8_t result = g_MAX11410_device.Configure_MUX_CTRL2(vbias_ain7_ain0_bitmap); - cmdLine.serial().printf(" =%d\r\n", result); - return true; // command handled by MAX11410 -// CODE GENERATOR: bottom of loop: testMenuCommand="XV", testMenuFirstCharHandler="X" - } // end nested case 'XV' - break; - - } // end nested switch (cmdLine[1]) inside case 'X' - break; - } // end case 'X' - // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - { - // hexadecimal codes get parsed as bytecodes - // - // parse_byteCount_byteList_dec() assumes all keyword args have already been removed from the buffer - // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; - #define MAX_SPI_BYTE_COUNT 32 - size_t byteCount = byteCount; - static char mosiData[MAX_SPI_BYTE_COUNT]; - static char misoData[MAX_SPI_BYTE_COUNT]; - if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, - MAX_SPI_BYTE_COUNT)) - { - // if length is 1 byte then operation is RegRead, otherwise RegWrite - // register_read_function 'RegRead' - // register_write_function 'RegWrite' - // register_name_function 'RegName' - // register_size_function 'RegSize' - MAX11410::MAX11410_CMD_enum_t regAddress = (MAX11410::MAX11410_CMD_enum_t)((mosiData[0] &~ MAX11410::CMD_1aaa_aaaa_REGISTER_READ) & 0xFF); - cmdLine.serial().printf(" regAddress=0x%2.2x\r\n", (regAddress & 0xFF)); - cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11410_device.RegName(regAddress)); - uint32_t regData = 0; - int regSize = g_MAX11410_device.RegSize(regAddress); - cmdLine.serial().printf(" RegSize=%d\r\n", regSize); - switch(regSize) - { - case 8: - regData = ((uint32_t)mosiData[1] & 0xFF); - break; - case 16: - regData = (((uint32_t)mosiData[1] & 0xFF) << 8) + ((uint32_t)mosiData[2] & 0xFF); - break; - case 24: - regData = (((uint32_t)mosiData[1] & 0xFF) << 16) + (((uint32_t)mosiData[2] & 0xFF) << 8) + ((uint32_t)mosiData[3] & 0xFF); - break; - } - if ((byteCount == 1) || (regAddress & MAX11410::CMD_1aaa_aaaa_REGISTER_READ)) - { - cmdLine.serial().printf(" RegRead"); - g_MAX11410_device.RegRead(regAddress, ®Data); - cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF)); - } - else - { - cmdLine.serial().printf(" RegWrite regData=0x%6.6X\r\n", (regData & 0x00FFFFFF)); - g_MAX11410_device.RegWrite(regAddress, regData); - } - // is there support function shadow regValue of regAddr? - } - return true; // command handled by MAX11410 - // - } // end case '0'..'9','A'..'F','a'..'f' - break; - } // end switch (cmdLine[0]) - return false; // command not handled by MAX11410 -} // end bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine) - -// CODE GENERATOR: class declaration statement close
--- a/main.cpp Wed Jan 22 07:57:46 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6829 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES - * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of Maxim Integrated - * Products, Inc. shall not be used except as stated in the Maxim Integrated - * Products, Inc. Branding Policy. - * - * The mere transfer of this software does not imply any licenses - * of trade secrets, proprietary technology, copyrights, patents, - * trademarks, maskwork rights, or any other form of intellectual - * property whatsoever. Maxim Integrated Products, Inc. retains all - * ownership rights. - ******************************************************************************* - */ - -// Test fixture and application menu for breakout boards: -// - MAX5715BOB -// - MAX11131BOB -// - MAX5171BOB -// Platforms: -// - MAX32625MBED -// - supports mbed-os-5.11, requires USBDevice library -// - remove max32630fthr library (if present) -// - remove MAX32620FTHR library (if present) -// - MAX32600MBED -// - remove max32630fthr library (if present) -// - remove MAX32620FTHR library (if present) -// - NUCLEO_F446RE -// - remove USBDevice library -// - remove max32630fthr library (if present) -// - remove MAX32620FTHR library (if present) -// - NUCLEO_F401RE -// - remove USBDevice library -// - remove max32630fthr library (if present) -// - remove MAX32620FTHR library (if present) -// - MAX32630FTHR -// - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/ -// - remove MAX32620FTHR library (if present) -// - MAX32620FTHR -// - remove max32630fthr library (if present) -// - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/ -// - not tested yet -// - MAX32625PICO -// - remove max32630fthr library (if present) -// - remove MAX32620FTHR library (if present) -// - not tested yet - -#include "mbed.h" -// mbed shared event queue run onTimerTick() in Thread context not Interrupt context -#include "mbed_events.h" -#if defined(TARGET) -// TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h -// Create a string definition for the TARGET -#define STRING_ARG(arg) #arg -#define STRING_NAME(name) STRING_ARG(name) -#define TARGET_NAME STRING_NAME(TARGET) -#elif defined(TARGET_MAX32600) -#define TARGET_NAME "MAX32600" -#elif defined(TARGET_LPC1768) -#define TARGET_NAME "LPC1768" -#elif defined(TARGET_NUCLEO_F446RE) -#define TARGET_NAME "NUCLEO_F446RE" -#elif defined(TARGET_NUCLEO_F401RE) -#define TARGET_NAME "NUCLEO_F401RE" -#else -#error TARGET NOT DEFINED -#endif -#if defined(TARGET_MAX32630) -//-------------------------------------------------- -// TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM -// +-------------[microUSB]-------------+ -// | J1 MAX32630FTHR J2 | -// ______ | [ ] RST GND [ ] | -// ______ | [ ] 3V3 BAT+[ ] | -// ______ | [ ] 1V8 reset SW1 | -// ______ | [ ] GND J4 J3 | -// analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+ -// analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn -// analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power -// analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9 -// (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8 -// (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7 -// D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6 -// D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5 -// D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4 -// D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3 -// D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2 -// ______ | [ ] GND SDA P3_4 [d] | D8 dig1 -// | | -// | XIP Flash MAX14690N | -// | XIP_SCLK P1_0 SDA2 P5_7 | -// | XIP_MOSI P1_1 SCL2 P6_0 | -// | XIP_MISO P1_2 PMIC_INIT P3_7 | -// | XIP_SSEL P1_3 MPC P2_7 | -// | XIP_DIO2 P1_4 MON AIN_0 | -// | XIP_DIO3 P1_5 | -// | | -// | PAN1326B MicroSD LED | -// | BT_RX P0_0 SD_SCLK P0_4 r P2_4 | -// | BT_TX P0_1 SD_MOSI P0_5 g P2_5 | -// | BT_CTS P0_2 SD_MISO P0_6 b P2_6 | -// | BT_RTS P0_3 SD_SSEL P0_7 | -// | BT_RST P1_6 DETECT P2_2 | -// | BT_CLK P1_7 SW2 P2_3 | -// +------------------------------------+ -// 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). -// 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). -// AIN_0 = AIN0 pin fullscale is 1.2V -// AIN_1 = AIN1 pin fullscale is 1.2V -// AIN_2 = AIN2 pin fullscale is 1.2V -// AIN_3 = AIN3 pin fullscale is 1.2V -// AIN_4 = AIN0 / 5.0 fullscale is 6.0V -// AIN_5 = AIN1 / 5.0 fullscale is 6.0V -// AIN_6 = VDDB / 4.0 fullscale is 4.8V -// AIN_7 = VDD18 fullscale is 1.2V -// AIN_8 = VDD12 fullscale is 1.2V -// AIN_9 = VRTC / 2.0 fullscale is 2.4V -// AIN_10 = x undefined? -// AIN_11 = VDDIO / 4.0 fullscale is 4.8V -// AIN_12 = VDDIOH / 4.0 fullscale is 4.8V -// - #include "max32630fthr.h" -MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); -#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 -// MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15 -const float ADC_FULL_SCALE_VOLTAGE = 1.200; -// Arduino connector -#ifndef A0 -#define A0 AIN_0 -#endif -#ifndef A1 -#define A1 AIN_1 -#endif -#ifndef A2 -#define A2 AIN_2 -#endif -#ifndef A3 -#define A3 AIN_3 -#endif -#ifndef D0 -#define D0 P4_0 -#endif -#ifndef D1 -#define D1 P5_6 -#endif -#ifndef D2 -#define D2 P5_5 -#endif -#ifndef D3 -#define D3 P5_4 -#endif -#ifndef D4 -#define D4 P5_3 -#endif -#ifndef D5 -#define D5 P3_3 -#endif -#ifndef D6 -#define D6 P3_2 -#endif -#ifndef D7 -#define D7 P3_5 -#endif -#ifndef D8 -#define D8 P3_4 -#endif -#ifndef D9 -#define D9 P3_1 -#endif -#ifndef D10 -#define D10 P3_0 -#endif -#ifndef D11 -#define D11 P5_1 -#endif -#ifndef D12 -#define D12 P5_2 -#endif -#ifndef D13 -#define D13 P5_0 -#endif -//-------------------------------------------------- -#elif defined(TARGET_MAX32625MBED) -//-------------------------------------------------- -// TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM -// +-------------------------------------+ -// | MAX32625MBED Arduino UNO header | -// | | -// | A5/SCL[ ] | P1_7 dig15 -// | A4/SDA[ ] | P1_6 dig14 -// | AREF=N/C[ ] | -// | GND[ ] | -// | [ ]N/C SCK/13[ ] | P1_0 dig13 -// | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12 -// | [ ]RST MOSI/11[ ]~| P1_1 dig11 -// | [ ]3V3 CS/10[ ]~| P1_3 dig10 -// | [ ]5V0 9[ ]~| P1_5 dig9 -// | [ ]GND 8[ ] | P1_4 dig8 -// | [ ]GND | -// | [ ]Vin 7[ ] | P0_7 dig7 -// | 6[ ]~| P0_6 dig6 -// AIN_0 | [ ]A0 5[ ]~| P0_5 dig5 -// AIN_1 | [ ]A1 4[ ] | P0_4 dig4 -// AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3 -// AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2 -// dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1 -// dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0 -// | [ ] [ ] [ ] | -// | UNO_R3 GND MOSI 5V ____________/ -// \_______________________/ -// -// +------------------------+ -// | | -// | MicroSD LED | -// | SD_SCLK P2_4 r P3_0 | -// | SD_MOSI P2_5 g P3_1 | -// | SD_MISO P2_6 b P3_2 | -// | SD_SSEL P2_7 y P3_3 | -// | | -// | DAPLINK BUTTONS | -// | TX P2_1 SW3 P2_3 | -// | RX P2_0 SW2 P2_2 | -// +------------------------+ -// -// AIN_0 = AIN0 pin fullscale is 1.2V -// AIN_1 = AIN1 pin fullscale is 1.2V -// AIN_2 = AIN2 pin fullscale is 1.2V -// AIN_3 = AIN3 pin fullscale is 1.2V -// AIN_4 = AIN0 / 5.0 fullscale is 6.0V -// AIN_5 = AIN1 / 5.0 fullscale is 6.0V -// AIN_6 = VDDB / 4.0 fullscale is 4.8V -// AIN_7 = VDD18 fullscale is 1.2V -// AIN_8 = VDD12 fullscale is 1.2V -// AIN_9 = VRTC / 2.0 fullscale is 2.4V -// AIN_10 = x undefined? -// AIN_11 = VDDIO / 4.0 fullscale is 4.8V -// AIN_12 = VDDIOH / 4.0 fullscale is 4.8V -// -//#include "max32625mbed.h" // ? -//MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ? -#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 -// MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15 -const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico? -// Arduino connector -#ifndef A0 -#define A0 AIN_0 -#endif -#ifndef A1 -#define A1 AIN_1 -#endif -#ifndef A2 -#define A2 AIN_2 -#endif -#ifndef A3 -#define A3 AIN_3 -#endif -#ifndef D0 -#define D0 P0_0 -#endif -#ifndef D1 -#define D1 P0_1 -#endif -#ifndef D2 -#define D2 P0_2 -#endif -#ifndef D3 -#define D3 P0_3 -#endif -#ifndef D4 -#define D4 P0_4 -#endif -#ifndef D5 -#define D5 P0_5 -#endif -#ifndef D6 -#define D6 P0_6 -#endif -#ifndef D7 -#define D7 P0_7 -#endif -#ifndef D8 -#define D8 P1_4 -#endif -#ifndef D9 -#define D9 P1_5 -#endif -#ifndef D10 -#define D10 P1_3 -#endif -#ifndef D11 -#define D11 P1_1 -#endif -#ifndef D12 -#define D12 P1_2 -#endif -#ifndef D13 -#define D13 P1_0 -#endif -//-------------------------------------------------- -#elif defined(TARGET_MAX32600) -// target MAX32600 -// -#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 -const float ADC_FULL_SCALE_VOLTAGE = 1.500; -// -//-------------------------------------------------- -#elif defined(TARGET_MAX32620FTHR) -#warning "TARGET_MAX32620FTHR not previously tested; need to define pins..." -#include "MAX32620FTHR.h" -// Initialize I/O voltages on MAX32620FTHR board -MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3); -//#define USE_LEDS 0 ? -#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 -#warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..." -const float ADC_FULL_SCALE_VOLTAGE = 1.200; -// -//-------------------------------------------------- -#elif defined(TARGET_MAX32625PICO) -#warning "TARGET_MAX32625PICO not previously tested; need to define pins..." -//#define USE_LEDS 0 ? -#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1 -#warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..." -const float ADC_FULL_SCALE_VOLTAGE = 1.200; -// -//-------------------------------------------------- -#elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) -// TODO1: target NUCLEO_F446RE -// -// USER_BUTTON PC13 -// LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1. -#define USE_LEDS 0 -// SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); -// Serial serial(SERIAL_TX, SERIAL_RX); -#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 -const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico? -// -//-------------------------------------------------- -#elif defined(TARGET_LPC1768) -//-------------------------------------------------- -// TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM -// +-------------[microUSB]-------------+ -// ______ | [ ] GND +3.3V VOUT [ ] | ______ -// ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______ -// ______ | [ ] VB USB.IF- [ ] | ______ -// ______ | [ ] nR USB.IF+ [ ] | ______ -// digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______ -// digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______ -// digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______ -// digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______ -// digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______ -// digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______ -// digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13 -// digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12 -// digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11 -// digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10 -// analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1 -// analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2 -// analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3 -// analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4 -// analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5 -// analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6 -// +------------------------------------+ -// AIN6 = P0.3 = TGT_SBL_RXD? -// AIN7 = P0.2 = TGT_SBL_TXD? -// -//-------------------------------------------------- -// LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14 -#define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0 -const float ADC_FULL_SCALE_VOLTAGE = 3.300; -#else // not defined(TARGET_LPC1768 etc.) -//-------------------------------------------------- -// unknown target -//-------------------------------------------------- -#endif // target definition - - -//-------------------------------------------------- -// alphanumeric command codes A-Z,a-z,0-9 reserved for application use -#ifndef APPLICATION_ArduinoPinsMonitor -#define APPLICATION_ArduinoPinsMonitor 1 -#endif // APPLICATION_ArduinoPinsMonitor - -//-------------------------------------------------- -// Support MAX5715BOB Breakout Board -#ifndef APPLICATION_MAX5715 -#define APPLICATION_MAX5715 0 -#endif // APPLICATION_MAX5715 -#if APPLICATION_MAX5715 // header file -#include "MAX5715.h" -// suppress the I2C diagnostics, not relevant to this chip -#define HAS_I2C 0 -#endif // APPLICATION_MAX5715 - -//-------------------------------------------------- -// Support MAX11131BOB Breakout Board -#ifndef APPLICATION_MAX11131 -#define APPLICATION_MAX11131 0 -#endif // APPLICATION_MAX11131 -#if APPLICATION_MAX11131 // header file -#include "MAX11131.h" -// suppress the I2C diagnostics, not relevant to this chip -#define HAS_I2C 0 -#endif // APPLICATION_MAX11131 - -//-------------------------------------------------- -// Support MAX5171BOB Breakout Board -#ifndef APPLICATION_MAX5171 -#define APPLICATION_MAX5171 0 -#endif // APPLICATION_MAX5171 -#if APPLICATION_MAX5171 // header file -#include "MAX5171.h" -// suppress the I2C diagnostics, not relevant to this chip -#define HAS_I2C 0 -#endif // APPLICATION_MAX5171 - -//-------------------------------------------------- -// Support MAX11410BOB Breakout Board (placeholder) -#ifndef APPLICATION_MAX11410 -#define APPLICATION_MAX11410 1 -#endif // APPLICATION_MAX11410 -#if APPLICATION_MAX11410 // header file -#include "MAX11410.h" -#define HAS_I2C 0 -// Optional Diagnostic function to print SPI transactions -#ifndef MAX11410_ONSPIPRINT -#define MAX11410_ONSPIPRINT 1 -#endif -#endif // APPLICATION_MAX11410 - -//-------------------------------------------------- -// Support MAX12345BOB Breakout Board (placeholder) -#ifndef APPLICATION_MAX12345 -#define APPLICATION_MAX12345 0 -#endif // APPLICATION_MAX12345 -#if APPLICATION_MAX12345 // header file -#include "MAX12345.h" -#define HAS_I2C 0 -#endif // APPLICATION_MAX12345 - - -#include "MAX541.h" - -#include "MaximTinyTester.h" - -//-------------------------------------------------- -// Option to dedicate SPI port pins -// -// SPI2_MOSI = P5_1 -// SPI2_MISO = P5_2 -// SPI2_SCK = P5_0 -// On this board I'm using P3_0 as spi_cs -// SPI2_SS = P5_3 -// SPI2_SDIO2 = P5_4 -// SPI2_SDIO3 = P5_5 -// SPI2_SRN = P5_6 -// -#ifndef HAS_SPI -#define HAS_SPI 1 -#endif -#if HAS_SPI -#define SPI_MODE0 0 -#define SPI_MODE1 1 -#define SPI_MODE2 2 -#define SPI_MODE3 3 -// -// Define application-specific default SPI_SCLK_Hz and SPI_dataMode -#if APPLICATION_MAX5715 // SPI interface default settings -// -//#define SPI_SCLK_Hz 48000000 // 48MHz -//#define SPI_SCLK_Hz 24000000 // 24MHz -#define SPI_SCLK_Hz 12000000 // 12MHz -//#define SPI_SCLK_Hz 4000000 // 4MHz -//#define SPI_SCLK_Hz 2000000 // 2MHz -//#define SPI_SCLK_Hz 1000000 // 1MHz -#define SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High -// -#elif APPLICATION_MAX11131 // SPI interface default settings -// -//#define SPI_SCLK_Hz 48000000 // 48MHz -//#define SPI_SCLK_Hz 24000000 // 24MHz -#define SPI_SCLK_Hz 12000000 // 12MHz -//#define SPI_SCLK_Hz 4000000 // 4MHz -//#define SPI_SCLK_Hz 2000000 // 2MHz -//#define SPI_SCLK_Hz 1000000 // 1MHz -#define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High -// -#elif APPLICATION_MAX5171 // SPI interface default settings -// -//#define SPI_SCLK_Hz 48000000 // 48MHz -//#define SPI_SCLK_Hz 24000000 // 24MHz -#define SPI_SCLK_Hz 12000000 // 12MHz -//#define SPI_SCLK_Hz 4000000 // 4MHz -//#define SPI_SCLK_Hz 2000000 // 2MHz -//#define SPI_SCLK_Hz 1000000 // 1MHz -#define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High -// -#elif APPLICATION_MAX11410 // SPI interface default settings -// -//#define SPI_SCLK_Hz 48000000 // 48MHz -//#define SPI_SCLK_Hz 24000000 // 24MHz -//#define SPI_SCLK_Hz 12000000 // 12MHz -#define SPI_SCLK_Hz 8000000 // 8MHz -//#define SPI_SCLK_Hz 4000000 // 4MHz -//#define SPI_SCLK_Hz 2000000 // 2MHz -//#define SPI_SCLK_Hz 1000000 // 1MHz -#define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Falling Edge stable; SCLK idle Low -// -#elif APPLICATION_MAX12345 // SPI interface default settings -// -//#define SPI_SCLK_Hz 48000000 // 48MHz -//#define SPI_SCLK_Hz 24000000 // 24MHz -#define SPI_SCLK_Hz 12000000 // 12MHz -//#define SPI_SCLK_Hz 4000000 // 4MHz -//#define SPI_SCLK_Hz 2000000 // 2MHz -//#define SPI_SCLK_Hz 1000000 // 1MHz -#define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High -// -#else // APPLICATION_ArduinoPinsMonitor diagnostic -// -//#define SPI_SCLK_Hz 48000000 // 48MHz -//#define SPI_SCLK_Hz 4000000 // 4MHz -//#define SPI_SCLK_Hz 2000000 // 2MHz -#define SPI_SCLK_Hz 1000000 // 1MHz -//#define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low -//#define SPI_dataMode SPI_MODE1 // CPOL=0,CPHA=1: Falling Edge stable; SCLK idle Low -//#define SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High -#define SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High -// -#endif -// -#if defined(TARGET_MAX32630) - // Before setting global variables g_SPI_SCLK_Hz and g_SPI_dataMode, - // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem (issue #30) -#warning "MAX32630 SPI workaround..." - // replace SPI_MODE2 (CPOL=1,CPHA=0) with SPI_MODE1 (CPOL=0,CPHA=1) Falling Edge stable - // replace SPI_MODE3 (CPOL=1,CPHA=1) with SPI_MODE0 (CPOL=0,CPHA=0) Rising Edge stable -# if ((SPI_dataMode) == (SPI_MODE2)) -#warning "MAX32630 SPI_MODE2 workaround, changing SPI_dataMode to SPI_MODE1..." - // SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High -# undef SPI_dataMode -# define SPI_dataMode SPI_MODE1 // CPOL=0,CPHA=1: Falling Edge stable; SCLK idle Low -# elif ((SPI_dataMode) == (SPI_MODE3)) -#warning "MAX32630 SPI_MODE3 workaround, changing SPI_dataMode to SPI_MODE0..." - // SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High -# undef SPI_dataMode -# define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low -# endif // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem - // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem (issue #30) - // limit SPI SCLK speed to 6MHz or less -# if ((SPI_SCLK_Hz) > (6000000)) -#warning "MAX32630 SPI speed workaround, changing SPI_SCLK_Hz to 6000000 or 6MHz..." -# undef SPI_SCLK_Hz -# define SPI_SCLK_Hz 6000000 // 6MHz -# endif -#endif -// -uint32_t g_SPI_SCLK_Hz = SPI_SCLK_Hz; -// TODO1: validate g_SPI_SCLK_Hz against system clock frequency SystemCoreClock F_CPU -#if defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) -// Nucleo SPI frequency isn't working quite as expected... -// Looks like STMF4 has an spi clock prescaler (2,4,8,16,32,64,128,256) -// so 180MHz->[90.0, 45.0, 22.5, 11.25, 5.625, 2.8125, 1.40625, 0.703125] -// %SC SCLK=1MHz sets spi frequency 703.125kHz -// %SC SCLK=2MHz sets spi frequency 1.40625MHz -// %SC SCLK=3MHz sets spi frequency 2.8125MHz -// %SC SCLK=6MHz sets spi frequency 5.625MHz -// %SC SCLK=12MHz sets spi frequency 11.25MHz -// %SC SCLK=23MHz sets spi frequency 22.5MHz -// %SC SCLK=45MHz sets spi frequency 45.0MHz -// Don't know why I can't reach spi frequency 90.0MHz, but ok whatever. -const uint32_t limit_min_SPI_SCLK_divisor = 2; -const uint32_t limit_max_SPI_SCLK_divisor = 256; -// not really a divisor, just a powers-of-two prescaler with no intermediate divisors. -#else -const uint32_t limit_min_SPI_SCLK_divisor = 2; -const uint32_t limit_max_SPI_SCLK_divisor = 8191; -#endif -const uint32_t limit_max_SPI_SCLK_Hz = (SystemCoreClock / limit_min_SPI_SCLK_divisor); // F_CPU / 2; // 8MHz / 2 = 4MHz -const uint32_t limit_min_SPI_SCLK_Hz = (SystemCoreClock / limit_max_SPI_SCLK_divisor); // F_CPU / 128; // 8MHz / 128 = 62.5kHz -// -uint8_t g_SPI_dataMode = SPI_dataMode; -uint8_t g_SPI_cs_state = 1; -// -#if defined(TARGET_MAX32630) -// TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut -// void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) -//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 -//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 -//SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 -SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 -// -DigitalOut spi_cs(P3_0); -#elif defined(TARGET_MAX32625MBED) -// TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut -// void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) -//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 -//DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32635MBED: P0_7 Arduino 8-pin header D4 -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 -DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32635MBED: P1_3 Arduino 10-pin header D10 -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 -DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header -#define HAS_SPI2_MAX541 1 -// -#elif defined(TARGET_MAX32620FTHR) -#warning "TARGET_MAX32620FTHR not previously tested; need to define SPI pins..." -// -// SPI0 P0_ PMOD Port 0 Back access -//SPI spi0(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32620FTHR: PMOD Port 0 Back access -//DigitalOut spi_cs0(SPI0_SS); // TARGET_MAX32620FTHR: PMOD Port 0 Back access -// -// SPI1 P1_ PMOD Port 1 Top Access -SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32620FTHR: PMOD Port 1 Top Access -DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32620FTHR: PMOD Port 1 Top Access -// -// SPI2 P5_ Feather J1.11,12,13 -//SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32620FTHR: Feather J1.11,12,13 -//DigitalOut spi_cs2(SPI2_SS); // TARGET_MAX32620FTHR: Feather J1.11,12,13 -// -#elif defined(TARGET_MAX32625PICO) -#warning "TARGET_MAX32625PICO not previously tested; need to define SPI pins..." -// Note to software maintainer: -// when adding new platform support, -// add another #elif block above to support the new platform -SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: 15 P0_5 MOSI; 14 P0_6 MISO; 16 P0_4 SCLK -DigitalOut spi_cs(SPI_SS); // TARGET_MAX32625PICO: 13 P0_7 SSEL -// -#elif defined(TARGET_MAX32600) -SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 -DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10 -// -#elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) -// TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut -// void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) -// -// TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses. -SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); // mosi, miso, sclk spi1 TARGET_NUCLEO_F446RE: Arduino 10-pin header D11 D12 D13 -DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10 -// -#elif defined(TARGET_LPC1768) -// TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut -// void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) -//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 -//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 -//SPI spi2(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 -SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 MAX32630FTHR: P5_1, P5_2, P5_0 -// -DigitalOut spi_cs(P3_0); -// -#else -// unknown target -#warning "target not previously tested; need to define SPI pins..." -// Note to software maintainer: -// when adding new platform support, -// add another #elif block above to support the new platform -//SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); // mosi, miso, sclk spi1 TARGET_xxx: Arduino 10-pin header D11 D12 D13 -//DigitalOut spi_cs(SPI_CS); // TARGET_xxx: PX_x Arduino 10-pin header D10 -#endif -#endif - -//-------------------------------------------------- -// Device driver object -#if APPLICATION_MAX5715 // SPI interface default settings -DigitalOut LDACb_pin(D9); // Arduino 10-pin header D9 -DigitalOut CLRb_pin(D8); // Arduino 10-pin header D8 -//~ DigitalIn RDYb_pin(D12); // Arduino 10-pin header D12 (MISO) -MAX5715 g_MAX5715_device(spi, spi_cs, - LDACb_pin, - CLRb_pin, - ///* RDYb_pin */ digitalInOut12, - MAX5715::MAX5715_IC); -// -#elif APPLICATION_MAX11131 // SPI interface default settings -DigitalOut CNVSTb_pin(D9); // Arduino 10-pin header D9 -//DigitalOut CLRb_pin(D8); // Arduino 10-pin header D8 -DigitalIn EOCb_pin(D12); // Arduino 10-pin header D12 (MISO) -MAX11131 g_MAX11131_device(spi, spi_cs, - CNVSTb_pin, - EOCb_pin, - ///* RDYb_pin */ digitalInOut12, - MAX11131::MAX11131_IC); -// -// -#elif APPLICATION_MAX5171 // SPI interface default settings -// AnalogOut FB_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5171 device -DigitalOut RS_pin(D9); // Digital Configuration Input to MAX5171 device -DigitalOut PDLb_pin(D8); // Digital Configuration Input to MAX5171 device -DigitalOut CLRb_pin(D7); // Digital Configuration Input to MAX5171 device -DigitalOut SHDN_pin(D6); // Digital Configuration Input to MAX5171 device -// AnalogIn OUT_pin(A0); // Analog Output from MAX5171 device -DigitalIn UPO_pin(D2); // Digital General-Purpose Output from MAX5171 device -MAX5171 g_MAX5171_device(spi, spi_cs, RS_pin, PDLb_pin, CLRb_pin, SHDN_pin, UPO_pin, MAX5171::MAX5171_IC); -// -#elif APPLICATION_MAX11410 // SPI interface default settings -// -MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC); -// -#elif APPLICATION_MAX12345 // SPI interface default settings -// -MAX12345 g_MAX12345_device(spi, spi_cs, ...); -// -#else // APPLICATION_ArduinoPinsMonitor diagnostic -// -#endif - - -//-------------------------------------------------- -// Option to dedicate I2C port pins -// -#ifndef HAS_I2C -#define HAS_I2C 1 -#endif -#if HAS_I2C -//#include "I2C.h" -//#include "I2CSlave.h" -//#define I2C_SCL_Hz 400000 // 400kHz -//#define I2C_SCL_Hz 200000 // 200kHz -#define I2C_SCL_Hz 100000 // 100kHz -// -#if defined(TARGET_MAX32630) -// TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU -const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz -const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz -// -// avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut -//I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl MAX32630FTHR: NOT_CONNECTED -//I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl MAX32630FTHR: P3_4, P3_5 -//I2C i2cMaster2(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0 -//I2C i2cMaster(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0 -// -//I2CSlave i2cSlave0(I2C0_SDA, I2C0_SCL); // sda scl MAX32630FTHR: NOT_CONNECTED -//I2CSlave i2cSlave1(I2C1_SDA, I2C1_SCL); // sda scl MAX32630FTHR: P3_4, P3_5 -//I2CSlave i2cSlave2(I2C2_SDA, I2C2_SCL); // sda scl MAX32630FTHR: P5_7, P6_0 -#elif defined(TARGET_MAX32625MBED) -// TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU -const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz -const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz -// -// avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut -//I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header -//I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header -// declare in narrower scope: MAX32625MBED I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header -// -#elif defined(TARGET_NUCLEO_F446RE) -// TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU -const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz -const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz -// -// avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut -//I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header -//I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header -// declare in narrower scope: MAX32625MBED I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header -# ifndef I2C0_SDA -# define I2C0_SDA I2C_SDA -# define I2C0_SCL I2C_SCL -# endif -// -#elif defined(TARGET_NUCLEO_F401RE) -// TODO1: validate g_I2C_SCL_Hz against system clock frequency SystemCoreClock F_CPU -const uint32_t limit_max_I2C_SCL_Hz = (SystemCoreClock / 2); // F_CPU / 2; // 8MHz / 2 = 4MHz -const uint32_t limit_min_I2C_SCL_Hz = (SystemCoreClock / 8191); // F_CPU / 128; // 8MHz / 128 = 62.5kHz -// -// avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut -//I2C i2cMaster0(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header -//I2C i2cMaster1(I2C1_SDA, I2C1_SCL); // sda scl TARGET_MAX32635MBED: P3_4, P3_5 Arduino 6-pin header -// declare in narrower scope: MAX32625MBED I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header -# ifndef I2C0_SDA -# define I2C0_SDA I2C_SDA -# define I2C0_SCL I2C_SCL -# endif -// -#elif defined(TARGET_LPC1768) -#else -// unknown target -#warning "target not previously tested; need to define I2C pins..." -#endif -// -#endif -#if HAS_I2C -uint32_t g_I2C_SCL_Hz = I2C_SCL_Hz; -uint8_t g_I2C_status = 0; // g_I2C_status = Wire_Sr.endTransmission(); -uint8_t g_I2C_deviceAddress7 = (0xA0 >> 1); // I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified. -uint8_t g_I2C_read_count = 0; -uint8_t g_I2C_write_count = 0; -uint8_t g_I2C_write_data[256]; -uint8_t g_I2C_command_regAddress; -// -// TODO: i2c init -// i2cMaster.frequency(g_I2C_SCL_Hz); -#endif -#if HAS_I2C -// TODO: i2c transfer -//const int addr7bit = 0x48; // 7 bit I2C address -//const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 -// /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. -// /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. -// /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. -// /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. -// /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. -// /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. -// /* 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... -// /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... -#endif - - -//-------------------------------------------------- -// Declare the Serial driver -// default baud rate settings are 9600 8N1 -// install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe -// see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/ -#if defined(TARGET_MAX32630) - #include "USBSerial.h" -// Hardware serial port over DAPLink -// The default baud rate for the DapLink UART is 9600 -Serial DAPLINKserial(P2_1, P2_0); // tx, rx - #define HAS_DAPLINK_SERIAL 1 -// Virtual serial port over USB -// The baud rate does not affect the virtual USBSerial UART. -USBSerial serial; -//-------------------------------------------------- -#elif defined(TARGET_MAX32625MBED) - #include "USBSerial.h" -// Hardware serial port over DAPLink -// The default baud rate for the DapLink UART is 9600 -Serial DAPLINKserial(P2_1, P2_0); // tx, rx - #define HAS_DAPLINK_SERIAL 1 -// Virtual serial port over USB -// The baud rate does not affect the virtual USBSerial UART. -USBSerial serial; -// -//-------------------------------------------------- -#elif defined(TARGET_MAX32620FTHR) -#warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..." -// Hardware serial port over DAPLink -// The default baud rate for the DapLink UART is 9600 -Serial DAPLINKserial(USBTX, USBRX); // tx, rx MAX32620FTHR: P2_1,P2_0 -//Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx - #define HAS_DAPLINK_SERIAL 1 -// Virtual serial port over USB -// The baud rate does not affect the virtual USBSerial UART. -// #include "USBSerial.h" -//USBSerial serial; -//Serial serial(UART0_TX, UART0_RX); // tx, rx MAX32620FTHR: P0_1,P0_0 (PMOD Port 0) -//Serial serial(UART1_TX, UART1_RX); // tx, rx MAX32620FTHR: P2_1,P2_0 (DAPLINK) -Serial serial(UART2_TX, UART2_RX); // tx, rx MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14) -//Serial serial(UART3_TX, UART3_RX); // tx, rx MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8) -//Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx -//Serial serial(USBTX, USBRX); // tx, rx -//Serial serial(UART_TX, UART_RX); // tx, rx -// -//-------------------------------------------------- -#elif defined(TARGET_MAX32625PICO) -#warning "TARGET_MAX32625PICO not previously tested; need to verify serial pins..." -// Note to software maintainer: -// when adding new platform support, -// add another #elif block above to support the new platform -Serial serial(UART_TX, UART_RX); // tx, rx -// -//-------------------------------------------------- -#elif defined(TARGET_MAX32600) - #include "USBSerial.h" -// Hardware serial port over DAPLink -// The default baud rate for the DapLink UART is 9600 -Serial DAPLINKserial(P1_1, P1_0); // tx, rx - #define HAS_DAPLINK_SERIAL 1 -// Virtual serial port over USB -// The baud rate does not affect the virtual USBSerial UART. -USBSerial serial; -//-------------------------------------------------- -#elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) -Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx -//-------------------------------------------------- -// TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM -#elif defined(TARGET_LPC1768) -Serial serial(USBTX, USBRX); // tx, rx -#else -// unknown target -#if defined(SERIAL_TX) -#warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..." -Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx -#elif defined(USBTX) -#warning "target not previously tested; guess serial pins are USBTX, USBRX..." -Serial serial(USBTX, USBRX); // tx, rx -#elif defined(UART_TX) -#warning "target not previously tested; guess serial pins are UART_TX, UART_RX..." -Serial serial(UART_TX, UART_RX); // tx, rx -#else -#warning "target not previously tested; need to define serial pins..." -#endif -#endif - -void on_immediate_0x21(); // Unicode (U+0021) ! EXCLAMATION MARK -void on_immediate_0x7b(); // Unicode (U+007B) { LEFT CURLY BRACKET -void on_immediate_0x7d(); // Unicode (U+007D) } RIGHT CURLY BRACKET - -#include "CmdLine.h" - -# if HAS_DAPLINK_SERIAL -CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK"); -# endif // HAS_DAPLINK_SERIAL -CmdLine cmdLine_serial(serial, "serial"); - - -//-------------------------------------------------- -// tolerate AT commands, which may be sent during probe, such as: -// AT -// AT+CGMI -- request manufacturer identification AT+CMGI=? -// AT+CGMM -- request manufacturer model -// AT%IPSYS? -// ATE0 -- echo disable -// ATV1 -- verbose result codes OK | ERROR | NO CARRIER -// AT+CMEE=1 -// ATX4 -// AT&C1 -// ATE0 -// AT+CMEE=1 -// AT+GCAP -// ATI -// AT+CPIN? -// AT+CGMM -#ifndef IGNORE_AT_COMMANDS -#define IGNORE_AT_COMMANDS 1 -#endif - - -// uncrustify-0.66.1 *INDENT-OFF* -//-------------------------------------------------- -// Declare the DigitalInOut GPIO pins -// Optional digitalInOut support. If there is only one it should be digitalInOut1. -// D) Digital High/Low/Input Pin -#if defined(TARGET_MAX32630) -// +-------------[microUSB]-------------+ -// | J1 MAX32630FTHR J2 | -// | [ ] RST GND [ ] | -// | [ ] 3V3 BAT+[ ] | -// | [ ] 1V8 reset SW1 | -// | [ ] GND J4 J3 | -// | [ ] AIN_0 1.2Vfs (bat) SYS [ ] | -// | [ ] AIN_1 1.2Vfs PWR [ ] | -// | [ ] AIN_2 1.2Vfs +5V VBUS [ ] | -// | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9 -// dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8 -// dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7 -// dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6 -// dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5 -// dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4 -// dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3 -// dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2 -// | [ ] GND SDA P3_4 [x] | dig1 -// +------------------------------------+ - #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15 - #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12 - #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11 - #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10 - #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9 - #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8 - #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7 - #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6 - #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5 - #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4 -#if HAS_I2C -// avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut - #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9 - #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10 -#else // HAS_I2C - #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9 - #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10 -#endif // HAS_I2C -#if HAS_SPI -// avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut - #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11 - #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12 - #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13 - #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14 -#else // HAS_SPI - #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11 - #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12 - #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13 - #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14 -#endif // HAS_SPI -#if HAS_digitalInOut0 - DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15 -#endif -#if HAS_digitalInOut1 - DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12 -#endif -#if HAS_digitalInOut2 - DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11 -#endif -#if HAS_digitalInOut3 - DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10 -#endif -#if HAS_digitalInOut4 - DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9 -#endif -#if HAS_digitalInOut5 - DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8 -#endif -#if HAS_digitalInOut6 - DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7 -#endif -#if HAS_digitalInOut7 - DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6 -#endif -#if HAS_digitalInOut8 - DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5 -#endif -#if HAS_digitalInOut9 - DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4 -#endif -#if HAS_digitalInOut10 - DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9 -#endif -#if HAS_digitalInOut11 - DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10 -#endif -#if HAS_digitalInOut12 - DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11 -#endif -#if HAS_digitalInOut13 - DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12 -#endif -#if HAS_digitalInOut14 - DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13 -#endif -#if HAS_digitalInOut15 - DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14 -#endif -//-------------------------------------------------- -#elif defined(TARGET_MAX32625MBED) -// TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM -// +-------------------------------------+ -// | MAX32625MBED Arduino UNO header | -// | | -// | A5/SCL[ ] | P1_7 dig15 -// | A4/SDA[ ] | P1_6 dig14 -// | AREF=N/C[ ] | -// | GND[ ] | -// | [ ]N/C SCK/13[ ] | P1_0 dig13 -// | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12 -// | [ ]RST MOSI/11[ ]~| P1_1 dig11 -// | [ ]3V3 CS/10[ ]~| P1_3 dig10 -// | [ ]5V0 9[ ]~| P1_5 dig9 -// | [ ]GND 8[ ] | P1_4 dig8 -// | [ ]GND | -// | [ ]Vin 7[ ] | P0_7 dig7 -// | 6[ ]~| P0_6 dig6 -// AIN_0 | [ ]A0 5[ ]~| P0_5 dig5 -// AIN_1 | [ ]A1 4[ ] | P0_4 dig4 -// AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3 -// AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2 -// dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1 -// dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0 -// | [ ] [ ] [ ] | -// | UNO_R3 GND MOSI 5V ____________/ -// \_______________________/ -// - #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0 - #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1 -#if APPLICATION_MAX11131 - #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn -#else - #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2 -#endif - #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3 - #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4 - #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5 - #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6 - #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7 - #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8 -#if APPLICATION_MAX11131 - #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut -#else - #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9 -#endif -#if HAS_SPI -// avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut - #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10 - #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11 - #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12 - #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13 -#else // HAS_SPI - #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10 - #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11 - #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12 - #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13 -#endif // HAS_SPI -#if HAS_I2C -// avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut - #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) - #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) - #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) - #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) -#else // HAS_I2C - #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) - #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) - #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) - #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) -#endif // HAS_I2C -#if HAS_digitalInOut0 - DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0 -#endif -#if HAS_digitalInOut1 - DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1 -#endif -#if HAS_digitalInOut2 - DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2 -#endif -#if HAS_digitalInOut3 - DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3 -#endif -#if HAS_digitalInOut4 - DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4 -#endif -#if HAS_digitalInOut5 - DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5 -#endif -#if HAS_digitalInOut6 - DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6 -#endif -#if HAS_digitalInOut7 - DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7 -#endif -#if HAS_digitalInOut8 - DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8 -#endif -#if HAS_digitalInOut9 - DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9 -#endif -#if HAS_digitalInOut10 - DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10 -#endif -#if HAS_digitalInOut11 - DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11 -#endif -#if HAS_digitalInOut12 - DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12 -#endif -#if HAS_digitalInOut13 - DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13 -#endif -#if HAS_digitalInOut14 - // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 - // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain - DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) -#endif -#if HAS_digitalInOut15 - // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 - DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) -#endif -#if HAS_digitalInOut16 - // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 - // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain - // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V - DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) -#endif -#if HAS_digitalInOut17 - // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 - DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) -#endif -//-------------------------------------------------- -#elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) - #define HAS_digitalInOut0 0 // P0_0 TARGET_MAX32625MBED D0 - #define HAS_digitalInOut1 0 // P0_1 TARGET_MAX32625MBED D1 -#if APPLICATION_MAX11131 - #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn -#else - #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2 -#endif - #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3 - #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4 - #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5 - #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6 - #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7 -#if APPLICATION_MAX5715 - #define HAS_digitalInOut8 0 // P1_4 TARGET_MAX32625MBED D8 -- MAX5715 CLRb DigitalOut -#else - #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8 -#endif -#if APPLICATION_MAX5715 - #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX5715 LDACb DigitalOut -#elif APPLICATION_MAX11131 - #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut -#else - #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9 -#endif -#if HAS_SPI -// avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut - // Arduino digital pin D10 SPI function is CS/10 - // Arduino digital pin D11 SPI function is MOSI/11 - // Arduino digital pin D12 SPI function is MISO/12 - // Arduino digital pin D13 SPI function is SCK/13 - #define HAS_digitalInOut10 0 - #define HAS_digitalInOut11 0 - #define HAS_digitalInOut12 0 - #define HAS_digitalInOut13 0 -#else // HAS_SPI - #define HAS_digitalInOut10 1 - #define HAS_digitalInOut11 1 - #define HAS_digitalInOut12 1 - #define HAS_digitalInOut13 1 -#endif // HAS_SPI -#if HAS_I2C -// avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut - // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector) - // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector) - // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector) - // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector) - #define HAS_digitalInOut14 0 - #define HAS_digitalInOut15 0 - #define HAS_digitalInOut16 0 - #define HAS_digitalInOut17 0 -#else // HAS_I2C - #define HAS_digitalInOut14 1 - #define HAS_digitalInOut15 1 - #define HAS_digitalInOut16 0 - #define HAS_digitalInOut17 0 -#endif // HAS_I2C -#if HAS_digitalInOut0 - DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut1 - DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut2 - DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut3 - DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut4 - DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut5 - DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut6 - DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut7 - DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut8 - DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut9 - DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut10 - // Arduino digital pin D10 SPI function is CS/10 - DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut11 - // Arduino digital pin D11 SPI function is MOSI/11 - DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut12 - // Arduino digital pin D12 SPI function is MISO/12 - DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut13 - // Arduino digital pin D13 SPI function is SCK/13 - DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut14 - // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector) - DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut15 - // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector) - DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut16 - // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector) - DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut17 - // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector) - DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1); -#endif -//-------------------------------------------------- -#elif defined(TARGET_LPC1768) - #define HAS_digitalInOut0 1 - #define HAS_digitalInOut1 1 - #define HAS_digitalInOut2 1 - #define HAS_digitalInOut3 1 - #define HAS_digitalInOut4 1 - #define HAS_digitalInOut5 1 - #define HAS_digitalInOut6 1 - #define HAS_digitalInOut7 1 - #define HAS_digitalInOut8 1 - #define HAS_digitalInOut9 1 -// #define HAS_digitalInOut10 1 -// #define HAS_digitalInOut11 1 -// #define HAS_digitalInOut12 1 -// #define HAS_digitalInOut13 1 -// #define HAS_digitalInOut14 1 -// #define HAS_digitalInOut15 1 -#if HAS_digitalInOut0 - DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3 -#endif -#if HAS_digitalInOut1 - DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2 -#endif -#if HAS_digitalInOut2 - DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1 -#endif -#if HAS_digitalInOut3 - DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0 -#endif -#if HAS_digitalInOut4 - DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1 -#endif -#if HAS_digitalInOut5 - DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1 -#endif -#if HAS_digitalInOut6 - DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1 -#endif -#if HAS_digitalInOut7 - DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO -#endif -#if HAS_digitalInOut8 - DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK -#endif -#if HAS_digitalInOut9 - DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL -#endif - // - // these pins support analog input analogIn0 .. analogIn5 - //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0 - //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1 - //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3 - //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3 - //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4 - //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5 - // - // these pins support PWM pwmDriver1 .. pwmDriver6 - //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0 - //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1 - //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2 - //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3 - //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1 - //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK - // - // these could be additional digitalInOut pins -#if HAS_digitalInOut10 - DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1 -#endif -#if HAS_digitalInOut11 - DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0 -#endif -#if HAS_digitalInOut12 - DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1 -#endif -#if HAS_digitalInOut13 - DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0 -#endif -#if HAS_digitalInOut14 - DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1); -#endif -#if HAS_digitalInOut15 - DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1); -#endif -#else - // unknown target -#endif -// uncrustify-0.66.1 *INDENT-ON* -#if HAS_digitalInOut0 || HAS_digitalInOut1 \ - || HAS_digitalInOut2 || HAS_digitalInOut3 \ - || HAS_digitalInOut4 || HAS_digitalInOut5 \ - || HAS_digitalInOut6 || HAS_digitalInOut7 \ - || HAS_digitalInOut8 || HAS_digitalInOut9 \ - || HAS_digitalInOut10 || HAS_digitalInOut11 \ - || HAS_digitalInOut12 || HAS_digitalInOut13 \ - || HAS_digitalInOut14 || HAS_digitalInOut15 \ - || HAS_digitalInOut16 || HAS_digitalInOut17 -#define HAS_digitalInOuts 1 -#endif - -// uncrustify-0.66.1 *INDENT-OFF* -//-------------------------------------------------- -// Declare the AnalogIn driver -// Optional analogIn support. If there is only one it should be analogIn1. -// A) analog input -#if defined(TARGET_MAX32630) - #define HAS_analogIn0 1 - #define HAS_analogIn1 1 - #define HAS_analogIn2 1 - #define HAS_analogIn3 1 - #define HAS_analogIn4 1 - #define HAS_analogIn5 1 - #define HAS_analogIn6 1 - #define HAS_analogIn7 1 - #define HAS_analogIn8 1 - #define HAS_analogIn9 1 -// #define HAS_analogIn10 0 -// #define HAS_analogIn11 0 -// #define HAS_analogIn12 0 -// #define HAS_analogIn13 0 -// #define HAS_analogIn14 0 -// #define HAS_analogIn15 0 -#if HAS_analogIn0 - AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V -#endif -#if HAS_analogIn1 - AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V -#endif -#if HAS_analogIn2 - AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V -#endif -#if HAS_analogIn3 - AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V -#endif -#if HAS_analogIn4 - AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V -#endif -#if HAS_analogIn5 - AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V -#endif -#if HAS_analogIn6 - AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V -#endif -#if HAS_analogIn7 - AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V -#endif -#if HAS_analogIn8 - AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V -#endif -#if HAS_analogIn9 - AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V -#endif -#if HAS_analogIn10 - AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined? -#endif -#if HAS_analogIn11 - AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V -#endif -#if HAS_analogIn12 - AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V -#endif -#if HAS_analogIn13 - AnalogIn analogIn13(____); -#endif -#if HAS_analogIn14 - AnalogIn analogIn14(____); -#endif -#if HAS_analogIn15 - AnalogIn analogIn15(____); -#endif -//-------------------------------------------------- -#elif defined(TARGET_MAX32625MBED) - #define HAS_analogIn0 1 - #define HAS_analogIn1 1 - #define HAS_analogIn2 1 - #define HAS_analogIn3 1 - #define HAS_analogIn4 1 - #define HAS_analogIn5 1 -#if HAS_analogIn0 - AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V -#endif -#if HAS_analogIn1 - AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V -#endif -#if HAS_analogIn2 - AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V -#endif -#if HAS_analogIn3 - AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V -#endif -#if HAS_analogIn4 - AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V -#endif -#if HAS_analogIn5 - AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V -#endif -//-------------------------------------------------- -#elif defined(TARGET_MAX32620FTHR) -#warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..." - #define HAS_analogIn0 1 - #define HAS_analogIn1 1 - #define HAS_analogIn2 1 - #define HAS_analogIn3 1 - #define HAS_analogIn4 1 - #define HAS_analogIn5 1 - #define HAS_analogIn6 1 - #define HAS_analogIn7 1 - #define HAS_analogIn8 1 - #define HAS_analogIn9 1 -// #define HAS_analogIn10 0 -// #define HAS_analogIn11 0 -// #define HAS_analogIn12 0 -// #define HAS_analogIn13 0 -// #define HAS_analogIn14 0 -// #define HAS_analogIn15 0 -#if HAS_analogIn0 - AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V -#endif -#if HAS_analogIn1 - AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V -#endif -#if HAS_analogIn2 - AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V -#endif -#if HAS_analogIn3 - AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V -#endif -#if HAS_analogIn4 - AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V -#endif -#if HAS_analogIn5 - AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V -#endif -#if HAS_analogIn6 - AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V -#endif -#if HAS_analogIn7 - AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V -#endif -#if HAS_analogIn8 - AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V -#endif -#if HAS_analogIn9 - AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V -#endif -#if HAS_analogIn10 - AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined? -#endif -#if HAS_analogIn11 - AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V -#endif -#if HAS_analogIn12 - AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V -#endif -#if HAS_analogIn13 - AnalogIn analogIn13(____); -#endif -#if HAS_analogIn14 - AnalogIn analogIn14(____); -#endif -#if HAS_analogIn15 - AnalogIn analogIn15(____); -#endif -//-------------------------------------------------- -#elif defined(TARGET_MAX32625PICO) -#warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..." - #define HAS_analogIn0 1 - #define HAS_analogIn1 1 - #define HAS_analogIn2 1 - #define HAS_analogIn3 1 - #define HAS_analogIn4 1 - #define HAS_analogIn5 1 -#if HAS_analogIn0 - AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V -#endif -#if HAS_analogIn1 - AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V -#endif -#if HAS_analogIn2 - AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V -#endif -#if HAS_analogIn3 - AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V -#endif -#if HAS_analogIn4 - AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V -#endif -#if HAS_analogIn5 - AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V -#endif -//-------------------------------------------------- -#elif defined(TARGET_MAX32600) - #define HAS_analogIn0 1 - #define HAS_analogIn1 1 - #define HAS_analogIn2 1 - #define HAS_analogIn3 1 - #define HAS_analogIn4 1 - #define HAS_analogIn5 1 -#if HAS_analogIn0 - AnalogIn analogIn0(A0); -#endif -#if HAS_analogIn1 - AnalogIn analogIn1(A1); -#endif -#if HAS_analogIn2 - AnalogIn analogIn2(A2); -#endif -#if HAS_analogIn3 - AnalogIn analogIn3(A3); -#endif -#if HAS_analogIn4 - AnalogIn analogIn4(A4); -#endif -#if HAS_analogIn5 - AnalogIn analogIn5(A5); -#endif -//-------------------------------------------------- -#elif defined(TARGET_NUCLEO_F446RE) - #define HAS_analogIn0 1 - #define HAS_analogIn1 1 - #define HAS_analogIn2 1 - #define HAS_analogIn3 1 - #define HAS_analogIn4 1 - #define HAS_analogIn5 1 -#if HAS_analogIn0 - AnalogIn analogIn0(A0); -#endif -#if HAS_analogIn1 - AnalogIn analogIn1(A1); -#endif -#if HAS_analogIn2 - AnalogIn analogIn2(A2); -#endif -#if HAS_analogIn3 - AnalogIn analogIn3(A3); -#endif -#if HAS_analogIn4 - AnalogIn analogIn4(A4); -#endif -#if HAS_analogIn5 - AnalogIn analogIn5(A5); -#endif -//-------------------------------------------------- -#elif defined(TARGET_NUCLEO_F401RE) - #define HAS_analogIn0 1 - #define HAS_analogIn1 1 - #define HAS_analogIn2 1 - #define HAS_analogIn3 1 - #define HAS_analogIn4 1 - #define HAS_analogIn5 1 -#if HAS_analogIn0 - AnalogIn analogIn0(A0); -#endif -#if HAS_analogIn1 - AnalogIn analogIn1(A1); -#endif -#if HAS_analogIn2 - AnalogIn analogIn2(A2); -#endif -#if HAS_analogIn3 - AnalogIn analogIn3(A3); -#endif -#if HAS_analogIn4 - AnalogIn analogIn4(A4); -#endif -#if HAS_analogIn5 - AnalogIn analogIn5(A5); -#endif -//-------------------------------------------------- -// TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM -#elif defined(TARGET_LPC1768) - #define HAS_analogIn0 1 - #define HAS_analogIn1 1 - #define HAS_analogIn2 1 - #define HAS_analogIn3 1 - #define HAS_analogIn4 1 - #define HAS_analogIn5 1 -// #define HAS_analogIn6 1 -// #define HAS_analogIn7 1 -// #define HAS_analogIn8 1 -// #define HAS_analogIn9 1 -// #define HAS_analogIn10 1 -// #define HAS_analogIn11 1 -// #define HAS_analogIn12 1 -// #define HAS_analogIn13 1 -// #define HAS_analogIn14 1 -// #define HAS_analogIn15 1 -#if HAS_analogIn0 - AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0 -#endif -#if HAS_analogIn1 - AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1 -#endif -#if HAS_analogIn2 - AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3 -#endif -#if HAS_analogIn3 - AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3 -#endif -#if HAS_analogIn4 - AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4 -#endif -#if HAS_analogIn5 - AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5 -#endif -#if HAS_analogIn6 - AnalogIn analogIn6(____); -#endif -#if HAS_analogIn7 - AnalogIn analogIn7(____); -#endif -#if HAS_analogIn8 - AnalogIn analogIn8(____); -#endif -#if HAS_analogIn9 - AnalogIn analogIn9(____); -#endif -#if HAS_analogIn10 - AnalogIn analogIn10(____); -#endif -#if HAS_analogIn11 - AnalogIn analogIn11(____); -#endif -#if HAS_analogIn12 - AnalogIn analogIn12(____); -#endif -#if HAS_analogIn13 - AnalogIn analogIn13(____); -#endif -#if HAS_analogIn14 - AnalogIn analogIn14(____); -#endif -#if HAS_analogIn15 - AnalogIn analogIn15(____); -#endif -#else - // unknown target -#endif -// uncrustify-0.66.1 *INDENT-ON* -#if HAS_analogIn0 || HAS_analogIn1 \ - || HAS_analogIn2 || HAS_analogIn3 \ - || HAS_analogIn4 || HAS_analogIn5 \ - || HAS_analogIn6 || HAS_analogIn7 \ - || HAS_analogIn8 || HAS_analogIn9 \ - || HAS_analogIn10 || HAS_analogIn11 \ - || HAS_analogIn12 || HAS_analogIn13 \ - || HAS_analogIn14 || HAS_analogIn15 -#define HAS_analogIns 1 -#endif - -//-------------------------------------------------- -// Option to use LEDs to show status -#ifndef USE_LEDS -#define USE_LEDS 1 -#endif -#if USE_LEDS -#if defined(TARGET_MAX32630) -# define LED_ON 0 -# define LED_OFF 1 -//-------------------------------------------------- -#elif defined(TARGET_MAX32625MBED) -# define LED_ON 0 -# define LED_OFF 1 -//-------------------------------------------------- -// TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM -#elif defined(TARGET_LPC1768) -# define LED_ON 1 -# define LED_OFF 0 -#else // not defined(TARGET_LPC1768 etc.) -// USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768 -// bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined -# ifndef LED_ON -# define LED_ON 0 -# endif -# ifndef LED_OFF -# define LED_OFF 1 -# endif -//# define LED_ON 1 -//# define LED_OFF 0 -#endif // target definition -DigitalOut led1(LED1, LED_OFF); // MAX32630FTHR: LED1 = LED_RED -DigitalOut led2(LED2, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN -DigitalOut led3(LED3, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE -DigitalOut led4(LED4, LED_OFF); -#else // USE_LEDS=0 -// issue #41 support Nucleo_F446RE -// there are no LED indicators on the board, LED1 interferes with SPI; -// but we still need placeholders led1 led2 led3 led4. -// Declare DigitalOut led1 led2 led3 led4 targeting safe pins. -// PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false -# define LED_ON 0 -# define LED_OFF 1 -DigitalOut led1(NC, LED_OFF); -DigitalOut led2(NC, LED_OFF); -DigitalOut led3(NC, LED_OFF); -DigitalOut led4(NC, LED_OFF); -#endif // USE_LEDS - -//-------------------------------------------------- -#if USE_LEDS -class RGB_LED { -public: - RGB_LED(DigitalOut &led_red, DigitalOut &led_green, DigitalOut &led_blue) - : m_red(led_red), m_green(led_green), m_blue(led_blue) - { - }; - DigitalOut &m_red; - DigitalOut &m_green; - DigitalOut &m_blue; - ~RGB_LED() - { - }; - /* diagnostic rbg led RED - */ - void red() { - m_red = LED_ON; m_green = LED_OFF; m_blue = LED_OFF; // diagnostic rbg led RED - }; - /* diagnostic rbg led GREEN - */ - void green() { - m_red = LED_OFF; m_green = LED_ON; m_blue = LED_OFF; // diagnostic rbg led GREEN - }; - /* diagnostic rbg led BLUE - */ - void blue() { - m_red = LED_OFF; m_green = LED_OFF; m_blue = LED_ON; // diagnostic rbg led BLUE - }; - /* diagnostic rbg led RED+GREEN+BLUE=WHITE - */ - void white() { - m_red = LED_ON; m_green = LED_ON; m_blue = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE - }; - /* diagnostic rbg led GREEN+BLUE=CYAN - */ - void cyan() { - m_red = LED_OFF; m_green = LED_ON; m_blue = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN - }; - /* diagnostic rbg led RED+BLUE=MAGENTA - */ - void magenta() { - m_red = LED_ON; m_green = LED_OFF; m_blue = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA - }; - /* diagnostic rbg led RED+GREEN=YELLOW - */ - void yellow() { - m_red = LED_ON; m_green = LED_ON; m_blue = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW - }; - /* diagnostic rbg led BLACK - */ - void black() { - m_red = LED_OFF; m_green = LED_OFF; m_blue = LED_OFF; // diagnostic rbg led BLACK - }; -}; -RGB_LED rgb_led(led1, led2, led3); // red, green, blue LEDs -#endif // USE_LEDS - -//-------------------------------------------------- -// use BUTTON1 trigger some action -#if defined(TARGET_MAX32630) -#define HAS_BUTTON1_DEMO_INTERRUPT 1 -#define HAS_BUTTON2_DEMO 0 -#define HAS_BUTTON2_DEMO_INTERRUPT 0 -#elif defined(TARGET_MAX32625PICO) -#warning "TARGET_MAX32625PICO not previously tested; need to define buttons..." -#define HAS_BUTTON1_DEMO_INTERRUPT 1 -#define HAS_BUTTON2_DEMO 0 -#define HAS_BUTTON2_DEMO_INTERRUPT 0 -#elif defined(TARGET_MAX32625) -#define HAS_BUTTON1_DEMO_INTERRUPT 1 -#define HAS_BUTTON2_DEMO_INTERRUPT 1 -#elif defined(TARGET_MAX32620FTHR) -#warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..." -#define BUTTON1 SW1 -#define HAS_BUTTON1_DEMO_INTERRUPT 1 -#define HAS_BUTTON2_DEMO 0 -#define HAS_BUTTON2_DEMO_INTERRUPT 0 -#elif defined(TARGET_NUCLEO_F446RE) -#define HAS_BUTTON1_DEMO_INTERRUPT 0 -#define HAS_BUTTON2_DEMO_INTERRUPT 0 -#elif defined(TARGET_NUCLEO_F401RE) -#define HAS_BUTTON1_DEMO_INTERRUPT 0 -#define HAS_BUTTON2_DEMO_INTERRUPT 0 -#else -#warning "target not previously tested; need to define buttons..." -#endif -// -#ifndef HAS_BUTTON1_DEMO -#define HAS_BUTTON1_DEMO 0 -#endif -#ifndef HAS_BUTTON2_DEMO -#define HAS_BUTTON2_DEMO 0 -#endif -// -// avoid runtime error on button1 press [mbed-os-5.11] -// instead of using InterruptIn, use DigitalIn and poll in main while(1) -#ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING -#define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1 -#endif -// -#ifndef HAS_BUTTON1_DEMO_INTERRUPT -#define HAS_BUTTON1_DEMO_INTERRUPT 1 -#endif -#ifndef HAS_BUTTON2_DEMO_INTERRUPT -#define HAS_BUTTON2_DEMO_INTERRUPT 1 -#endif -// -#if HAS_BUTTON1_DEMO_INTERRUPT -# if HAS_BUTTON1_DEMO_INTERRUPT_POLLING -// avoid runtime error on button1 press [mbed-os-5.11] -// instead of using InterruptIn, use DigitalIn and poll in main while(1) -DigitalIn button1(BUTTON1); -# else -InterruptIn button1(BUTTON1); -# endif -#elif HAS_BUTTON1_DEMO -DigitalIn button1(BUTTON1); -#endif -#if HAS_BUTTON2_DEMO_INTERRUPT -# if HAS_BUTTON1_DEMO_INTERRUPT_POLLING -// avoid runtime error on button1 press [mbed-os-5.11] -// instead of using InterruptIn, use DigitalIn and poll in main while(1) -DigitalIn button2(BUTTON2); -# else -InterruptIn button2(BUTTON2); -# endif -#elif HAS_BUTTON2_DEMO -DigitalIn button2(BUTTON2); -#endif - -//-------------------------------------------------- -// Ticker is the periodic interrupt timer itself -#ifndef USE_PERIODIC_TIMER -#define USE_PERIODIC_TIMER 0 -#endif -#if USE_PERIODIC_TIMER -Ticker periodicInterruptTimer; -us_timestamp_t periodicInterruptTimer_interval_usec = 50; -us_timestamp_t periodicInterruptTimer_interval_usec_MAX = 1000; -us_timestamp_t periodicInterruptTimer_interval_usec_MIN = 20; -#endif - - -#if APPLICATION_MAX11131 // hardware interface functions -//---------------------------------------- -void print_value(CmdLine& cmdLine, int16_t value_u12, int channelId) -{ - int channelPairIndex = channelId / 2; - // 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 - // unused variable: int UCHn = (g_MAX11131_device.UNIPOLAR >> (10 - channelPairIndex)) & 0x01; - int BCHn = (g_MAX11131_device.BIPOLAR >> (10 - channelPairIndex)) & 0x01; - // unused variable: int RANGEn = (g_MAX11131_device.RANGE >> (10 - channelPairIndex)) & 0x01; - // - cmdLine.serial().printf(" ch="); - // TODO1: if CHANID=0 don't print ch=channelId - if ((g_MAX11131_device.isExternalClock == 0) || (g_MAX11131_device.chan_id_0_1 == 1)) - { - // Internal clock modes always use channel ID. - // External clock modes use channel ID if ADC_MODE_CONTROL.CHAN_ID is 1. - cmdLine.serial().printf("%d", channelId); - } else { - cmdLine.serial().printf("?"); - } - if (BCHn) - { - cmdLine.serial().printf(" xb=%ld", g_MAX11131_device.TwosComplementValue(value_u12)); - } - else - { - cmdLine.serial().printf(" xu=%d", value_u12); - } - cmdLine.serial().printf(" = 0x%4.4x = %6.4fV", - (value_u12 & 0xFFFF), - g_MAX11131_device.VoltageOfCode(value_u12, channelId) - ); - // dtostrf width and precision: 2.5v / 4096 LSB = 0.0006103515625 volts per LSB -} - -//---------------------------------------- -// read data words -// @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data -// @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs -// For internal clock modes, the data format always includes the channel address. -// misoData16 = CH[3:0] DATA[11:0] -void AINcode_print_value_chanID(CmdLine& cmdLine, int nWords) -{ - cmdLine.serial().printf("ScanRead_nWords_chanID nWords=%d\r\n", nWords); - for (int index = 0; index < nWords; index++) { - //~ int16_t misoData16 = MAX11131_ScanRead(); - // For internal clock modes, the data format always includes the channel address. - // misoData16 = CH[3:0] DATA[11:0] - int16_t value_u12 = (g_MAX11131_device.RAW_misoData16[index] & 0x0FFF); - int channelId = ((g_MAX11131_device.RAW_misoData16[index] >> 12) & 0x000F); - // diagnostic: print raw MISO data - cmdLine.serial().printf(" MAX11131.MISO[%u]=0x%4.4x:", index, - (g_MAX11131_device.RAW_misoData16[index] & 0xFFFF)); - print_value(cmdLine, value_u12, channelId); - cmdLine.serial().printf("\r\n"); - } -} - -//---------------------------------------- -// read data words -// @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data -// @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs -// For external clock modes, the data format returned depends on the CHAN_ID bit. -// when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x -// when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0] -void AINcode_print_value_externalClock(CmdLine& cmdLine, int nWords) -{ - // For external clock modes, the data format returned depends on the CHAN_ID bit. - // when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x - // when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0] - // For internal clock modes, the data format always includes the channel address. - // misoData16 = CH[3:0] DATA[11:0] - if (g_MAX11131_device.chan_id_0_1 != 0) { - AINcode_print_value_chanID(cmdLine, nWords); - return; - } - cmdLine.serial().printf("ScanRead_nWords_externalClock nWords=%d\r\n", nWords); - for (int index = 0; index < nWords; index++) { - // int16_t misoData16 = MAX11131_ScanRead(); - int16_t value_u12 = ((g_MAX11131_device.RAW_misoData16[index] >> 3) & 0x0FFF); - int channelId = g_MAX11131_device.channelNumber_0_15; - // diagnostic: print raw MISO data - cmdLine.serial().printf(" MAX11131.MISO[%u]=0x%4.4x:", index, - (g_MAX11131_device.RAW_misoData16[index] & 0xFFFF)); - print_value(cmdLine, value_u12, channelId); - cmdLine.serial().printf("\r\n"); - } -} - -//---------------------------------------- -// read data words and calculate mean, stddev -// @pre RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data -// @pre AINcode[NUM_CHANNELS] contains the latest readings in LSBs -void AINcode_print_value_chanID_mean(CmdLine& cmdLine, int nWords) -{ - cmdLine.serial().printf("ScanRead_nWords_chanID_mean nWords=%d\r\n", nWords); - double Sx = 0; - double Sxx = 0; - for (int index = 0; index < nWords; index++) { - //~ int16_t misoData16 = MAX11131_ScanRead(); - // For internal clock modes, the data format always includes the channel address. - // misoData16 = CH[3:0] DATA[11:0] - int16_t value_u12 = (g_MAX11131_device.RAW_misoData16[index] & 0x0FFF); - int channelId = ((g_MAX11131_device.RAW_misoData16[index] >> 12) & 0x000F); - // TODO: sign-extend value_s12 from value_u12 - // - cmdLine.serial().printf("n=%d", index); - print_value(cmdLine, value_u12, channelId); - // - Sx = Sx + value_u12; - Sxx = Sxx + ((double)value_u12 * value_u12); - cmdLine.serial().printf(" Sx=%f Sxx=%f\r\n", Sx, Sxx); - } - double mean = Sx / nWords; - cmdLine.serial().printf(" mean=%f=0x%4.4x", mean, (int)mean); - // calculate standard deviation from N, Sx, Sxx - if (nWords >= 2) - { - double variance = (Sxx - ( Sx * Sx / nWords)) / (nWords - 1); - // stddev = square root of variance - double stddev = sqrt(variance); - cmdLine.serial().printf(" variance=%f stddev=%f", variance, stddev); - } - cmdLine.serial().printf("\r\n"); -} - -/* MAX11131_print_register_verbose - * - * TODO: document this function - * This header was inserted by uncrustify; see uncrustify_func_header.txt. - * - */ -void MAX11131_print_register_verbose(CmdLine& cmdLine, int16_t registerData) -{ - if (registerData & 0x8000) - { - switch (registerData & 0xF800) - { - 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 - cmdLine.serial().printf(" ADC_CONFIGURATION"); - { - // define write-only register ADC_CONFIGURATION - //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 - const int REFSEL_LSB = 10; const int REFSEL_BITS = 0x01; // ADC_CONFIGURATION.REFSEL - const int AVGON_LSB = 9; const int AVGON_BITS = 0x01; // ADC_CONFIGURATION.AVGON - const int NAVG_LSB = 7; const int NAVG_BITS = 0x03; // ADC_CONFIGURATION.NAVG[1:0] - const int NSCAN_LSB = 5; const int NSCAN_BITS = 0x03; // ADC_CONFIGURATION.NSCAN[1:0] - const int SPM_LSB = 3; const int SPM_BITS = 0x03; // ADC_CONFIGURATION.SPM[1:0] - const int ECHO_LSB = 2; const int ECHO_BITS = 0x01; // ADC_CONFIGURATION.ECHO - - const int REFSEL = ((registerData >> REFSEL_LSB) & REFSEL_BITS); - const int AVGON = ((registerData >> AVGON_LSB) & AVGON_BITS); - const int NAVG = ((registerData >> NAVG_LSB) & NAVG_BITS); - const int NSCAN = ((registerData >> NSCAN_LSB) & NSCAN_BITS); - const int SPM = ((registerData >> SPM_LSB) & SPM_BITS); - const int ECHO = ((registerData >> ECHO_LSB) & ECHO_BITS); - - if (REFSEL) { - cmdLine.serial().printf(" REFSEL=%d", REFSEL); - } - if (AVGON) { - cmdLine.serial().printf(" AVGON=%d", AVGON); - } - if (NAVG) { - cmdLine.serial().printf(" NAVG=%d", NAVG); - } - if (NSCAN) { - cmdLine.serial().printf(" NSCAN=%d", NSCAN); - } - if (SPM) { - cmdLine.serial().printf(" SPM=%d", SPM); - } - if (ECHO) { - cmdLine.serial().printf(" ECHO=%d", ECHO); - } - } - break; - 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 - cmdLine.serial().printf(" UNIPOLAR 0x%4.4x", ((registerData >> 3) & 0xFF)); - if ((registerData >> 2) & 0x01) { - cmdLine.serial().printf(" PDIFF_COM"); - } - break; - 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 - cmdLine.serial().printf(" BIPOLAR 0x%4.4x", ((registerData >> 3) & 0xFF)); - break; - 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 - cmdLine.serial().printf(" RANGE 0x%4.4x", ((registerData >> 3) & 0xFF)); - break; - case 0xA000: // CSCAN0 0xA000..0xA7FF format: 1 0 1 0 0 CHSCAN15 CHSCAN14 CHSCAN13 CHSCAN12 CHSCAN11 CHSCAN10 CHSCAN9 CHSCAN8 x x x - cmdLine.serial().printf(" CSCAN0 0x%4.4x", ((registerData >> 3) & 0xFF)); - break; - case 0xA800: // CSCAN1 0xA800..0xAFFF format: 1 0 1 0 1 CHSCAN7 CHSCAN6 CHSCAN5 CHSCAN4 CHSCAN3 CHSCAN2 CHSCAN1 CHSCAN0 x x x - cmdLine.serial().printf(" CSCAN1 0x%4.4x", ((registerData >> 3) & 0xFF)); - break; - case 0xB000: // SAMPLESET 0xB000..0xB7FF format: 1 0 1 1 0 SEQ_LENGTH[7:0] x x x - cmdLine.serial().printf(" SAMPLESET SEQ_LENGTH[7:0]=0x%4.4x", ((registerData >> 3) & 0xFF)); - cmdLine.serial().printf(" so length=%d channels", (((registerData >> 3) & 0xFF) + 1)); - break; - default: - cmdLine.serial().printf(" ???"); - break; - } - } - else - { - // ADC_MODE_CONTROL 0x0000..0x7FFF format: 0 SCAN[3:0] CHSEL[3:0] RESET[1:0] PM[1:0] CHAN_ID SWCNV 0 - cmdLine.serial().printf(" ADC_MODE_CONTROL"); - - // define write-only register ADC_MODE_CONTROL - //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 - const int SCAN_LSB = 11; const int SCAN_BITS = 0x0F; //!< ADC_MODE_CONTROL.SCAN[3:0] ADC Scan Control (command) - const int CHSEL_LSB = 7; const int CHSEL_BITS = 0x0F; //!< ADC_MODE_CONTROL.CHSEL[3:0] Analog Input Channel Select AIN0..AIN15 - 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 - 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 - const int CHAN_ID_LSB = 2; const int CHAN_ID_BITS = 0x01; //!< ADC_MODE_CONTROL.CHAN_ID - const int SWCNV_LSB = 1; const int SWCNV_BITS = 0x01; //!< ADC_MODE_CONTROL.SWCNV - - const int SCAN = ((registerData >> SCAN_LSB) & SCAN_BITS); - const int CHSEL = ((registerData >> CHSEL_LSB) & CHSEL_BITS); - const int RESET = ((registerData >> RESET_LSB) & RESET_BITS); - const int PM = ((registerData >> PM_LSB) & PM_BITS); - const int CHANID = ((registerData >> CHAN_ID_LSB) & CHAN_ID_BITS); - const int SWCNV = ((registerData >> SWCNV_LSB) & SWCNV_BITS); - - switch (SCAN) - { - case MAX11131::SCAN_0000_NOP: - cmdLine.serial().printf(" SCAN_0000_NOP"); - break; - case MAX11131::SCAN_0001_Manual: - cmdLine.serial().printf(" SCAN_0001_Manual CHSEL=%d", CHSEL); - break; - case MAX11131::SCAN_0010_Repeat: - cmdLine.serial().printf(" SCAN_0010_Repeat CHSEL=%d", CHSEL); - break; - case MAX11131::SCAN_0011_StandardInternalClock: - cmdLine.serial().printf(" SCAN_0011_StandardInt CHSEL=%d", CHSEL); - break; - case MAX11131::SCAN_0100_StandardExternalClock: - cmdLine.serial().printf(" SCAN_0100_StandardExt CHSEL=%d", CHSEL); - break; - case MAX11131::SCAN_0101_UpperInternalClock: - cmdLine.serial().printf(" SCAN_0101_UpperInt CHSEL=%d", CHSEL); - break; - case MAX11131::SCAN_0110_UpperExternalClock: - cmdLine.serial().printf(" SCAN_0110_UpperExt CHSEL=%d", CHSEL); - break; - case MAX11131::SCAN_0111_CustomInternalClock: - cmdLine.serial().printf(" SCAN_0111_CustomInt"); - break; - case MAX11131::SCAN_1000_CustomExternalClock: - cmdLine.serial().printf(" SCAN_1000_CustomExt"); - break; - case MAX11131::SCAN_1001_SampleSetExternalClock: - cmdLine.serial().printf(" SCAN_1001_SampleSetExt"); - break; - default: - cmdLine.serial().printf(" SCAN=%d", SCAN); - cmdLine.serial().printf(" CHSEL=%d", CHSEL); - } - if (RESET) { - cmdLine.serial().printf(" RESET=%d", RESET); - } - if (PM) { - cmdLine.serial().printf(" PM=%d", PM); - } - if (SCAN != MAX11131::SCAN_0000_NOP) - { - if (g_MAX11131_device.isExternalClock) - { - // if external clock mode, print CHANID - cmdLine.serial().printf(" CHANID=%d", CHANID); - } - else - { - // if internal clock mode, print SWCNV - cmdLine.serial().printf(" SWCNV=%d", SWCNV); - } - } - } - cmdLine.serial().printf("\r\n"); -} -#endif - - -#if APPLICATION_MAX5171 // hardware interface functions -#endif - - -#if APPLICATION_MAX11410 // hardware interface functions -#endif - - -#if APPLICATION_MAX12345 // hardware interface functions -#endif - - -//-------------------------------------------------- -// print banner message to serial port -void print_banner() -{ -#if HAS_DAPLINK_SERIAL - DAPLINKserial.printf("\r\n"); -# if defined(TARGET_MAX32630) - DAPLINKserial.printf("MAX32630"); -# elif defined(TARGET_MAX32625MBED) - DAPLINKserial.printf("MAX32625MBED"); -# elif defined(TARGET_NUCLEO_F446RE) - DAPLINKserial.printf("NUCLEO_F446RE"); -# elif defined(TARGET_NUCLEO_F401RE) - DAPLINKserial.printf("NUCLEO_F401RE"); -# elif defined(TARGET_LPC1768) - DAPLINKserial.printf("LPC1768"); -# else - // unknown target - DAPLINKserial.printf("unknownTarget"); -# endif - DAPLINKserial.printf(" DAPLINKserial\r\n"); -#endif // HAS_DAPLINK_SERIAL - - serial.printf("\r\n"); -# if defined(TARGET_MAX32630) - serial.printf("MAX32630"); -# elif defined(TARGET_MAX32625MBED) - serial.printf("MAX32625MBED"); -# elif defined(TARGET_NUCLEO_F446RE) - serial.printf("NUCLEO_F446RE"); -# elif defined(TARGET_NUCLEO_F401RE) - serial.printf("NUCLEO_F401RE"); -# elif defined(TARGET_LPC1768) - serial.printf("LPC1768"); -# else - // unknown target - serial.printf("unknownTarget"); -# endif - serial.printf(" Tester\r\n"); -} - -// DigitalInOut pin resource: print the pin index names to serial -#if HAS_digitalInOuts -void list_digitalInOutPins(Stream& serialStream) -{ -#if HAS_digitalInOut0 - serialStream.printf(" 0"); -#endif -#if HAS_digitalInOut1 - serialStream.printf(" 1"); -#endif -#if HAS_digitalInOut2 - serialStream.printf(" 2"); -#endif -#if HAS_digitalInOut3 - serialStream.printf(" 3"); -#endif -#if HAS_digitalInOut4 - serialStream.printf(" 4"); -#endif -#if HAS_digitalInOut5 - serialStream.printf(" 5"); -#endif -#if HAS_digitalInOut6 - serialStream.printf(" 6"); -#endif -#if HAS_digitalInOut7 - serialStream.printf(" 7"); -#endif -#if HAS_digitalInOut8 - serialStream.printf(" 8"); -#endif -#if HAS_digitalInOut9 - serialStream.printf(" 9"); -#endif -#if HAS_digitalInOut10 - serialStream.printf(" 10"); -#endif -#if HAS_digitalInOut11 - serialStream.printf(" 11"); -#endif -#if HAS_digitalInOut12 - serialStream.printf(" 12"); -#endif -#if HAS_digitalInOut13 - serialStream.printf(" 13"); -#endif -#if HAS_digitalInOut14 - serialStream.printf(" 14"); -#endif -#if HAS_digitalInOut15 - serialStream.printf(" 15"); -#endif -#if HAS_digitalInOut16 - serialStream.printf(" 16"); -#endif -#if HAS_digitalInOut17 - serialStream.printf(" 17"); -#endif -} -#endif - -// DigitalInOut pin resource: present? -#if HAS_digitalInOuts -bool has_digitalInOutPin(int cPinIndex) -{ - switch (cPinIndex) - { -#if HAS_digitalInOut0 - case '0': case 0x00: return true; -#endif -#if HAS_digitalInOut1 - case '1': case 0x01: return true; -#endif -#if HAS_digitalInOut2 - case '2': case 0x02: return true; -#endif -#if HAS_digitalInOut3 - case '3': case 0x03: return true; -#endif -#if HAS_digitalInOut4 - case '4': case 0x04: return true; -#endif -#if HAS_digitalInOut5 - case '5': case 0x05: return true; -#endif -#if HAS_digitalInOut6 - case '6': case 0x06: return true; -#endif -#if HAS_digitalInOut7 - case '7': case 0x07: return true; -#endif -#if HAS_digitalInOut8 - case '8': case 0x08: return true; -#endif -#if HAS_digitalInOut9 - case '9': case 0x09: return true; -#endif -#if HAS_digitalInOut10 - case 'a': case 0x0a: return true; -#endif -#if HAS_digitalInOut11 - case 'b': case 0x0b: return true; -#endif -#if HAS_digitalInOut12 - case 'c': case 0x0c: return true; -#endif -#if HAS_digitalInOut13 - case 'd': case 0x0d: return true; -#endif -#if HAS_digitalInOut14 - case 'e': case 0x0e: return true; -#endif -#if HAS_digitalInOut15 - case 'f': case 0x0f: return true; -#endif - default: - return false; - } -} -#endif - -// DigitalInOut pin resource: search index -#if HAS_digitalInOuts -DigitalInOut& find_digitalInOutPin(int cPinIndex) -{ - switch (cPinIndex) - { - default: // default to the first defined digitalInOut pin -#if HAS_digitalInOut0 - case '0': case 0x00: return digitalInOut0; -#endif -#if HAS_digitalInOut1 - case '1': case 0x01: return digitalInOut1; -#endif -#if HAS_digitalInOut2 - case '2': case 0x02: return digitalInOut2; -#endif -#if HAS_digitalInOut3 - case '3': case 0x03: return digitalInOut3; -#endif -#if HAS_digitalInOut4 - case '4': case 0x04: return digitalInOut4; -#endif -#if HAS_digitalInOut5 - case '5': case 0x05: return digitalInOut5; -#endif -#if HAS_digitalInOut6 - case '6': case 0x06: return digitalInOut6; -#endif -#if HAS_digitalInOut7 - case '7': case 0x07: return digitalInOut7; -#endif -#if HAS_digitalInOut8 - case '8': case 0x08: return digitalInOut8; -#endif -#if HAS_digitalInOut9 - case '9': case 0x09: return digitalInOut9; -#endif -#if HAS_digitalInOut10 - case 'a': case 0x0a: return digitalInOut10; -#endif -#if HAS_digitalInOut11 - case 'b': case 0x0b: return digitalInOut11; -#endif -#if HAS_digitalInOut12 - case 'c': case 0x0c: return digitalInOut12; -#endif -#if HAS_digitalInOut13 - case 'd': case 0x0d: return digitalInOut13; -#endif -#if HAS_digitalInOut14 - case 'e': case 0x0e: return digitalInOut14; -#endif -#if HAS_digitalInOut15 - case 'f': case 0x0f: return digitalInOut15; -#endif -#if HAS_digitalInOut16 - case 'g': case 0x10: return digitalInOut16; -#endif -#if HAS_digitalInOut17 - case 'h': case 0x11: return digitalInOut17; -#endif - } -} -#endif - -// AnalogIn pin resource: print the pin index names to serial -#if HAS_analogIns -void list_analogInPins(Stream& serialStream) -{ -#if HAS_analogIn0 - serialStream.printf(" 0"); -#endif -#if HAS_analogIn1 - serialStream.printf(" 1"); -#endif -#if HAS_analogIn2 - serialStream.printf(" 2"); -#endif -#if HAS_analogIn3 - serialStream.printf(" 3"); -#endif -#if HAS_analogIn4 - serialStream.printf(" 4"); -#endif -#if HAS_analogIn5 - serialStream.printf(" 5"); -#endif -#if HAS_analogIn6 - serialStream.printf(" 6"); -#endif -#if HAS_analogIn7 - serialStream.printf(" 7"); -#endif -#if HAS_analogIn8 - serialStream.printf(" 8"); -#endif -#if HAS_analogIn9 - serialStream.printf(" 9"); -#endif -#if HAS_analogIn10 - serialStream.printf(" a"); -#endif -#if HAS_analogIn11 - serialStream.printf(" b"); -#endif -#if HAS_analogIn12 - serialStream.printf(" c"); -#endif -#if HAS_analogIn13 - serialStream.printf(" d"); -#endif -#if HAS_analogIn14 - serialStream.printf(" e"); -#endif -#if HAS_analogIn15 - serialStream.printf(" f"); -#endif -} -#endif - -// AnalogIn pin resource: present? -#if HAS_analogIns -bool has_analogInPin(int cPinIndex) -{ - switch (cPinIndex) - { -#if HAS_analogIn0 - case '0': case 0x00: return true; -#endif -#if HAS_analogIn1 - case '1': case 0x01: return true; -#endif -#if HAS_analogIn2 - case '2': case 0x02: return true; -#endif -#if HAS_analogIn3 - case '3': case 0x03: return true; -#endif -#if HAS_analogIn4 - case '4': case 0x04: return true; -#endif -#if HAS_analogIn5 - case '5': case 0x05: return true; -#endif -#if HAS_analogIn6 - case '6': case 0x06: return true; -#endif -#if HAS_analogIn7 - case '7': case 0x07: return true; -#endif -#if HAS_analogIn8 - case '8': case 0x08: return true; -#endif -#if HAS_analogIn9 - case '9': case 0x09: return true; -#endif -#if HAS_analogIn10 - case 'a': case 0x0a: return true; -#endif -#if HAS_analogIn11 - case 'b': case 0x0b: return true; -#endif -#if HAS_analogIn12 - case 'c': case 0x0c: return true; -#endif -#if HAS_analogIn13 - case 'd': case 0x0d: return true; -#endif -#if HAS_analogIn14 - case 'e': case 0x0e: return true; -#endif -#if HAS_analogIn15 - case 'f': case 0x0f: return true; -#endif - default: - return false; - } -} -#endif - -// AnalogIn pin resource: search index -#if HAS_analogIns -AnalogIn& find_analogInPin(int cPinIndex) -{ - switch (cPinIndex) - { - default: // default to the first defined analogIn pin -#if HAS_analogIn0 - case '0': case 0x00: return analogIn0; -#endif -#if HAS_analogIn1 - case '1': case 0x01: return analogIn1; -#endif -#if HAS_analogIn2 - case '2': case 0x02: return analogIn2; -#endif -#if HAS_analogIn3 - case '3': case 0x03: return analogIn3; -#endif -#if HAS_analogIn4 - case '4': case 0x04: return analogIn4; -#endif -#if HAS_analogIn5 - case '5': case 0x05: return analogIn5; -#endif -#if HAS_analogIn6 - case '6': case 0x06: return analogIn6; -#endif -#if HAS_analogIn7 - case '7': case 0x07: return analogIn7; -#endif -#if HAS_analogIn8 - case '8': case 0x08: return analogIn8; -#endif -#if HAS_analogIn9 - case '9': case 0x09: return analogIn9; -#endif -#if HAS_analogIn10 - case 'a': case 0x0a: return analogIn10; -#endif -#if HAS_analogIn11 - case 'b': case 0x0b: return analogIn11; -#endif -#if HAS_analogIn12 - case 'c': case 0x0c: return analogIn12; -#endif -#if HAS_analogIn13 - case 'd': case 0x0d: return analogIn13; -#endif -#if HAS_analogIn14 - case 'e': case 0x0e: return analogIn14; -#endif -#if HAS_analogIn15 - case 'f': case 0x0f: return analogIn15; -#endif - } -} -#endif - -#if HAS_analogIns -const float analogInPin_fullScaleVoltage[] = { -# if defined(TARGET_MAX32630) - ADC_FULL_SCALE_VOLTAGE, // analogIn0 - ADC_FULL_SCALE_VOLTAGE, // analogIn1 - ADC_FULL_SCALE_VOLTAGE, // analogIn2 - ADC_FULL_SCALE_VOLTAGE, // analogIn3 - ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V - ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V - ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V - ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V - ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V - ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V - ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined? - ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V - ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V - ADC_FULL_SCALE_VOLTAGE, // analogIn13 - ADC_FULL_SCALE_VOLTAGE, // analogIn14 - ADC_FULL_SCALE_VOLTAGE // analogIn15 -# elif defined(TARGET_MAX32620FTHR) -#warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..." - ADC_FULL_SCALE_VOLTAGE, // analogIn0 - ADC_FULL_SCALE_VOLTAGE, // analogIn1 - ADC_FULL_SCALE_VOLTAGE, // analogIn2 - ADC_FULL_SCALE_VOLTAGE, // analogIn3 - ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V - ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V - ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V - ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V - ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V - ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V - ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined? - ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V - ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V - ADC_FULL_SCALE_VOLTAGE, // analogIn13 - ADC_FULL_SCALE_VOLTAGE, // analogIn14 - ADC_FULL_SCALE_VOLTAGE // analogIn15 -#elif defined(TARGET_MAX32625MBED) - ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V - ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V - ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V - ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V - ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V - ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V - ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V - ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V - ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V - ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V - ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined? - ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V - ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V - ADC_FULL_SCALE_VOLTAGE, // analogIn13 - ADC_FULL_SCALE_VOLTAGE, // analogIn14 - ADC_FULL_SCALE_VOLTAGE // analogIn15 -#elif defined(TARGET_NUCLEO_F446RE) - ADC_FULL_SCALE_VOLTAGE, // analogIn0 - ADC_FULL_SCALE_VOLTAGE, // analogIn1 - ADC_FULL_SCALE_VOLTAGE, // analogIn2 - ADC_FULL_SCALE_VOLTAGE, // analogIn3 - ADC_FULL_SCALE_VOLTAGE, // analogIn4 - ADC_FULL_SCALE_VOLTAGE, // analogIn5 - ADC_FULL_SCALE_VOLTAGE, // analogIn6 - ADC_FULL_SCALE_VOLTAGE, // analogIn7 - ADC_FULL_SCALE_VOLTAGE, // analogIn8 - ADC_FULL_SCALE_VOLTAGE, // analogIn9 - ADC_FULL_SCALE_VOLTAGE, // analogIn10 - ADC_FULL_SCALE_VOLTAGE, // analogIn11 - ADC_FULL_SCALE_VOLTAGE, // analogIn12 - ADC_FULL_SCALE_VOLTAGE, // analogIn13 - ADC_FULL_SCALE_VOLTAGE, // analogIn14 - ADC_FULL_SCALE_VOLTAGE // analogIn15 -#elif defined(TARGET_NUCLEO_F401RE) - ADC_FULL_SCALE_VOLTAGE, // analogIn0 - ADC_FULL_SCALE_VOLTAGE, // analogIn1 - ADC_FULL_SCALE_VOLTAGE, // analogIn2 - ADC_FULL_SCALE_VOLTAGE, // analogIn3 - ADC_FULL_SCALE_VOLTAGE, // analogIn4 - ADC_FULL_SCALE_VOLTAGE, // analogIn5 - ADC_FULL_SCALE_VOLTAGE, // analogIn6 - ADC_FULL_SCALE_VOLTAGE, // analogIn7 - ADC_FULL_SCALE_VOLTAGE, // analogIn8 - ADC_FULL_SCALE_VOLTAGE, // analogIn9 - ADC_FULL_SCALE_VOLTAGE, // analogIn10 - ADC_FULL_SCALE_VOLTAGE, // analogIn11 - ADC_FULL_SCALE_VOLTAGE, // analogIn12 - ADC_FULL_SCALE_VOLTAGE, // analogIn13 - ADC_FULL_SCALE_VOLTAGE, // analogIn14 - ADC_FULL_SCALE_VOLTAGE // analogIn15 -//#elif defined(TARGET_LPC1768) -#else - // unknown target - ADC_FULL_SCALE_VOLTAGE, // analogIn0 - ADC_FULL_SCALE_VOLTAGE, // analogIn1 - ADC_FULL_SCALE_VOLTAGE, // analogIn2 - ADC_FULL_SCALE_VOLTAGE, // analogIn3 - ADC_FULL_SCALE_VOLTAGE, // analogIn4 - ADC_FULL_SCALE_VOLTAGE, // analogIn5 - ADC_FULL_SCALE_VOLTAGE, // analogIn6 - ADC_FULL_SCALE_VOLTAGE, // analogIn7 - ADC_FULL_SCALE_VOLTAGE, // analogIn8 - ADC_FULL_SCALE_VOLTAGE, // analogIn9 - ADC_FULL_SCALE_VOLTAGE, // analogIn10 - ADC_FULL_SCALE_VOLTAGE, // analogIn11 - ADC_FULL_SCALE_VOLTAGE, // analogIn12 - ADC_FULL_SCALE_VOLTAGE, // analogIn13 - ADC_FULL_SCALE_VOLTAGE, // analogIn14 - ADC_FULL_SCALE_VOLTAGE // analogIn15 -# endif -}; -#endif - -#if HAS_I2C // SUPPORT_I2C -//-------------------------------------------------- -// Search I2C device address list -// -// @param[in] deviceAddress7First = I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified. -// @param[in] deviceAddress7Last = I2C device address (slave address on I2C bus), 7-bits, RIGHT-justified. -// @param[in] numDevicesFoundLimit = maximum number of devices to detect before halting search; in case SCL stuck low or pullups missing. -// @returns deviceAddress on success; 0 on failure -// @post g_I2C_deviceAddress7 is updated with any device that did ACK -// -void HuntAttachedI2CDevices(CmdLine& cmdLine, uint8_t deviceAddress7First, uint8_t deviceAddress7Last, - const uint8_t numDevicesFoundLimit = 20) -{ - // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) - I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header - i2cMaster.frequency(g_I2C_SCL_Hz); - - // %IP -- I2C probe - // TODO: i2c transfer - //const int addr7bit = 0x48; // 7 bit I2C address - //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 - // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. - // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. - // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. - // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. - // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. - // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. - // /* 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... - // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... - - //const char probeWriteData[] = { 0x00 }; - //int probeWriteDataLength = 1; - //bool isRepeatedStart = false; - cmdLine.serial().printf("I2C Probe {0x%2.2X (0x%2.2X >> 1) to 0x%2.2X (0x%2.2X >> 1)}, limit %d\r\n", - deviceAddress7First, - deviceAddress7First << 1, - deviceAddress7Last, - deviceAddress7Last << 1, - numDevicesFoundLimit); // HuntAttachedI2CDevices - //~ const int i2cFileDescriptor = i2c_open_adapter(1); - uint8_t numDevicesFound = 0; - uint8_t last_valid_deviceAddress7 = 0; - for (uint8_t deviceAddress7 = deviceAddress7First; deviceAddress7 <= deviceAddress7Last; deviceAddress7++) - { - //cmdLine.serial().printf(" (0x%2.2X >> 1) ", (deviceAddress7 << 1)); - //if (i2c_ioctl_I2C_SLAVE_i2cDeviceAddress7bits(i2cFileDescriptor, deviceAddress7) == 0) - int addr8bit = deviceAddress7 * 2; - // - // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. - // Returns 0 on success (ack), nonzero on failure (nack) - //bool gotACK = (i2cMaster.write (addr8bit, probeWriteData, probeWriteDataLength, isRepeatedStart) == 0); - // - // SMBusQuick test - i2cMaster.start(); - // /** Write single byte out on the I2C bus - // * - // * @param data data to write out on bus - // * - // * @returns - // * '0' - NAK was received - // * '1' - ACK was received, - // * '2' - timeout - // */ - // int write(int data); - int writeStatus = i2cMaster.write(addr8bit); - i2cMaster.stop(); - bool gotACK = (writeStatus == 1); // ACK was received - if (writeStatus == 2) // timeout - { - cmdLine.serial().printf("- timeout\r\n"); - } - // - if (gotACK) - { - // @return status; error if (fileDescriptor < 0) - cmdLine.serial().printf("+ ADDR=0x%2.2X (0x%2.2X >> 1) ACK\r\n", deviceAddress7, (deviceAddress7 << 1)); - numDevicesFound++; - last_valid_deviceAddress7 = deviceAddress7; - if (numDevicesFound > numDevicesFoundLimit) - { - break; - } - continue; - } - } - if (numDevicesFound == 0) - { - cmdLine.serial().printf("- No I2C devices found. Maybe SCL/SDA are swapped?\r\n"); - } - else if (numDevicesFound > numDevicesFoundLimit) - { - cmdLine.serial().printf("- Many I2C devices found. SCL/SDA missing pullup resistors? SCL stuck low?\r\n"); - } - else - { - //~ i2c_ioctl_I2C_SLAVE_i2cDeviceAddress7bits(i2cFileDescriptor, last_valid_deviceAddress7); - g_I2C_deviceAddress7 = last_valid_deviceAddress7; - } - //~ i2c_close(i2cFileDescriptor); -} -#endif // SUPPORT_I2C - -//-------------------------------------------------- -// periodic interrupt timer onTimerTick handler triggered by Ticker -// analogIn0 (MAX32630:AIN_4 = AIN0 / 5.0) controls angular speed -// analogIn1 (MAX32630:AIN_5 = AIN1 / 5.0) controls PWM duty cycle -// note: measured 500ns overhead for MAX32630FTHR digitalInOut1.write(0); digitalInOut1.write(1); -#if USE_PERIODIC_TIMER -void onTimerTick() { -} // onTimerTick -#endif - -#if USE_PERIODIC_TIMER -// periodic interrupt timer command handlers -- enable timer -void cmd_TE() -{ - //us_timestamp_t interval_usec = 100000; // 100ms - periodicInterruptTimer_interval_usec = 100000; // 100ms -# if HAS_DAPLINK_SERIAL - DAPLINKserial.printf(" TE rate=%lluus -- Timer Enable\r\n", periodicInterruptTimer_interval_usec); -# endif - serial.printf(" TE rate=%lluus -- Timer Enable", periodicInterruptTimer_interval_usec); -#if 1 - // mbed shared event queue run onTimerTick() in Thread context not Interrupt context - periodicInterruptTimer.attach_us(mbed_event_queue()->event(onTimerTick), - periodicInterruptTimer_interval_usec); - // Works if rate=620Hz or less, Fails if rate=750Hz - // MbedOS Error Info Error Status 0x80FF0144 code 324 module 255 - // Assertion failed; id location 0xBE6F mbed-os.lib/events/Event.h+158 - // Current thread main id 0x200036f8 entry 0xc22f stacksize 0x1000 stackmem 0x200026f8 sp 0x2007ff60 - // Seems not robust about overrun / sample rate too fast -#else - periodicInterruptTimer.attach_us(&onTimerTick, periodicInterruptTimer_interval_usec); -#endif - // -- periodicInterruptTimer.attach(&onTimerTick, interval_sec); // the address of the function to be attached (onTimerTick) and the interval (2 seconds) - // -- periodicInterruptTimer.attach_us(&onTimerTick, interval_usec); // the address of the function to be attached (onTimerTick) and the interval (2 seconds) - // -- periodicInterruptTimer.attach(Callback<void()> func, float t); - // -- periodicInterruptTimer.attach_us(Callback<void()> func, us_timestamp_t t); - // TODO1: cmd_T add cSubCommand to change interval of Ticker periodic interrupt timer -} -#endif - -#if USE_PERIODIC_TIMER -// periodic interrupt timer command handlers -- disable timer -void cmd_TD() -{ -# if HAS_DAPLINK_SERIAL - DAPLINKserial.printf(" Timer Disable\r\n"); -# endif - serial.printf(" Timer Disable "); - periodicInterruptTimer.detach(); // Detach the function -} -#endif - -//-------------------------------------------------- -// When user presses button BUTTON1, perform a demo configuration -#if HAS_BUTTON1_DEMO_INTERRUPT -void onButton1FallingEdge(void) -{ - void SelfTest(CmdLine & cmdLine); - - SelfTest(cmdLine_serial); - -#if 0 // APPLICATION_MAX5715 // onButton1FallingEdge BUTTON1 demo configuration MAX5715BOB - //~ cmdLine.serial().printf("MAX5715_REF(REF_AlwaysOn_2V500)"); - g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); - - uint16_t code = 4095; - //~ cmdLine.serial().printf("CODEallLOADall code=%d", code); - g_MAX5715_device.CODEallLOADall(code); -#endif // APPLICATION_MAX5715 - -} -#endif // HAS_BUTTON1_DEMO_INTERRUPT - -//-------------------------------------------------- -// When user presses button BUTTON2, perform a demo configuration -#if HAS_BUTTON2_DEMO_INTERRUPT -void onButton2FallingEdge(void) -{ - // TODO1: BUTTON2 demo configuration LED blink - -#if APPLICATION_MAX5715 // onButton2FallingEdge BUTTON2 demo configuration MAX5715BOB - //~ cmdLine.serial().printf("MAX5715_REF(REF_AlwaysOn_2V048)"); - g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048); - // - uint16_t ch = 0; - uint16_t code = 0xccc; - //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADn(ch, code); - // - ch = 1; - code = 0x800; - //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADn(ch, code); - // - ch = 2; - code = 0x666; - //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADn(ch, code); - // - ch = 3; - code = 0xFFF; - //~ cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADn(ch, code); -#elif APPLICATION_MAX11131 // onButton2FallingEdge BUTTON2 demo configuration MAX11131BOB - // TODO1: demo - // MAX11131 > 4 - // ScanStandardExternalClock ch=9 pm=0 id=1 - // ScanRead_nWords_chanID nWords=10 - // ch=0 xu=2964 = 0x0b94 = 1.8091V - // ch=1 xu=2227 = 0x08b3 = 1.3593V - // ch=2 xu=1570 = 0x0622 = 0.9583V - // ch=3 xu=865 = 0x0361 = 0.5280V - // ch=4 xu=630 = 0x0276 = 0.3845V - // ch=5 xu=594 = 0x0252 = 0.3625V - // ch=6 xu=461 = 0x01cd = 0.2814V - // ch=7 xu=364 = 0x016c = 0.2222V - // ch=8 xu=480 = 0x01e0 = 0.2930V - // ch=9 xu=616 = 0x0268 = 0.3760V - g_MAX11131_device.channelNumber_0_15 = 9; - g_MAX11131_device.PowerManagement_0_2 = 0; - g_MAX11131_device.chan_id_0_1 = 1; - g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock(); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - // TODO: compare with mbed/Arduino AIN0-AIN3 - // -#elif APPLICATION_MAX5171 // onButton2FallingEdge BUTTON2 demo configuration MAX5171BOB - // TODO: demo - uint16_t code = 0xccc; - g_MAX5171_device.CODE(code); -#elif APPLICATION_MAX11410 // onButton2FallingEdge BUTTON2 demo configuration MAX11410BOB - // TODO: demo - #warning "MAX11410 onButton2FallingEdge demo not defined" - //g_MAX11410_device.CODEnLOADn(ch, code); -#elif APPLICATION_MAX12345 // onButton2FallingEdge BUTTON2 demo configuration MAX12345BOB - // TODO: demo - g_MAX12345_device.CODEnLOADn(ch, code); -#endif // APPLICATION_MAX5715 - rgb_led.blue(); // diagnostic rbg led BLUE - -} -#endif // HAS_BUTTON2_DEMO_INTERRUPT - -//-------------------------------------------------- -// TODO1: use MaximTinyTester encapsulate SelfTest support functions -//-------------------------------------------------- -#if APPLICATION_MAX5715 // SelfTest -// -// Note: ide.mbed.com does not support C++11 Lambda Expressions -// -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ -// -// define function under test using C++11 lambda expression [](){} -// uint8_t MAX5715::Init(void) -// uint8_t (*fn_MAX5715_Init)() = [](){ return g_MAX5715_device.Init(); }; -uint8_t fn_MAX5715_Init() { return g_MAX5715_device.Init(); }; -// -// define function under test using C++11 lambda expression [](){} -// uint16_t MAX5715::DACCodeOfVoltage(double voltageV) -// uint16_t (*fn_MAX5715_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5715_device.DACCodeOfVoltage(voltageV); }; -uint16_t fn_MAX5715_DACCodeOfVoltage(double voltageV) { return g_MAX5715_device.DACCodeOfVoltage(voltageV); }; -// -// define function under test using C++11 lambda expression [](){} -// double MAX5715::VoltageOfCode(uint16_t value_u14) -//double (*fn_MAX5715_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5715_device.VoltageOfCode(value_u14); }; -double fn_MAX5715_VoltageOfCode(uint16_t value_u14) { return g_MAX5715_device.VoltageOfCode(value_u14); }; -// -// define function under test using C++11 lambda expression [](){} -// void MAX5715::CODEnLOADn(uint8_t channel_0_3, uint16_t dacCodeLsbs) -// 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); }; -void fn_MAX5715_CODEnLOADn (uint8_t channel_0_3, uint16_t dacCodeLsbs) { return g_MAX5715_device.CODEnLOADn(channel_0_3, dacCodeLsbs); }; -// -#endif // APPLICATION_MAX5715 // SelfTest -//-------------------------------------------------- -#if APPLICATION_MAX11131 // SelfTest -// -// Note: ide.mbed.com does not support C++11 Lambda Expressions -// -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ -// -// define function under test using C++11 lambda expression [](){} -// -#endif // APPLICATION_MAX11131 // SelfTest -//-------------------------------------------------- -#if APPLICATION_MAX5171 // SelfTest -// -// Note: ide.mbed.com does not support C++11 Lambda Expressions -// -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ -// -// define function under test using C++11 lambda expression [](){} -// uint8_t MAX5171::Init(void) -// uint8_t (*fn_MAX5171_Init)() = [](){ return g_MAX5171_device.Init(); }; -uint8_t fn_MAX5171_Init() { return g_MAX5171_device.Init(); }; -// -// define function under test using C++11 lambda expression [](){} -// uint16_t MAX5171::DACCodeOfVoltage(double voltageV) -// uint16_t (*fn_MAX5171_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5171_device.DACCodeOfVoltage(voltageV); }; -uint16_t fn_MAX5171_DACCodeOfVoltage(double voltageV) { return g_MAX5171_device.DACCodeOfVoltage(voltageV); }; -// -// define function under test using C++11 lambda expression [](){} -// double MAX5171::VoltageOfCode(uint16_t value_u14) -// double (*fn_MAX5171_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5171_device.VoltageOfCode(value_u14); }; -double fn_MAX5171_VoltageOfCode(uint16_t value_u14) { return g_MAX5171_device.VoltageOfCode(value_u14); }; -// -// define function under test using C++11 lambda expression [](){} -// uint8_t MAX5171::CODE_LOAD(uint16_t dacCodeLsbs) -// uint8_t (*fn_MAX5171_CODE_LOAD)(uint16_t dacCodeLsbs) = [](uint16_t dacCodeLsbs){ return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); }; -uint8_t fn_MAX5171_CODE_LOAD(uint16_t dacCodeLsbs) { return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); }; -// -// -#endif // APPLICATION_MAX5171 // SelfTest -//-------------------------------------------------- -#if APPLICATION_MAX11410 // SelfTest -// -// Note: ide.mbed.com does not support C++11 Lambda Expressions -// -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ -// -// define function under test using C++11 lambda expression [](){} -// -#endif // APPLICATION_MAX11410 // SelfTest -//-------------------------------------------------- -#if APPLICATION_MAX12345 // SelfTest -// -// Note: ide.mbed.com does not support C++11 Lambda Expressions -// -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ -// -// define function under test using C++11 lambda expression [](){} -// -#endif // APPLICATION_MAX12345 // SelfTest -//-------------------------------------------------- -void SelfTest_print_DACCodeOfVoltage(CmdLine& cmdLine, double voltageV) -{ - cmdLine.serial().printf("DACCodeOfVoltage(%6.4fV)", voltageV); - // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001 - // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001 - //~ dtostrf(voltageV, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer - //~ cmdLine.serial().printf(strOutLineBuffer); - //~ cmdLine.serial().printf("V)"); -} -//-------------------------------------------------- -#if APPLICATION_MAX5171 // SelfTest -void SelfTest_print_VoltageOfCode(CmdLine& cmdLine, uint16_t value_u14) -{ - cmdLine.serial().printf("VoltageOfCode(%d)", value_u14); -} -#endif // APPLICATION_MAX5171 -//-------------------------------------------------- -#if APPLICATION_MAX5715 // SelfTest -void SelfTest_print_Vref(CmdLine & cmdLine) -{ - cmdLine.serial().printf("VRef = %6.4fV LSB=%6.4fV", g_MAX5715_device.VRef, (g_MAX5715_device.VRef / 4095)); - //~ dtostrf(g_MAX5715_device.VRef, 6, 4, strOutLineBuffer); // value, width, precision, char* buffer - //~ cmdLine.serial().printf(strOutLineBuffer); - //~ cmdLine.serial().printf("V LSB="); - // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001 - // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001 - //~ dtostrf( (g_MAX5715_device.VRef / 4095), 6, 4, strOutLineBuffer); // value, width, precision, char* buffer - //~ cmdLine.serial().printf(strOutLineBuffer); - //~ cmdLine.serial().printf("V"); -} -#endif // APPLICATION_MAX5715 -//-------------------------------------------------- -#if APPLICATION_MAX5171 // SelfTest -void SelfTest_print_Vref(CmdLine & cmdLine) -{ - cmdLine.serial().printf("VRef = %7.5fV LSB=%7.5fV", g_MAX5171_device.VRef, (g_MAX5171_device.VRef / 16383)); - // For 12-bit DAC, dtostrf width, precision = 6, 4 i.e. 0.0001 - // For 14-bit DAC, dtostrf width, precision = 7, 5 i.e. 0.00001 -} -#endif // APPLICATION_MAX5171 -//-------------------------------------------------- -#if HAS_SPI2_MAX541 -MAX541 max541(spi2_max541, spi2_max541_cs); -#endif -//-------------------------------------------------- -bool SelfTest_MAX541_Voltage(CmdLine & cmdLine, MAX541 &max541, double voltageV) -{ - max541.Set_Voltage(voltageV); - // cmdLine.serial().printf("\r\n Test Fixture: MAX541 set output to %1.3fV = code 0x%4.4x", max541.Get_Voltage(), max541.Get_Code()); - cmdLine.serial().printf("\r\n Test Fixture: MAX541 set output to 0x%4.4x = %1.3fV", - max541.Get_Code(), max541.Get_Voltage()); -#if analogIn4_IS_HIGH_RANGE_OF_analogIn0 - // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. - MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4, led1, led2, led3); - tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support - tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support - tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support - tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support - tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support - tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support - // low range channels AIN0, AIN1, AIN2, AIN3 -#else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 - // Platform board uses simple analog inputs - MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5, led1, led2, led3); - tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support - tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support - tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support - tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support - tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support - tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support -#endif - tinyTester.Wait_Output_Settling(); // wait for MAX541 to settle - // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.100; - return tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); -} -//-------------------------------------------------- -void SelfTest(CmdLine & cmdLine) -{ - //-------------------------------------------------- -#if analogIn4_IS_HIGH_RANGE_OF_analogIn0 - // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. - MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4, led1, led2, led3); - tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support - tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support - tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support - tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support - tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support - tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support - // low range channels AIN0, AIN1, AIN2, AIN3 -#else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 - // Platform board uses simple analog inputs - MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5, led1, led2, led3); - tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support - tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support - tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support - tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support - tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support - tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support -#endif - tinyTester.clear(); -#if APPLICATION_MAX5715 // SelfTest - // - // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect - // - // Note: ide.mbed.com does not support C++11 Lambda Expressions - // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ - // define function under test using C++11 lambda expression [](){} - // uint8_t MAX5715::Init(void) - //uint8_t (*fn_MAX5715_Init)() = [](){ return g_MAX5715_device.Init(); }; - // - // define function under test using C++11 lambda expression [](){} - // uint16_t MAX5715::DACCodeOfVoltage(double voltageV) - //uint16_t (*fn_MAX5715_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5715_device.DACCodeOfVoltage(voltageV); }; - // - // define function under test using C++11 lambda expression [](){} - // double MAX5715::VoltageOfCode(uint16_t value_u14) - //double (*fn_MAX5715_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5715_device.VoltageOfCode(value_u14); }; - // - // define function under test using C++11 lambda expression [](){} - // void MAX5715::CODEnLOADn(uint8_t channel_0_3, uint16_t dacCodeLsbs) - //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); }; - // - // - // - // - // - //------------------------------------------------------------ - g_MAX5715_device.VRef = 4.096; // MAX5715 12-bit LSB = 0.0010V - SelfTest_print_Vref(cmdLine); - //~ cmdLine.serial().printf("\r\n"); - // - tinyTester.blink_time_msec = 20; // quickly speed through the software verification - // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0950, 0x0FFF); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0945, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0944, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0943, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0942, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0941, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0940, 0x0FFE); // search for code transition - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0939, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0938, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0937, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0936, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0935, 0x0FFD); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 4.0930, 0x0FFD); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0480, 0x0800); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0470, 0x07FF); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x03E8); // 1.0 volt - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0030, 0x0003); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0020, 0x0002); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0001); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS - // - // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 4.0950); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 4.0940); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 2.0480); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 2.0470); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x03E8, 1.0000); // 1.0 volt - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0010); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000); - // - //------------------------------------------------------------ - cmdLine.serial().printf("\r\n"); - g_MAX5715_device.VRef = 2.048; // 12-bit LSB = 0.0005V - SelfTest_print_Vref(cmdLine); - //~ cmdLine.serial().printf("\r\n"); - // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0480, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0479, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0478, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0477, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0476, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0475, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0474, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0473, 0x0FFF); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0472, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0471, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0470, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0469, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0468, 0x0FFE); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0467, 0x0FFD); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0466, 0x0FFD); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0465, 0x0FFD); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0464, 0x0FFD); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.0463, 0x0FFD); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0240, 0x0800); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0235, 0x07FF); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x07D0); // 1.0 volt - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0017, 0x0003); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0016, 0x0003); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0015, 0x0003); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0014, 0x0003); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0013, 0x0003); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0012, 0x0002); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0011, 0x0002); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0002); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0009, 0x0002); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0008, 0x0002); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0007, 0x0001); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0006, 0x0001); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0005, 0x0001); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0004, 0x0001); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0003, 0x0001); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0002, 0x0000); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0001, 0x0000); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS - // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 2.0475); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 2.0470); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFD, 2.0465); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 1.0240); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 1.0235); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07D0, 1.0000); // 1.0 volt - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0002, 0.0010); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0005); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000); - // - // - //------------------------------------------------------------ - cmdLine.serial().printf("\r\n"); - g_MAX5715_device.VRef = 2.500; // 12-bit LSB = 0.0006105006105006105V - SelfTest_print_Vref(cmdLine); - //~ cmdLine.serial().printf("\r\n"); - // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 10.0, 0x0FFF); // overrange FS - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.5000, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4999, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4998, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4997, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4996, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4995, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4994, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4993, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4992, 0x0FFF); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4991, 0x0FFF); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4990, 0x0FFE); // search for code transitions - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4989, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4988, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4987, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4986, 0x0FFE); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4985, 0x0FFE); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4984, 0x0FFD); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4983, 0x0FFD); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4982, 0x0FFD); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4981, 0x0FFD); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4980, 0x0FFD); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4979, 0x0FFD); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4978, 0x0FFC); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4977, 0x0FFC); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4976, 0x0FFC); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4975, 0x0FFC); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4974, 0x0FFC); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4973, 0x0FFC); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4972, 0x0FFB); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4971, 0x0FFB); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 2.4970, 0x0FFB); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.2500, 0x0800); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.2494, 0x07FF); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 1.0000, 0x0666); // 1.0 volt - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0019, 0x0003); // search for code transitions - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0018, 0x0003); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0017, 0x0003); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0016, 0x0003); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0015, 0x0002); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0014, 0x0002); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0013, 0x0002); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0012, 0x0002); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0011, 0x0002); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0010, 0x0002); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0009, 0x0001); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0008, 0x0001); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0007, 0x0001); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0006, 0x0001); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0005, 0x0001); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0004, 0x0001); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0003, 0x0000); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0002, 0x0000); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0001, 0x0000); - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, 0.0000, 0x0000); - // - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0001, 0x0000); // overrange ZS - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -0.0002, 0x0000); // overrange ZS - tinyTester.FunctionCall_Expect("MAX5715.DACCodeOfVoltage", fn_MAX5715_DACCodeOfVoltage, -1.0, 0x0000); // overrange ZS - // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFF, 2.5000); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFE, 2.4988); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0FFD, 2.4976); - // - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0800, 1.2500); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x07FF, 1.2494); - // - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0667, 1.0000); // 1.0 volt - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0666, 1.0000); // 1.0 volt - // - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0002, 0.0012); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0001, 0.0006); - tinyTester.FunctionCall_Expect("MAX5715.VoltageOfCode", fn_MAX5715_VoltageOfCode, 0x0000, 0.0000); - // - // - // Device Testing: DAC commands, verify using on-board ADC inputs - // - tinyTester.blink_time_msec = 75; - cmdLine.serial().printf("\r\n MAX5715.Init()"); - g_MAX5715_device.Init(); - // - uint16_t ch = 0; - uint16_t code = 0xfff; - double voltageV = 0.5; - // - // full-scale output on ch0, test MAX5715 internal REF options - ch = 0; - cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADn(ch, code); - // - cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_2V048)"); - g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048); - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.030; // 30mV - tinyTester.AnalogIn0_Read_Expect_voltageV(2.048); - // - cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_4V096)"); - g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_4V096); - // MAX32625MBED 4.096V may be as low as 3.3V supply - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.50; // 30mV - tinyTester.AnalogIn0_Read_Expect_voltageV(3.750); // accept 3.25V to 4.25V - // - cmdLine.serial().printf("\r\n MAX5715.REF(MAX5715::REF_AlwaysOn_2V500)"); - g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.030; // 30mV - tinyTester.AnalogIn0_Read_Expect_voltageV(2.500); - // - // test the individual channel outputs - ch = 0; - voltageV = 0.5; - code = g_MAX5715_device.DACCodeOfVoltage(voltageV); - cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADn(ch, code); - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.030; // 30mV - tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); - // - ch = 1; - voltageV = 0.2; - code = g_MAX5715_device.DACCodeOfVoltage(voltageV); - cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADn(ch, code); - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.030; // 30mV - tinyTester.AnalogIn1_Read_Expect_voltageV(voltageV); - // - ch = 2; - voltageV = 0.4; - code = g_MAX5715_device.DACCodeOfVoltage(voltageV); - cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADn(ch, code); - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.030; // 30mV - tinyTester.AnalogIn2_Read_Expect_voltageV(voltageV); - // - ch = 3; - voltageV = 0.25; - code = g_MAX5715_device.DACCodeOfVoltage(voltageV); - cmdLine.serial().printf("\r\n MAX5715.CODEnLOADn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADn(ch, code); - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.030; // 30mV - tinyTester.AnalogIn3_Read_Expect_voltageV(voltageV); - // - // test that the channels are independent - tinyTester.AnalogIn0_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[0])); - tinyTester.AnalogIn1_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[1])); - tinyTester.AnalogIn2_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[2])); - tinyTester.AnalogIn3_Read_Expect_voltageV(g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[3])); - // -#elif APPLICATION_MAX11131 - // - // MAX11131BOB self-test functions - //~ SelfTest_FAIL(cmdLine); - //~ cmdLine.serial().printf("test program not implemented yet"); - int16_t value_u12; - int channelId; - double voltageV = 0.5; - // - //cmdLine.serial().printf("\r\n 0.0: MAX11131.Init()"); - //g_MAX11131_device.Init(); - // - // Device Testing: ADC commands, verify with on-board ADC and SPI framing - // - tinyTester.blink_time_msec = 75; - // MAX11131 SelfTest: MAX11131 SPI connections (Power Supply and GND, SCLK, MOSI, MISO, CS) - cmdLine.serial().printf("\r\n"); - cmdLine.serial().printf( - "\r\n 1.0: Test SCAN_0100_StandardExt -- verify SPI (VDD, GND, SCLK, MOSI, MISO, CS)"); - cmdLine.serial().printf("\r\n MAX11131.Init()"); - g_MAX11131_device.Init(); - // Send MOSI data Expect MISO data Description - // 1000_0000_0000_0000 xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0 - // 0010_0111_1010_0100 xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL SCAN_0100_StandardExt CHSEL=15 RESET=1 CHANID=1 - // 0000_0000_0000_0000 0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0 - // 0000_0000_0000_0000 0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1 - // 0000_0000_0000_0000 0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2 - // 0000_0000_0000_0000 0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3 - // - cmdLine.serial().printf("\r\n MOSI <-- 1000_0000_0000_0000 ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0"); - g_MAX11131_device.SPIoutputCS(0); // drive CS low - g_MAX11131_device.SPIwrite16bits(0x8000); - g_MAX11131_device.SPIoutputCS(1); // drive CS high - // - cmdLine.serial().printf( - "\r\n MOSI <-- 0010_0111_1010_0100 ADC_MODE_CONTROL SCAN_0100_StandardExt CHSEL=15 RESET=1 CHANID=1"); - g_MAX11131_device.SPIoutputCS(0); // drive CS low - g_MAX11131_device.SPIwrite16bits(0x27a4); - g_MAX11131_device.SPIoutputCS(1); // drive CS high - // - for (int channelIndex = 0; channelIndex < 16; channelIndex++) { - //~ cmdLine.serial().printf("\r\n MISO --> expect 0000_xxxx_xxxx_xxxx"); - g_MAX11131_device.SPIoutputCS(0); // drive CS low - g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits(); - g_MAX11131_device.SPIoutputCS(1); // drive CS high - int expect_channelId = channelIndex; - int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F; - if (actual_channelId != expect_channelId) - { - tinyTester.FAIL(); - cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); - cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); - cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId); - } - else - { - tinyTester.PASS(); - cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); - cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); - } - } - // - // MAX11131 SelfTest: MAX11131 Supports Internal Clock Modes (CNVST, EOC) - cmdLine.serial().printf("\r\n"); - cmdLine.serial().printf( - "\r\n 1.1: Test SCAN_0011_StandardInt -- verify Internal Clock signals (CNVST, EOC)"); - cmdLine.serial().printf("\r\n MAX11131.Init()"); - g_MAX11131_device.Init(); - g_MAX11131_device.SPIoutputCS(0); // drive CS low - g_MAX11131_device.RAW_misoData16[0] = g_MAX11131_device.SPIread16bits(); - g_MAX11131_device.SPIoutputCS(1); // drive CS high -// - // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect - tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "initial value before sending commands"); -// - // Send MOSI data Expect MISO data Description - // 1000_0000_0000_0000 xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0 No Averaging - // 0001_1001_1010_0000 xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL SCAN_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0 - // 0000_0000_0000_0000 0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0 - // 0000_0000_0000_0000 0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1 - // 0000_0000_0000_0000 0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2 - // 0000_0000_0000_0000 0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3 - // - cmdLine.serial().printf("\r\n MOSI <-- 1000_0000_0000_0000 ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0"); - g_MAX11131_device.SPIoutputCS(0); // drive CS low - g_MAX11131_device.SPIwrite16bits(0x8000); - g_MAX11131_device.SPIoutputCS(1); // drive CS high - // - cmdLine.serial().printf( - "\r\n MOSI <-- 0001_1001_1010_0000 ADC_MODE_CONTROL SCAN_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0"); - g_MAX11131_device.SPIoutputCS(0); // drive CS low - g_MAX11131_device.SPIwrite16bits(0x19a0); - g_MAX11131_device.SPIoutputCS(1); // drive CS high - // - for (int channelIndex = 0; channelIndex < 4; channelIndex++) { - //~ cmdLine.serial().printf("\r\n MISO --> expect 0000_xxxx_xxxx_xxxx"); - //~ wait_ms(200); // delay - g_MAX11131_device.CNVSToutputPulseLow(); - //~ g_MAX11131_device.CNVSToutputValue(0); - //~ wait_ms(100); // delay - //~ g_MAX11131_device.CNVSToutputValue(1); - // g_MAX11131_device.EOCinputWaitUntilLow(); // infinite wait hazard, need to fail if timeout exceeded - // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect - tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 0, "after CNVST pulse"); - g_MAX11131_device.SPIoutputCS(0); // drive CS low - g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits(); - g_MAX11131_device.SPIoutputCS(1); // drive CS high - // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect - tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "after SPI read"); - int expect_channelId = channelIndex; - int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F; - if (actual_channelId != expect_channelId) - { - tinyTester.FAIL(); - cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); - cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); - cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId); - } - else - { - tinyTester.PASS(); - cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF)); - cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId); - } - } - // - // MAX11131 SelfTest: Test Fixture: MAX541ACPA+ to MAX32625MBED.AIN0/AIN4 - // Test Fixture: MAX541 connected to spi2 - // 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 - // DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header - // Test Fixture: MAX541 spi2 init - cmdLine.serial().printf("\r\n"); - cmdLine.serial().printf("\r\n 2.0: Test Fixture: MAX541 connected to spi2 (P2.4 P2.5 P2.7)?"); - bool SelfTest_has_max541 = false; - // Check actual MAX541 reference voltage - cmdLine.serial().printf("\r\n Test Fixture: MAX541 midscale voltage measure with MAX32625MBED AIN0/4"); - max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale - tinyTester.Wait_Output_Settling(); // wait for MAX541 to settle - // - double max541_midscale_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V - const int average_count = 100; - const double average_K = 0.25; - for (int count = 0; count < average_count; count++) { - double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V - max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V); - } - if (max541_midscale_V > 1.0f) { - max541.VRef = 2.0 * max541_midscale_V; - cmdLine.serial().printf("\r\n Test Fixture: MAX541 midscale = %1.3fV, so fullscale = %1.3fV", - max541_midscale_V, max541.VRef); - // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4 - voltageV = 1.0f; - SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - if (SelfTest_has_max541) { - voltageV = 0.0f; - SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - if (SelfTest_has_max541) { - voltageV = 2.7f; - SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - if (SelfTest_has_max541) { - voltageV = 1.65f; - SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - if (SelfTest_has_max541) { - voltageV = 2.0f; - SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - if (SelfTest_has_max541) { - voltageV = 0.25f; - SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - if (SelfTest_has_max541) { - voltageV = 0.5f; - SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - if (SelfTest_has_max541) { - voltageV = 1.0f; - SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - if (SelfTest_has_max541 == false) { - // don't fail just because we're missing the test fixture... - cmdLine.serial().printf("\r\n Test Fixture: MAX541 not present"); - //~ g_SelfTest_nFail--; - } - // - // TODO1: MAX11131 SelfTest: if Test Fixture: drive MAX541, compare MAX32625MBED.AIN0/AIN4 and MAX11131 AIN0 - // indirectly verify the reference voltage by reading a known input voltage - if (SelfTest_has_max541) { - cmdLine.serial().printf("\r\n"); - cmdLine.serial().printf("\r\n 2.1: TODO1: Check MAX11131 reference voltage using SCAN_0001_Manual"); - voltageV = 1.0f; - SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - cmdLine.serial().printf("\r\n MAX11131.Init()"); - g_MAX11131_device.Init(); - // 1 ScanManual ch=0 pm=0 id=1 - g_MAX11131_device.channelNumber_0_15 = 0; - g_MAX11131_device.PowerManagement_0_2 = 0; - g_MAX11131_device.chan_id_0_1 = 1; - cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15); - cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2); - cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1); - g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); - cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d", - g_MAX11131_device.NumWords); - g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); - g_MAX11131_device.ReadAINcode(); - cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); - AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); - // - // 2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here? - // - cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d", - g_MAX11131_device.NumWords); - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); - AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); - // - // 2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here? - // - // compare with mbed/Arduino AIN0-AIN3 - // MAX32625MBED.AIN4 = MAX11131.AIN0 - channelId = 0; - value_u12 = g_MAX11131_device.AINcode[channelId]; - voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); -// - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.100; - tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); -// - } - // - if (SelfTest_has_max541) { - voltageV = 1.0f; - SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - cmdLine.serial().printf("\r\n"); - cmdLine.serial().printf("\r\n 3.1: Test SCAN_0001_Manual"); - cmdLine.serial().printf("\r\n MAX11131.Init()"); - g_MAX11131_device.Init(); - // 1 ScanManual ch=0 pm=0 id=1 - g_MAX11131_device.channelNumber_0_15 = 0; - g_MAX11131_device.PowerManagement_0_2 = 0; - g_MAX11131_device.chan_id_0_1 = 1; - cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15); - cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2); - cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1); - g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); - cmdLine.serial().printf("\r\n MAX11131.ScanManual -- NumWords = %d", - g_MAX11131_device.NumWords); - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); - AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); - // compare with mbed/Arduino AIN0-AIN3 - // MAX32625MBED.AIN4 = MAX11131.AIN0 - channelId = 0; - value_u12 = g_MAX11131_device.AINcode[channelId]; - voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); -// - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.100; - tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); -// - // - cmdLine.serial().printf("\r\n"); - cmdLine.serial().printf("\r\n 3.4: Test SCAN_0100_StandardExternalClock"); - cmdLine.serial().printf("\r\n MAX11131.Init()"); - g_MAX11131_device.Init(); - // MAX11131 > 4 - // ScanStandardExternalClock ch=9 pm=0 id=1 - // ScanRead_nWords_chanID nWords=10 - // ch=0 xu=2964 = 0x0b94 = 1.8091V - // ch=1 xu=2227 = 0x08b3 = 1.3593V - // ch=2 xu=1570 = 0x0622 = 0.9583V - // ch=3 xu=865 = 0x0361 = 0.5280V - // ch=4 xu=630 = 0x0276 = 0.3845V - // ch=5 xu=594 = 0x0252 = 0.3625V - // ch=6 xu=461 = 0x01cd = 0.2814V - // ch=7 xu=364 = 0x016c = 0.2222V - // ch=8 xu=480 = 0x01e0 = 0.2930V - // ch=9 xu=616 = 0x0268 = 0.3760V - g_MAX11131_device.channelNumber_0_15 = 9; - g_MAX11131_device.PowerManagement_0_2 = 0; - g_MAX11131_device.chan_id_0_1 = 1; - cmdLine.serial().printf("\r\n MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15); - cmdLine.serial().printf("\r\n MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2); - cmdLine.serial().printf("\r\n MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1); - g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock(); - cmdLine.serial().printf("\r\n MAX11131.ScanStandardExternalClock -- NumWords = %d", - g_MAX11131_device.NumWords); - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - cmdLine.serial().printf("\r\n MAX11131.ReadAINcode"); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // expect g_MAX11131_device.NumWords == g_MAX11131_device.channelNumber_0_15 + 1; - // expect RAW_misoData16[index] msnybble 0,1,2,3,... - AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); - // compare with mbed/Arduino AIN0-AIN3 - // MAX32625MBED.AIN4 = MAX11131.AIN0 - channelId = 0; - value_u12 = g_MAX11131_device.AINcode[channelId]; - voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.err_threshold = 0.100; - tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV); - // compare MAX32625MBED.AIN5 = MAX11131.AIN1 - //channelId = 1; - //value_u12 = g_MAX11131_device.AINcode[channelId]; - //voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId); - //SelfTest_AnalogInput_Expect_ch_V(cmdLine, 5, voltageV, 0.100); - // -#elif APPLICATION_MAX5171 - - // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect - // - // Note: ide.mbed.com does not support C++11 Lambda Expressions - // -- see https://os.mbed.com/questions/82580/Is-there-solution-for-defining-of-interr/ - // define function under test using C++11 lambda expression [](){} - // uint8_t MAX5171::Init(void) - //uint8_t (*fn_MAX5171_Init)() = [](){ return g_MAX5171_device.Init(); }; - // - // define function under test using C++11 lambda expression [](){} - // uint16_t MAX5171::DACCodeOfVoltage(double voltageV) - //uint16_t (*fn_MAX5171_DACCodeOfVoltage)(double) = [](double voltageV){ return g_MAX5171_device.DACCodeOfVoltage(voltageV); }; - // - // define function under test using C++11 lambda expression [](){} - // double MAX5171::VoltageOfCode(uint16_t value_u14) - //double (*fn_MAX5171_VoltageOfCode)(uint16_t) = [](uint16_t value_u14){ return g_MAX5171_device.VoltageOfCode(value_u14); }; - // - // define function under test using C++11 lambda expression [](){} - // uint8_t MAX5171::CODE_LOAD(uint16_t dacCodeLsbs) - //uint8_t (*fn_MAX5171_CODE_LOAD)(uint16_t dacCodeLsbs) = [](uint16_t dacCodeLsbs){ return g_MAX5171_device.CODE_LOAD(dacCodeLsbs); }; - // - //double one_LSB = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.settle_time_msec = 250; - - g_MAX5171_device.VRef = 2.500; // MAX5171 14-bit LSB = 0.00015V - SelfTest_print_Vref(cmdLine); - tinyTester.err_threshold = (g_MAX5171_device.VRef / 16383); // 14-bit DAC FS - // - // tinyTester.FunctionCall_Expect replaces SelfTest_DACCodeOfVoltage_Expect - tinyTester.blink_time_msec = 20; // quickly speed through the software verification - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.499847412109375, 0x3FFF); - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.49969482421875, 0x3FFE); - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.499542236328125, 0x3FFD); - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 2.4993896484375, 0x3FFC); - // - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.250152587890625, 0x2001); - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.25, 0x2000); - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.249847412109375, 0x1FFF); - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 1.24969482421875, 0x1FFE); - // - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.000457763671875, 0x0003); - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.00030517578125, 0x0002); - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.000152587890625, 0x0001); - tinyTester.FunctionCall_Expect("MAX5171.DACCodeOfVoltage", fn_MAX5171_DACCodeOfVoltage, 0.00000, 0x0000); - // - // tinyTester.FunctionCall_Expect replaces SelfTest_VoltageOfCode_Expect - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFF, 2.499847412109375); - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFE, 2.49969482421875); - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFD, 2.499542236328125); - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x3FFC, 2.4993896484375); - // - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x2001, 1.250152587890625); - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x2000, 1.25); - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x1FFF, 1.249847412109375); - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x1FFE, 1.24969482421875); - // - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0003, 0.000457763671875); - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0002, 0.00030517578125); - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0001, 0.000152587890625); - tinyTester.FunctionCall_Expect("MAX5171.VoltageOfCode", fn_MAX5171_VoltageOfCode, 0x0000, 0.00000); - // - // Device Testing: DAC commands, verify using on-board ADC inputs - // - tinyTester.blink_time_msec = 75; - cmdLine.serial().printf("\r\n MAX5171.Init()"); - g_MAX5171_device.Init(); - // - tinyTester.err_threshold = 0.030; // 30mV - uint16_t code = 0x3FFF; - //~ double voltageV = 0.5; - // - cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code); - g_MAX5171_device.CODE_LOAD(code); - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.AnalogIn0_Read_Expect_voltageV(2.500); - // - code = 0x0000; - cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code); - g_MAX5171_device.CODE_LOAD(code); - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.AnalogIn0_Read_Expect_voltageV(0.0000); - // - code = 0x1FFF; - cmdLine.serial().printf("\r\n MAX5171.CODE_LOAD code=%d", code); - g_MAX5171_device.CODE_LOAD(code); - // tinyTester.Wait_Output_Settling replaces wait_ms - tinyTester.Wait_Output_Settling(); - // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V - tinyTester.AnalogIn0_Read_Expect_voltageV(1.2500); - // - // test UPO User Programmable Output, verify using digital input D2 - // - cmdLine.serial().printf("\r\n MAX5171.UPO_HIGH"); - g_MAX5171_device.UPO_HIGH(); - tinyTester.Wait_Output_Settling(); - // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin - tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command"); - // - cmdLine.serial().printf("\r\n MAX5171.UPO_LOW"); - g_MAX5171_device.UPO_LOW(); - tinyTester.Wait_Output_Settling(); - // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin - tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 0, "UPO_pin is low after MAX5171 UPO_LOW command"); - // - cmdLine.serial().printf("\r\n MAX5171.UPO_HIGH"); - g_MAX5171_device.UPO_HIGH(); - tinyTester.Wait_Output_Settling(); // wait_ms(100); // delay - // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_Expect_Input_UPO_pin - tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command"); - // -#elif APPLICATION_MAX11410 - // - // TODO: placeholder for self-test functions - tinyTester.FAIL(); - cmdLine.serial().printf("test program not implemented yet"); - // -#elif APPLICATION_MAX12345 - // - // TODO: placeholder for self-test functions - tinyTester.FAIL(); - cmdLine.serial().printf("test program not implemented yet"); - // -#else // APPLICATION_MAX5715 - // TODO: placeholder for self-test functions -#endif // APPLICATION_MAX5715 - // -#if INJECT_SELFTEST_FAIL - // Test of the pass/fail report mechanism - tinyTester.FAIL(); - cmdLine.serial().printf("injecting one false failure for test reporting"); -#endif - // - // Report number of pass and number of fail test results - tinyTester.Report_Summary(); -} - - -//-------------------------------------------------- -void main_menu_status(CmdLine & cmdLine) -{ - cmdLine.serial().printf("\r\nMain menu"); -#if APPLICATION_MAX5715 // main_menu_status banner - cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC"); -#elif APPLICATION_MAX11131 // main_menu_status banner - cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC"); -#elif APPLICATION_MAX5171 // main_menu_status banner - cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC"); -#elif APPLICATION_MAX11410 // main_menu_status banner - cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC"); -#elif APPLICATION_MAX12345 // main_menu_status banner - cmdLine.serial().printf(" MAX12345"); -#else - //cmdLine.serial().printf(" "); -#endif - cmdLine.serial().printf(" %s", TARGET_NAME); - if (cmdLine.nameStr()) - { - cmdLine.serial().printf(" [%s]", cmdLine.nameStr()); - } -#if HAS_BUTTON1_DEMO_INTERRUPT - cmdLine.serial().printf(" [Button1=DemoConfig1]"); -#endif -#if HAS_BUTTON2_DEMO_INTERRUPT - cmdLine.serial().printf(" [Button2=DemoConfig2]"); -#endif -#if HAS_BUTTON1_DEMO - // print BUTTON1 status - cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read()); -#endif -#if HAS_BUTTON2_DEMO - // print BUTTON1 status - cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read()); -#endif - cmdLine.serial().printf("\r\n ? -- help"); -} - -//-------------------------------------------------- -void main_menu_help(CmdLine & cmdLine) -{ - // ? -- help - //~ cmdLine.serial().printf("\r\nMenu:"); - cmdLine.serial().printf("\r\n # -- lines beginning with # are comments"); - cmdLine.serial().printf("\r\n . -- SelfTest"); - //cmdLine.serial().printf("\r\n ! -- Initial Configuration"); - // - // % standardize diagnostic commands - // %Hpin -- digital output high - // %Lpin -- digital output low - // %?pin -- digital input - // %A %Apin -- analog input - // %Ppin df=xx -- pwm output - // %Wpin -- measure high pulsewidth input in usec - // %wpin -- measure low pulsewidth input in usec - // %I... -- I2C diagnostics - // %IP -- I2C probe - // %IC scl=100khz ADDR=? -- I2C configure - // %IW ADDR=? cmd=? data,data,data -- write - // %IR ADDR=? RD=? -- read - // %I^ cmd=? -- i2c_smbus_read_word_data - // %S... -- SPI diagnostics - // %SC sclk=1Mhz -- SPI configure - // %SW -- write (write and read) - // %SR -- read (alias for %SW because SPI always write and read) - // A-Z,a-z,0-9 reserved for application use - // -#if HAS_digitalInOuts - // %Hpin -- digital output high - // %Lpin -- digital output low - // %?pin -- digital input - cmdLine.serial().printf("\r\n %%Hn {pin:"); - list_digitalInOutPins(cmdLine.serial()); - cmdLine.serial().printf("} -- High Output"); - cmdLine.serial().printf("\r\n %%Ln {pin:"); - list_digitalInOutPins(cmdLine.serial()); - cmdLine.serial().printf("} -- Low Output"); - cmdLine.serial().printf("\r\n %%?n {pin:"); - list_digitalInOutPins(cmdLine.serial()); - cmdLine.serial().printf("} -- Input"); -#endif - -#if HAS_analogIns - // Menu A) analogRead A0..7 - // %A %Apin -- analog input - // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0) - cmdLine.serial().printf("\r\n %%A -- analogRead"); -#endif - -#if HAS_SPI2_MAX541 - // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs); - cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)"); -#endif - -#if HAS_I2C // SUPPORT_I2C - // TODO: support I2C HAS_I2C // SUPPORT_I2C - // VERIFY: I2C utility commands SUPPORT_I2C - // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz); - // %I... -- I2C diagnostics - // %IP -- I2C probe - // %IC scl=100khz ADDR=? -- I2C configure - // %IW byte byte ... byte RD=? ADDR=0x -- write - // %IR ADDR=? RD=? -- read - // %I^ cmd=? -- i2c_smbus_read_word_data - //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope - cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config", - g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz, - (g_I2C_SCL_Hz / 1000.)); - cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read", - g_I2C_deviceAddress7); - // -#if SUPPORT_I2C - // Menu ^ cmd=?) i2c_smbus_read_word_data - cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data"); - // test low-level I2C i2c_smbus_read_word_data -#endif // SUPPORT_I2C - //cmdLine.serial().printf(" H) Hunt for attached I2C devices"); - cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices"); - // cmdLine.serial().printf(" s) search i2c address"); -#endif // SUPPORT_I2C - -#if HAS_SPI // SUPPORT_SPI - // TODO: support SPI HAS_SPI // SUPPORT_SPI - // SPI test command S (mosiData)+ - // %S... -- SPI diagnostics - // %SC sclk=1Mhz -- SPI configure - // %SW -- write (write and read) - // %SR -- read (alias for %SW because SPI always write and read) - // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default) - // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default) - // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default) - // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default) - // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default) - // mode | POL PHA - // -----+-------- - // 0 | 0 0 - // 1 | 0 1 - // 2 | 1 0 - // 3 | 1 1 - //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0"); - // 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=] - cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config", - g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.), - ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0), - ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0)); - cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes"); - // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0 -#endif // SUPPORT_SPI - // - // Application-specific commands (help text) here - // -#if APPLICATION_ArduinoPinsMonitor -# if APPLICATION_MAX5715 // main_menu_help -# elif APPLICATION_MAX11131 // main_menu_help -# elif APPLICATION_MAX5171 // main_menu_help -# elif APPLICATION_MAX11410 // main_menu_help -# elif APPLICATION_MAX12345 // main_menu_help -# else - cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor -# endif -#endif // APPLICATION_ArduinoPinsMonitor - // -#if APPLICATION_MAX5715 // main_menu_help - cmdLine.serial().printf("\r\n 0 ch=? code=? -- CODEn"); - cmdLine.serial().printf("\r\n 1 ch=? -- LOADn"); - cmdLine.serial().printf("\r\n 2 ch=? code=? -- CODEnLOADall"); - cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); - cmdLine.serial().printf("\r\n 40 ch=? -- POWERn_Normal"); - cmdLine.serial().printf("\r\n 41 ch=? -- POWERn_PD1k"); - cmdLine.serial().printf("\r\n 42 ch=? -- POWERn_PD100k"); - cmdLine.serial().printf("\r\n 43 ch=? -- POWERn_PDHiZ"); - cmdLine.serial().printf("\r\n 50 -- SW_CLEAR"); - cmdLine.serial().printf("\r\n 51 -- SW_RESET"); - cmdLine.serial().printf("\r\n 60 ch=? -- CONFIGn_LATCHED"); - cmdLine.serial().printf("\r\n 61 ch=? -- CONFIGn_TRANSPARENT"); - cmdLine.serial().printf("\r\n 68 -- CONFIGall_LATCHED"); - cmdLine.serial().printf("\r\n 69 -- CONFIGall_TRANSPARENT"); - cmdLine.serial().printf("\r\n 70 -- REF_EXT"); - cmdLine.serial().printf("\r\n 71 -- REF_2V500"); - cmdLine.serial().printf("\r\n 72 -- REF_2V048"); - cmdLine.serial().printf("\r\n 73 -- REF_4V096"); - cmdLine.serial().printf("\r\n 74 -- REF_AlwaysOn_EXT"); - cmdLine.serial().printf("\r\n 75 -- REF_AlwaysOn_2V500"); - cmdLine.serial().printf("\r\n 76 -- REF_AlwaysOn_2V048"); - cmdLine.serial().printf("\r\n 77 -- REF_AlwaysOn_4V096"); - cmdLine.serial().printf("\r\n 80 code=? -- CODEall"); - cmdLine.serial().printf("\r\n 81 -- LOADall"); - cmdLine.serial().printf("\r\n 82 code=? -- CODEallLOADall"); - //cmdLine.serial().printf("\r\n 83 code=? -- CODEallLOADall"); - // - // Menu @ -- print device configuration - cmdLine.serial().printf("\r\n @ -- print MAX5715 configuration"); - // - // MAX5717 menu function to drive MAX5717_LDACb_Pin LDAC# - // Note: '~' is not recommended for menu commands, interferes with ssh - cmdLine.serial().printf("\r\n L -- LDAC# pulse LH high LL low"); - // MAX5717 menu function to drive MAX5717_CLRb_Pin CLR# - cmdLine.serial().printf("\r\n C -- CLR# pulse CH high CL low"); -#endif // APPLICATION_MAX5715 - // -#if APPLICATION_MAX11131 // main_menu_help - // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void); - cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead"); - // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); - cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual"); - // 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); - cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat"); - // 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); - cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock"); - // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); - cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock"); - // 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); - cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock"); - // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); - cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock"); - // 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); - cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock"); - // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1); - cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock"); - // VERIFY: console menu command 9 MAX11131_ScanSampleSetExternalClock(uint8_t enabledChannelsPatternLength_1_256, int16_t enabledChannelsPattern[], int PowerManagement_0_2, int chan_id_0_1); - cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock"); - cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration"); - cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range"); - // cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual"); - // Note: '~' is not recommended for menu commands, interferes with ssh -#endif // APPLICATION_MAX11131 - // -#if APPLICATION_MAX5171 // main_menu_help - // TODO1: MAX5171 main_menu_help - cmdLine.serial().printf("\r\n 0 code=? -- CODE"); - cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD"); - cmdLine.serial().printf("\r\n 8 -- LOAD"); - cmdLine.serial().printf("\r\n c -- NOP"); - cmdLine.serial().printf("\r\n d -- SHUTDOWN"); - cmdLine.serial().printf("\r\n e0 -- UPO_LOW"); - cmdLine.serial().printf("\r\n e8 -- UPO_HIGH"); - cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE"); - cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE"); - // Note: '~' is not recommended for menu commands, interferes with ssh -#endif // APPLICATION_MAX5171 - // -#if 0 // APPLICATION_MAX11410 // main_menu_help - // TODO1: MAX11410 main_menu_help - cmdLine.serial().printf("\r\n W reg=? data=? -- write register"); - cmdLine.serial().printf("\r\n R reg=? -- read register"); - cmdLine.serial().printf("\r\n S -- read status register"); - cmdLine.serial().printf("\r\n CV ch=? ainp=? ainn=? pga=? -- (future) Voltage configuration"); - cmdLine.serial().printf("\r\n MV -- (future) Voltage measurement"); - cmdLine.serial().printf("\r\n CT -- (future) Thermocouple configuration"); - cmdLine.serial().printf("\r\n MT -- (future) Thermocouple measurement"); - cmdLine.serial().printf("\r\n CR -- (future) Resistive Temperature Device (RTD) configuration"); - cmdLine.serial().printf("\r\n MR -- (future) RTD measurement"); - // Menu @ -- print device configuration - cmdLine.serial().printf("\r\n @ -- print MAX11410 configuration"); - // Note: '~' is not recommended for menu commands, interferes with ssh -#endif // APPLICATION_MAX11410 - // -#if APPLICATION_MAX12345 // main_menu_help - cmdLine.serial().printf("\r\n 0 -- something"); - cmdLine.serial().printf("\r\n 1 -- something"); - cmdLine.serial().printf("\r\n 2 -- something"); - cmdLine.serial().printf("\r\n A -- something"); - cmdLine.serial().printf("\r\n B -- something"); - cmdLine.serial().printf("\r\n C -- something"); - // Note: '~' is not recommended for menu commands, interferes with ssh -#endif // APPLICATION_MAX12345 - // - // - extern bool MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n - MAX11410_menu_help(cmdLine); -} - -//-------------------------------------------------- -// diagnostic commands submenu -// invoked by main_menu_onEOLcommandParser case '%' -void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine) -{ - // % diagnostic commands submenu - // %Hpin -- digital output high - // %Lpin -- digital output low - // %?pin -- digital input - // %A %Apin -- analog input - // %Ppin df=xx -- pwm output - // %Wpin -- measure high pulsewidth input in usec - // %wpin -- measure low pulsewidth input in usec - // %I... -- I2C diagnostics - // %IP -- I2C probe - // %IC scl=100khz ADDR=? -- I2C configure - // %IW byte byte ... byte RD=? ADDR=0x -- write - // %IR ADDR=? RD=? -- read - // %I^ cmd=? -- i2c_smbus_read_word_data - // %S... -- SPI diagnostics - // %SC sclk=1Mhz -- SPI configure - // %SW -- write (write and read) - // %SR -- read (alias for %SW because SPI always write and read) - // A-Z,a-z,0-9 reserved for application use - // - // get pinIndex from cmdLine[2] - //int pinIndex = cmdLine[2]; - // *** warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith] - //int pinIndex = strtoul((char *)((void *)(cmdLine.str()) + 2), NULL, 10); // strtol(str, NULL, 10): get decimal value - // ^ - char strPinIndex[3]; - strPinIndex[0] = cmdLine[2]; - strPinIndex[1] = cmdLine[3]; - strPinIndex[2] = '\0'; - int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value - //cmdLine.serial().printf(" pinIndex=%d ", pinIndex); - // - // get next character - switch (cmdLine[1]) - { -#if HAS_digitalInOuts - case 'H': case 'h': - { - // %Hpin -- digital output high -#if ARDUINO_STYLE - pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 - digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 -#else - DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); - digitalInOutPin.output(); - digitalInOutPin.write(1); -#endif - cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex); - } - break; - case 'L': case 'l': - { - // %Lpin -- digital output low -#if ARDUINO_STYLE - pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 - digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 -#else - DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); - digitalInOutPin.output(); - digitalInOutPin.write(0); -#endif - cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex); - } - break; - case '?': - { - // %?pin -- digital input -#if ARDUINO_STYLE - pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5 -#else - DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex); - digitalInOutPin.input(); -#endif - serial.printf(" digitalInOutPin %d Input ", pinIndex); -#if ARDUINO_STYLE - int value = digitalRead(pinIndex); -#else - int value = digitalInOutPin.read(); -#endif - cmdLine.serial().printf("%d ", value); - } - break; -#endif - // -#if HAS_analogIns - case 'A': case 'a': - { - // %A %Apin -- analog input -#if analogIn4_IS_HIGH_RANGE_OF_analogIn0 - // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,.. - for (int pinIndex = 0; pinIndex < 2; pinIndex++) - { - int cPinIndex = '0' + pinIndex; - AnalogIn& analogInPin = find_analogInPin(cPinIndex); - float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; - float normValue_0_1 = analogInPin.read(); - // - int pinIndexH = pinIndex + 4; - int cPinIndexH = '0' + pinIndexH; - AnalogIn& analogInPinH = find_analogInPin(cPinIndexH); - float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH]; - float normValueH_0_1 = analogInPinH.read(); - // - cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV \r\n", - cPinIndex, - normValue_0_1 * 100.0, - normValue_0_1 * adc_full_scale_voltage, - cPinIndexH, - normValueH_0_1 * 100.0, - normValueH_0_1 * adc_full_scale_voltageH - ); - } - for (int pinIndex = 2; pinIndex < 4; pinIndex++) - { - int cPinIndex = '0' + pinIndex; - AnalogIn& analogInPin = find_analogInPin(cPinIndex); - float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; - float normValue_0_1 = analogInPin.read(); - // - cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n", - cPinIndex, - normValue_0_1 * 100.0, - normValue_0_1 * adc_full_scale_voltage - ); - } -#else // analogIn4_IS_HIGH_RANGE_OF_analogIn0 - // Platform board uses simple analog inputs - // assume standard Arduino analog inputs A0-A5 - for (int pinIndex = 0; pinIndex < 6; pinIndex++) - { - int cPinIndex = '0' + pinIndex; - AnalogIn& analogInPin = find_analogInPin(cPinIndex); - float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex]; - float normValue_0_1 = analogInPin.read(); - // - cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n", - cPinIndex, - normValue_0_1 * 100.0, - normValue_0_1 * adc_full_scale_voltage - ); - } -#endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0 - } - break; -#endif - // -#if HAS_SPI2_MAX541 - case 'D': case 'd': - { - // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV) - // MAX541 max541(spi2_max541, spi2_max541_cs); - float voltageV = max541.Get_Voltage(); - // if (cmdLine[2] == '+') { - // // %D+ - // voltageV = voltageV * 1.25f; - // if (voltageV >= max541.VRef) voltageV = max541.VRef; - // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - // } - // else if (cmdLine[2] == '-') { - // // %D- - // voltageV = voltageV * 0.75f; - // if (voltageV < 0.1f) voltageV = 0.1f; - // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - // } - if (cmdLine.parse_float("V", voltageV)) - { - // %D V=1.234 -- set voltage - max541.Set_Voltage(voltageV); - } - else if (cmdLine.parse_float("TEST", voltageV)) - { - // %D TEST=1.234 -- set voltage and compare with AIN0 - SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - else if (cmdLine.parse_float("CAL", voltageV)) - { - // %D CAL=1.234 -- calibrate VRef and compare with AIN0 - - max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale - double max541_midscale_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V - const int average_count = 100; - const double average_K = 0.25; - for (int count = 0; count < average_count; count++) { - double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V - max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V); - } - max541.VRef = 2.0 * max541_midscale_V; - cmdLine.serial().printf( - "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV", - max541_midscale_V, max541.VRef); - // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4 - voltageV = 1.0f; - SelfTest_MAX541_Voltage(cmdLine, max541, voltageV); - } - else { - // %D -- print MAX541 DAC status - cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n", - max541.Get_Code(), max541.Get_Voltage(), max541.VRef); - } - } - break; -#endif - - // -#if HAS_I2C // SUPPORT_I2C - case 'I': case 'i': - // %I... -- I2C diagnostics - // %IP -- I2C probe - // %IC scl=100khz ADDR=? -- I2C configure - // %IW byte byte ... byte RD=? ADDR=0x -- write - // %IR ADDR=? RD=? -- read - // %I^ cmd=? -- i2c_smbus_read_word_data - // get next character - // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7 - cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7); - // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count - g_I2C_read_count = 0; // read count must be reset every command - cmdLine.parse_byte_dec("RD", g_I2C_read_count); - // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress - cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress); - switch (cmdLine[2]) - { - case 'P': case 'p': - { - // %IP -- I2C probe - HuntAttachedI2CDevices(cmdLine, 0x03, 0x77); - } - break; - case 'C': case 'c': - { - bool isUpdatedI2CConfig = false; - // %IC scl=100khz ADDR=? -- I2C configure - // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz - if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz)) - { - isUpdatedI2CConfig = true; - // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU - if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz) - { - g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz; - } - if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz) - { - g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz; - } - } - if (isUpdatedI2CConfig) - { - // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) - I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header - i2cMaster.frequency(g_I2C_SCL_Hz); - i2cMaster.start(); - i2cMaster.stop(); - i2cMaster.frequency(g_I2C_SCL_Hz); - cmdLine.serial().printf( - "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config", - g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz, - (g_I2C_SCL_Hz / 1000.)); - i2cMaster.start(); - i2cMaster.stop(); - } - } - break; - case 'W': case 'w': - { - // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) - I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header - i2cMaster.frequency(g_I2C_SCL_Hz); - // %IW byte byte ... byte RD=? ADDR=0x -- write - // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; - #define MAX_I2C_BYTE_COUNT 32 - size_t byteCount = byteCount; - static char mosiData[MAX_I2C_BYTE_COUNT]; - static char misoData[MAX_I2C_BYTE_COUNT]; - if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, - MAX_I2C_BYTE_COUNT)) - { - // hex dump mosiData[0..byteCount-1] - cmdLine.serial().printf( - "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->", - g_I2C_deviceAddress7, - (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count); - for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) - { - cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]); - } - // - // TODO: i2c transfer - //const int addr7bit = 0x48; // 7 bit I2C address - //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 - // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. - // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. - // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. - // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. - // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. - // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. - // /* 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... - // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... - const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90 - unsigned int misoLength = 0; - bool repeated = (g_I2C_read_count > 0); - // - int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated); - switch (writeStatus) - { - case 0: cmdLine.serial().printf(" ack "); break; - case 1: cmdLine.serial().printf(" nack "); break; - default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ", - writeStatus); - } - if (repeated) - { - int readStatus = - i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false); - switch (readStatus) - { - case 1: cmdLine.serial().printf(" nack "); break; - case 0: cmdLine.serial().printf(" ack "); break; - default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ", - readStatus); - } - } - // - if (misoLength > 0) - { - // hex dump misoData[0..byteCount-1] - cmdLine.serial().printf(" MISO<-"); - for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count; - byteIndex++) - { - cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]); - } - } - cmdLine.serial().printf(" "); - } - } - break; - case 'R': case 'r': - { - // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) - I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header - i2cMaster.frequency(g_I2C_SCL_Hz); - // %IR ADDR=? RD=? -- read - // TODO: i2c transfer - //const int addr7bit = 0x48; // 7 bit I2C address - //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 - // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. - // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. - // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. - // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. - // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. - // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. - // /* 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... - // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... - } - break; - case '^': - { - // declare in narrower scope: MAX32625MBED I2C i2cMaster(...) - I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header - i2cMaster.frequency(g_I2C_SCL_Hz); - // %I^ cmd=? -- i2c_smbus_read_word_data - // TODO: i2c transfer - //const int addr7bit = 0x48; // 7 bit I2C address - //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90 - // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave. - // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus. - // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave. - // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus. - // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus. - // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus. - // /* 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... - // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More... - } - break; - } // switch(cmdLine[2]) - break; -#endif - // -#if HAS_SPI // SUPPORT_SPI - case 'S': case 's': - { - // %S... -- SPI diagnostics - // %SC sclk=1Mhz -- SPI configure - // %SW -- write (write and read) - // %SR -- read (alias for %SW because SPI always write and read) - // - // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d - bool isUpdatedSPIConfig = false; - // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2 - // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1 - if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2)) - { - isUpdatedSPIConfig = true; - } - if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1)) - { - isUpdatedSPIConfig = true; - } - if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1)) - { - isUpdatedSPIConfig = true; - } - // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz - if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz)) - { - isUpdatedSPIConfig = true; - // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU - if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz) - { - g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz; - } - if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz) - { - g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz; - } - } - // Update SPI configuration - if (isUpdatedSPIConfig) - { - // %SC sclk=1Mhz -- SPI configure - spi_cs = g_SPI_cs_state; - spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 -#if APPLICATION_MAX5715 - g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz); -#elif APPLICATION_MAX11131 - g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz); -#elif APPLICATION_MAX5171 - g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz); -#elif APPLICATION_MAX11410 - g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz); -#elif APPLICATION_MAX12345 - g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz); -#else - spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default) -#endif - // - double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz; - int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate - double actual_SCLK_Hz = SystemCoreClock / actual_divisor; - // - // 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=] - cmdLine.serial().printf( - "\r\n %%SC CPOL=%d CPHA=%d CS=%d SCLK=%ld=%1.3fMHz (%1.1fMHz/%1.2f = actual %1.3fMHz) -- SPI config", - ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0), - ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0), - g_SPI_cs_state, - g_SPI_SCLK_Hz, - (g_SPI_SCLK_Hz / 1000000.), - ((double)(SystemCoreClock / 1000000.)), - ideal_divisor, - (actual_SCLK_Hz / 1000000.) - ); - } - // get next character - switch (cmdLine[2]) - { - case 'C': case 's': - // %SC sclk=1Mhz -- SPI configure - break; - case 'W': case 'R': case 'w': case 'r': - { - // %SW -- write (write and read) - // %SR -- read (alias for %SW because SPI always write and read) - // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; - #define MAX_SPI_BYTE_COUNT 32 - size_t byteCount = byteCount; - static char mosiData[MAX_SPI_BYTE_COUNT]; - static char misoData[MAX_SPI_BYTE_COUNT]; - if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, - MAX_SPI_BYTE_COUNT)) - { - // hex dump mosiData[0..byteCount-1] - cmdLine.serial().printf("\r\nSPI"); - if (byteCount > 7) { - cmdLine.serial().printf(" byteCount:%d", byteCount); - } - cmdLine.serial().printf(" MOSI->"); - for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) - { - cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]); - } - spi_cs = 0; - unsigned int numBytesTransferred = - spi.write(mosiData, byteCount, misoData, byteCount); - spi_cs = 1; - // hex dump misoData[0..byteCount-1] - cmdLine.serial().printf(" MISO<-"); - for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; - byteIndex++) - { - cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]); - } - cmdLine.serial().printf(" "); - } - } - break; - } // switch(cmdLine[2]) - } // case 'S': // %S... -- SPI diagnostics - break; -#endif - // - // A-Z,a-z,0-9 reserved for application use - } // switch(cmdLine[1]) -} // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine) - - -//-------------------------------------------------- -#if 0 // APPLICATION_MAX5715 // MAX5715_menu_onEOLcommandParser moved to Test_Menu_MAX5715.cpp -bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine) -{ - switch (cmdLine[0]) - { - case '0': - { - // recommended for hex command codes 00..0F - // TODO: cmdLine.serial().printf("\r\n 0 ch=? code=? -- CODEn"); - // Menu 0 ch=? code=?) CODEn - // MAX5715_CODEn(uint8_t channel, uint16_t dacCodeLsbs); - // VERIFY: parse strCommandArgs for additional arguments including key=value pairs - // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); - uint16_t ch = g_MAX5715_device.channelNumber_0_3; - if (cmdLine.parse_uint16_dec("ch", ch)) - { - } - uint16_t code = g_MAX5715_device.CODE[ch]; - if (cmdLine.parse_uint16_dec("code", code)) - { - } - cmdLine.serial().printf("CODEn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEn(ch, code); - return true; // command was handled by MAX5715 - } - break; - case '1': - { - // recommended for hex command codes 10..1F - // TODO: cmdLine.serial().printf("\r\n 1 ch=? -- LOADn"); - // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); - uint16_t ch = g_MAX5715_device.channelNumber_0_3; - if (cmdLine.parse_uint16_dec("ch", ch)) - { - } - cmdLine.serial().printf("LOADn ch=%d", ch); - g_MAX5715_device.LOADn(ch); - return true; // command was handled by MAX5715 - } - break; - case '2': - { - // recommended for hex command codes 20..2F - // TODO: cmdLine.serial().printf("\r\n 2 ch=? code=? -- CODEnLOADall"); - // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); - uint16_t ch = g_MAX5715_device.channelNumber_0_3; - if (cmdLine.parse_uint16_dec("ch", ch)) - { - } - uint16_t code = g_MAX5715_device.CODE[ch]; - if (cmdLine.parse_uint16_dec("code", code)) - { - } - cmdLine.serial().printf("CODEnLOADall ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADall(ch, code); - return true; // command was handled by MAX5715 - } - break; - case '3': - { - // recommended for hex command codes 30..3F - // TODO: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); - // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); - uint16_t ch = g_MAX5715_device.channelNumber_0_3; - uint16_t code; - if (cmdLine.parse_uint16_dec("ch", ch)) - { - } - if (cmdLine.parse_uint16_dec("code", code)) - { - } - cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); - g_MAX5715_device.CODEnLOADn(ch, code); - return true; // command was handled by MAX5715 - } - break; - case '4': - { - // recommended for hex command codes 40..4F - switch (cmdLine[1]) - { - case '0': - { - // cmdLine.serial().printf("\r\n 40 ch=? -- POWERn_Normal"); - cmdLine.serial().printf( - "channel_dcba=%d, POWERn_Normal)", - g_MAX5715_device.channels_bitmask_DCBA); - g_MAX5715_device.POWER(g_MAX5715_device. - channels_bitmask_DCBA, - MAX5715::POWERn_Normal); - return true; // command was handled by MAX5715 - } - break; - case '1': - { - // cmdLine.serial().printf("\r\n 41 ch=? -- POWERn_PD1k"); - cmdLine.serial().printf( - "channel_dcba=%d, POWERn_PD1k)", - g_MAX5715_device.channels_bitmask_DCBA); - g_MAX5715_device.POWER(g_MAX5715_device. - channels_bitmask_DCBA, - MAX5715::POWERn_PD1k); - return true; // command was handled by MAX5715 - } - break; - case '2': - { - // cmdLine.serial().printf("\r\n 42 ch=? -- POWERn_PD100k"); - cmdLine.serial().printf( - "channel_dcba=%d, POWERn_PD100k)", - g_MAX5715_device.channels_bitmask_DCBA); - g_MAX5715_device.POWER(g_MAX5715_device. - channels_bitmask_DCBA, - MAX5715::POWERn_PD100k); - return true; // command was handled by MAX5715 - } - break; - case '3': - { - // cmdLine.serial().printf("\r\n 43 ch=? -- POWERn_PDHiZ"); - cmdLine.serial().printf( - "channel_dcba=%d, POWERn_PDHiZ)", - g_MAX5715_device.channels_bitmask_DCBA); - g_MAX5715_device.POWER(g_MAX5715_device. - channels_bitmask_DCBA, - MAX5715::POWERn_PDHiZ); - return true; // command was handled by MAX5715 - } - break; - } - break; - } - break; - case '5': - { - // recommended for hex command codes 50..5F - switch (cmdLine[1]) - { - case '0': - { - // cmdLine.serial().printf("\r\n 50 -- SW_CLEAR"); - cmdLine.serial().printf("SW_CLEAR"); - g_MAX5715_device.SW_CLEAR(); - return true; // command was handled by MAX5715 - } - break; - case '1': - { - // cmdLine.serial().printf("\r\n 51 -- SW_RESET"); - cmdLine.serial().printf("SW_RESET"); - g_MAX5715_device.SW_RESET(); - return true; // command was handled by MAX5715 - } - break; - } - } - break; - case '6': - { - // recommended for hex command codes 60..6F - switch (cmdLine[1]) - { - case '0': - { - // cmdLine.serial().printf("\r\n 60 ch=? -- CONFIGn_LATCHED"); - cmdLine.serial().printf( - "MAX5715_CONFIGn_LATCHED(channel_dcba=%d)", - g_MAX5715_device. - channels_bitmask_DCBA); - g_MAX5715_device.CONFIGn_LATCHED(g_MAX5715_device. - channels_bitmask_DCBA); - return true; // command was handled by MAX5715 - } - break; - case '1': - { - // cmdLine.serial().printf("\r\n 61 ch=? -- CONFIGn_TRANSPARENT"); - cmdLine.serial().printf( - "MAX5715_CONFIGn_TRANSPARENT(channel_dcba=%d)", - g_MAX5715_device. - channels_bitmask_DCBA); - g_MAX5715_device.CONFIGn_TRANSPARENT( - g_MAX5715_device.channels_bitmask_DCBA); - return true; // command was handled by MAX5715 - } - break; - case '8': - { - // cmdLine.serial().printf("\r\n 68 -- CONFIGall_LATCHED"); - cmdLine.serial().printf( - "MAX5715_CONFIGall_LATCHED()"); - g_MAX5715_device.CONFIGall_LATCHED(); - return true; // command was handled by MAX5715 - } - break; - case '9': - { - // cmdLine.serial().printf("\r\n 69 -- CONFIGall_TRANSPARENT"); - cmdLine.serial().printf( - "MAX5715_CONFIGall_TRANSPARENT()"); - g_MAX5715_device.CONFIGall_TRANSPARENT(); - return true; // command was handled by MAX5715 - } - break; - } - } - break; - case '7': - { - // recommended for hex command codes 70..7F - switch (cmdLine[1]) - { - case '0': - { - // cmdLine.serial().printf("\r\n 70 -- REF_EXT"); - cmdLine.serial().printf( - "MAX5715_REF(REF_EXT)"); - g_MAX5715_device.REF(MAX5715::REF_EXT); - return true; // command was handled by MAX5715 - } - break; - case '1': - { - // cmdLine.serial().printf("\r\n 71 -- REF_2V500"); - cmdLine.serial().printf( - "MAX5715_REF(REF_2V500)"); - g_MAX5715_device.REF(MAX5715::REF_2V500); - return true; // command was handled by MAX5715 - } - break; - case '2': - { - // cmdLine.serial().printf("\r\n 72 -- REF_2V048"); - cmdLine.serial().printf( - "MAX5715_REF(REF_2V048)"); - g_MAX5715_device.REF(MAX5715::REF_2V048); - return true; // command was handled by MAX5715 - } - break; - case '3': - { - // cmdLine.serial().printf("\r\n 73 -- REF_4V096"); - cmdLine.serial().printf( - "MAX5715_REF(REF_4V096)"); - g_MAX5715_device.REF(MAX5715::REF_4V096); - return true; // command was handled by MAX5715 - } - break; - case '4': - { - // cmdLine.serial().printf("\r\n 74 -- REF_AlwaysOn_EXT"); - cmdLine.serial().printf( - "MAX5715_REF(REF_AlwaysOn_EXT)"); - g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_EXT); - return true; // command was handled by MAX5715 - } - break; - case '5': - { - // cmdLine.serial().printf("\r\n 75 -- REF_AlwaysOn_2V500"); - cmdLine.serial().printf( - "MAX5715_REF(REF_AlwaysOn_2V500)"); - g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); - return true; // command was handled by MAX5715 - } - break; - case '6': - { - // cmdLine.serial().printf("\r\n 76 -- REF_AlwaysOn_2V048"); - cmdLine.serial().printf( - "MAX5715_REF(REF_AlwaysOn_2V048)"); - g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V048); - return true; // command was handled by MAX5715 - } - break; - case '7': - { - // cmdLine.serial().printf("\r\n 77 -- REF_AlwaysOn_4V096"); - cmdLine.serial().printf( - "MAX5715_REF(REF_AlwaysOn_4V096)"); - g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_4V096); - return true; // command was handled by MAX5715 - } - break; - } - } - break; - case '8': - { - // recommended for hex command codes 80..8F - switch (cmdLine[1]) - { - case '0': - { - // TODO: cmdLine.serial().printf("\r\n 80 code=? -- CODEall"); - // TODO: parse command arguments ~ parse_strCommandArgs(strCommandArgs); - g_MAX5715_device.channels_bitmask_DCBA = 0xFF; // store g_MAX5715_device.CODE[allChannels] - uint16_t code = g_MAX5715_device.CODE[0]; - if (cmdLine.parse_uint16_dec("code", code)) - { - } - cmdLine.serial().printf("CODEall code=%d", code); - g_MAX5715_device.CODEall(code); - return true; // command was handled by MAX5715 - } - break; - case '1': - { - // TODO: cmdLine.serial().printf("\r\n 81 -- LOADall"); - cmdLine.serial().printf("LOADall"); - g_MAX5715_device.LOADall(); - return true; // command was handled by MAX5715 - } - break; - case '2': - { - // TODO: cmdLine.serial().printf("\r\n 82 code=? -- CODEallLOADall"); - uint16_t code = g_MAX5715_device.CODE[0]; - if (cmdLine.parse_uint16_dec("code", code)) - { - } - cmdLine.serial().printf("CODEallLOADall code=%d", code); - g_MAX5715_device.CODEallLOADall(code); - return true; // command was handled by MAX5715 - } - break; - } - } - break; - case '9': - { - // recommended for hex command codes 90..9F - } - break; - case 'a': case 'A': - { - // recommended for hex command codes A0..AF - switch (cmdLine[1]) - { - case 't': case 'T': -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL - // AT command: skip the prompt to avoid confusing modem detector - return false; // command not handled -#endif // IGNORE_AT_COMMANDS - } - } - break; - case 'b': case 'B': - { - // recommended for hex command codes B0..BF - } - break; - case 'c': case 'C': - { - // recommended for hex command codes C0..CF - // // MAX5717 menu function to drive MAX5717_CLRb_Pin CLR# - // cmdLine.serial().printf("\r\n C -- CLR# pulse CH high CL low"); - switch (cmdLine[1]) - { - default: - // g_MAX5715_device.CLRboutputPulseLow(); - g_MAX5715_device.CLRboutputValue(1); - g_MAX5715_device.CLRboutputValue(0); - g_MAX5715_device.CLRboutputValue(1); - break; - case 'H': case 'h': case '1': - g_MAX5715_device.CLRboutputValue(1); // GPIOoutputCLRb(int isLogicHigh); - break; - case 'L': case 'l': case '0': - g_MAX5715_device.CLRboutputValue(0); // GPIOoutputCLRb(int isLogicHigh); - break; - } - return true; // command was handled by MAX5715 - } - break; - case 'd': case 'D': - { - // recommended for hex command codes D0..DF - } - break; - case 'e': case 'E': - { - // recommended for hex command codes E0..EF - } - break; - case 'f': case 'F': - { - // recommended for hex command codes F0..FF - } - break; - case 'l': case 'L': - { - // // MAX5717 menu function to drive MAX5717_LDACb_Pin LDAC# - // cmdLine.serial().printf("\r\n L -- LDAC# pulse LH high LL low"); - switch (cmdLine[1]) - { - default: - // g_MAX5715_device.LDACboutputPulseLow(); - g_MAX5715_device.LDACboutputValue(1); - g_MAX5715_device.LDACboutputValue(0); - g_MAX5715_device.LDACboutputValue(1); - break; - case 'H': case 'h': case '1': - g_MAX5715_device.LDACboutputValue(1); // GPIOoutputLDACb(int isLogicHigh); - break; - case 'L': case 'l': case '0': - g_MAX5715_device.LDACboutputValue(0); // GPIOoutputLDACb(int isLogicHigh); - break; - } - return true; // command was handled by MAX5715 - } - break; - case 'x': case 'X': - { - } - break; - case 'y': case 'Y': - { - } - break; - case 'z': case 'Z': - { - } - break; - case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command - { - // TODO: '~' is not recommended for menu commands, interferes with ssh - switch (cmdLine[1]) - { - default: - { -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", - cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - } - } - } - break; - case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command - { -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - } - break; - case '@': - { - // // - // // Menu @ -- print device configuration - // TODO: cmdLine.serial().printf("\r\n @ -- print MAX5715 configuration"); - // // - // print shadow register configuration - // - // shadow of write-only register CODE dddd_dddd_dddd_0000 - //~ int16_t CMD_1000_CODE; - int index = 0; - for (index = 0; index < 4; index++) - { - cmdLine.serial().printf("CODE %c=0x%4.4x MAX5715_VoltageOfCode(%d)=%5.3fV\r\n", - (char)('A' + index), - (g_MAX5715_device.Shadow_0010_nnnn_CODE[index] & 0xFFFF), - g_MAX5715_device.CODE[index], - g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[index]) - ); - } - // - cmdLine.serial().printf("\r\n"); - // - // - // Menu @) print MAX5715 configuration AND g_MAX5715_device globals - // -#if 1 // SUPPORT_CHANNELS - cmdLine.serial().printf("channelNumber_0_3=%d channels_bitmask_DCBA=%d\r\n", - (g_MAX5715_device.channelNumber_0_3 & 0xFFFF), - (g_MAX5715_device.channels_bitmask_DCBA & 0xFFFF)); -#endif // SUPPORT_CHANNELS - // - cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX5715_device.VRef); - // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB - return true; // command was handled by MAX5715 - } - break; - } // end switch (cmdLine[0]) - return false; // command not handled by MAX5715 -} // end bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine) -#endif - -//-------------------------------------------------- -#if 0 // APPLICATION_MAX11131 // MAX11131_menu_onEOLcommandParser moved to Test_Menu_MAX11131.cpp -bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine) -{ - switch (cmdLine[0]) - { - case '0': - { - // recommended for hex command codes 00..0F - // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void); - // TODO: cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead"); - if (cmdLine.parse_uint16_dec("n", g_MAX11131_device.NumWords)) - { - } - cmdLine.serial().printf("ScanRead NumWords=%d", g_MAX11131_device.NumWords); - if (g_MAX11131_device.isExternalClock) - { - cmdLine.serial().printf(" External Clock"); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); - } - else - { - cmdLine.serial().printf(" Internal Clock"); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); - } - return true; // command was handled by MAX11131 - } - break; - case '1': - { - // recommended for hex command codes 10..1F - // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); - // TODO: cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual"); - if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) - { - } - if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) - { - } - if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) - { - } - cmdLine.serial().printf("ScanManual ch=%d pm=%d id=%d\r\n", - g_MAX11131_device.channelNumber_0_15, - g_MAX11131_device.PowerManagement_0_2, - g_MAX11131_device.chan_id_0_1); - // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 - // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 - // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 - g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual(); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); - return true; // command was handled by MAX11131 - } - break; - case '2': - { - // recommended for hex command codes 20..2F - // 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); - // TODO: cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat"); - // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs - // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.nscan_4_8_12_16 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs - // VERIFY: parse strCommandArgs for additional arguments including key=value pairs - if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) - { - } - if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) - { - } - if (cmdLine.parse_byte_dec("n", g_MAX11131_device.nscan_4_8_12_16)) - { - } - if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) - { - } - if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) - { - } - cmdLine.serial().printf( - "ScanRepeat ch=%d average_0_4_8_16_32:%d nscan_4_8_12_16:%d swcnv=%d pm=%d\r\n", - g_MAX11131_device.channelNumber_0_15, - g_MAX11131_device.average_0_4_8_16_32, - g_MAX11131_device.nscan_4_8_12_16, - g_MAX11131_device.swcnv_0_1, - g_MAX11131_device.PowerManagement_0_2); - // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 - // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 - // VERIFY: replace argument with driver global; g_MAX11131_device.nscan_4_8_12_16 replaces nscan_4_8_12_16 - // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32 - // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 - g_MAX11131_device.NumWords = g_MAX11131_device.ScanRepeat(); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_chanID_mean(cmdLine, g_MAX11131_device.NumWords); - return true; // command was handled by MAX11131 - } - break; - case '3': - { - // recommended for hex command codes 30..3F - // 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); - // TODO: cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock"); - // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs - // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs - if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) - { - } - if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) - { - } - if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) - { - } - if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) - { - } - cmdLine.serial().printf("ScanStandardInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n", - g_MAX11131_device.channelNumber_0_15, - g_MAX11131_device.average_0_4_8_16_32, - g_MAX11131_device.swcnv_0_1, - g_MAX11131_device.PowerManagement_0_2 - ); - // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 - // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 - // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32 - // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 - g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardInternalClock(); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); - return true; // command was handled by MAX11131 - } - break; - case '4': - { - // recommended for hex command codes 40..4F - // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); - // TODO: cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock"); - // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs - // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs - if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) - { - } - if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) - { - } - if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) - { - } - cmdLine.serial().printf("ScanStandardExternalClock ch=%d pm=%d id=%d\r\n", - g_MAX11131_device.channelNumber_0_15, - g_MAX11131_device.PowerManagement_0_2, - g_MAX11131_device.chan_id_0_1 - ); - // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 - // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 - // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 - g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock(); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); - return true; // command was handled by MAX11131 - } - break; - case '5': - { - // recommended for hex command codes 50..5F - // 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); - // TODO: cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock"); - // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs - // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs - if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) - { - } - if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) - { - } - if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) - { - } - if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) - { - } - cmdLine.serial().printf("ScanUpperInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n", - g_MAX11131_device.channelNumber_0_15, - g_MAX11131_device.average_0_4_8_16_32, - g_MAX11131_device.swcnv_0_1, - g_MAX11131_device.PowerManagement_0_2 - ); - // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 - // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 - // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32 - // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 - g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperInternalClock(); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); - return true; // command was handled by MAX11131 - } - break; - case '6': - { - // recommended for hex command codes 60..6F - // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1); - // TODO: cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock"); - // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs - // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs - if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15)) - { - } - if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) - { - } - if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) - { - } - cmdLine.serial().printf("ScanUpperExternalClock ch=%d pm=%d id=%d\r\n", - g_MAX11131_device.channelNumber_0_15, - g_MAX11131_device.PowerManagement_0_2, - g_MAX11131_device.chan_id_0_1 - ); - // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 - // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 - // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15 - g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperExternalClock(); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); - return true; // command was handled by MAX11131 - } - break; - case '7': - { - // recommended for hex command codes 70..7F - // 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); - // TODO: cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock"); - // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs - // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs - if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask)) - { - // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs - } - if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32)) - { - } - if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) - { - } - if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1)) - { - } - cmdLine.serial().printf( - "ScanCustomInternalClock enabledChannelsMask:0x%4.4x average_0_4_8_16_32:%d pm=%d swcnv=%d\r\n", - (g_MAX11131_device.enabledChannelsMask & 0xFFFF), - g_MAX11131_device.average_0_4_8_16_32, - g_MAX11131_device.PowerManagement_0_2, - g_MAX11131_device.swcnv_0_1 - ); - // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 - // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1 - // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32 - // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask - g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomInternalClock(); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords); - return true; // command was handled by MAX11131 - } - break; - case '8': - { - // recommended for hex command codes 80..8F - // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1); - // TODO: cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock"); - if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask)) - { - // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs - } - if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2)) - { - } - if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1)) - { - } - cmdLine.serial().printf("ScanCustomExternalClock enabledChannelsMask:0x%4.4x pm=%d id=%d\r\n", - (g_MAX11131_device.enabledChannelsMask & 0xFFFF), - g_MAX11131_device.PowerManagement_0_2, - g_MAX11131_device.chan_id_0_1 - ); - // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 - // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 - // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask - g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomExternalClock(); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); - return true; // command was handled by MAX11131 - } - break; - case '9': - { - // recommended for hex command codes 90..9F - // VERIFY: console menu command 9 MAX11131_ScanSampleSetExternalClock(uint8_t enabledChannelsPatternLength_1_256, int16_t enabledChannelsPattern[], int PowerManagement_0_2, int chan_id_0_1); - // TODO: cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock"); - // - // get MAX11131 Sampleset channel selection pattern parse_strCommandArgs(strCommandArgs); - // cmdLine.parse_byteCount_byteList_dec(byteCount, mosiData, MAX_SPI_BYTE_COUNT) - // into g_MAX11131_device.enabledChannelsPatternLength_1_256 - // into g_MAX11131_device.enabledChannelsPattern[0..255] - size_t numValues; - char valueList[256]; - if (cmdLine.parse_byteCount_byteList_dec( numValues, valueList, 256)) - { - // first value is the "9" command itself - g_MAX11131_device.enabledChannelsPatternLength_1_256 = numValues - 1; - // copy valueList[1, ...] into g_MAX11131_device.enabledChannelsPattern[0, ...] - for (size_t index = 0; index < (numValues - 1); index++) - { - g_MAX11131_device.enabledChannelsPattern[index] = valueList[1 + index]; - } - } - // - cmdLine.serial().printf("ScanSampleSetExternalClock enabledChannelsPattern:{ "); - int index; - for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++) - { - //~ Serial.print( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC); - //~ Serial.print(" "); - cmdLine.serial().printf("AIN%d ", ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F)); - } - cmdLine.serial().printf("}"); - cmdLine.serial().printf(" pm=%d id=%d\r\n", g_MAX11131_device.PowerManagement_0_2, - g_MAX11131_device.chan_id_0_1); - // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2 - // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1 - g_MAX11131_device.NumWords = g_MAX11131_device.ScanSampleSetExternalClock(); - // - // Read raw ADC codes from device into AINcode[] and RAW_misoData16[] - // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords - g_MAX11131_device.ReadAINcode(); - // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data - // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs - // - AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords); - return true; // command was handled by MAX11131 - } - break; - case 'a': case 'A': - { - // recommended for hex command codes A0..AF - switch (cmdLine[1]) - { - case 't': case 'T': -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL - // AT command: skip the prompt to avoid confusing modem detector - return false; // command not handled -#endif // IGNORE_AT_COMMANDS - } - } - break; - case 'b': case 'B': - { - // recommended for hex command codes B0..BF - } - break; - case 'c': case 'C': - { - // recommended for hex command codes C0..CF - } - break; - case 'd': case 'D': - { - // recommended for hex command codes D0..DF - } - break; - case 'e': case 'E': - { - // recommended for hex command codes E0..EF - } - break; - case 'f': case 'F': - { - // recommended for hex command codes F0..FF - } - break; - case 'x': case 'X': - { - } - break; - case 'y': case 'Y': - { - } - break; - case 'i': case 'I': - { - // TODO: cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range"); - char strChannelId[3]; - strChannelId[0] = cmdLine[2]; - strChannelId[1] = cmdLine[3]; - strChannelId[2] = '\0'; - int channelId_0_15 = strtoul(strChannelId, NULL, 10); // strtol(str, NULL, 10): get decimal value - switch (cmdLine[1]) - { - case 's': case 'S': - g_MAX11131_device.Reconfigure_SingleEnded(channelId_0_15); - break; - case 'u': case 'U': - g_MAX11131_device.Reconfigure_DifferentialUnipolar(channelId_0_15); - break; - case 'b': case 'B': - g_MAX11131_device.Reconfigure_DifferentialBipolarFSVref(channelId_0_15); - break; - case 'r': case 'R': - g_MAX11131_device.Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15); - break; - } - // char cmd1 = strCommandArgs[0]; - // strCommandArgs.remove(0, 1); // unsigned int index, unsigned int count - // // get argument int channelId_0_15 - // // parse_strCommandArgs(strCommandArgs); - // int channelId_0_15 = strtoul(strCommandArgs.c_str(), NULL, 10); // strtol(str, NULL, 10): get decimal value - // if (cmd1 == 'S') { - // MAX11131_Reconfigure_SingleEnded(channelId_0_15); - // } - // else if (cmd1 == 'U') { - // MAX11131_Reconfigure_DifferentialUnipolar(channelId_0_15); - // } - // else if (cmd1 == 'B') { - // MAX11131_Reconfigure_DifferentialBipolarFSVref(channelId_0_15); - // } - // else if (cmd1 == 'R') { - // MAX11131_Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15); - // } - return true; // command was handled by MAX11131 - } - break; - case '@': - { - // TODO: cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration"); - // print shadow register configuration - // - cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_MODE_CONTROL & 0xFFFF)); - MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_MODE_CONTROL); - cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_CONFIGURATION & 0xFFFF)); - MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_CONFIGURATION); - cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.UNIPOLAR & 0xFFFF)); - MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.UNIPOLAR); - cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.BIPOLAR & 0xFFFF)); - MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.BIPOLAR); - cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.RANGE & 0xFFFF)); - MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.RANGE); - cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN0 & 0xFFFF)); - MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN0); - cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN1 & 0xFFFF)); - MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN1); - cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.SAMPLESET & 0xFFFF)); - MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.SAMPLESET); - // - // VERIFY: print shadow SAMPLESET pattern entry - int entryIndex; - for (entryIndex = 0; entryIndex < g_MAX11131_device.enabledChannelsPatternLength_1_256; - entryIndex += 4) - { - uint16_t pack4channels = 0; - pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 0]) & 0x0F) << 12); - if ((entryIndex + 1) < g_MAX11131_device.enabledChannelsPatternLength_1_256) { - pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 1]) & 0x0F) << 8); - } - if ((entryIndex + 2) < g_MAX11131_device.enabledChannelsPatternLength_1_256) { - pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 2]) & 0x0F) << 4); - } - if ((entryIndex + 3) < g_MAX11131_device.enabledChannelsPatternLength_1_256) { - pack4channels |= ((g_MAX11131_device.enabledChannelsPattern[entryIndex + 3]) & 0x0F); - } - //~ SPIwrite16bits(pack4channels); - cmdLine.serial().printf(" 0x%4.4x", (pack4channels & 0xFFFF)); - // decode SAMPLESET channel select pattern - cmdLine.serial().printf(" SampleSet Entry: AIN%d AIN%d AIN%d AIN%d\r\n", - ((pack4channels >> 12) & 0x000F), - ((pack4channels >> 8) & 0x000F), - ((pack4channels >> 4) & 0x000F), - ((pack4channels ) & 0x000F) - ); - } - //cmdLine.serial().printf(" SAMPLESET enabledChannelsPattern:{ "); - //int index; - //for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++) - //{ - // //~ cmdLine.serial().printf( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC); - // //~ cmdLine.serial().printf(" "); - // cmdLine.serial().printf("AIN"); - // cmdLine.serial().printf( ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F), DEC); - // cmdLine.serial().printf(" "); - //} - //cmdLine.serial().printf("}"); - // - // Menu @) print MAX11131 configuration AND g_MAX11131_device globals - // - cmdLine.serial().printf("SPI_MOSI_Semantic=%d\r\n", (g_MAX11131_device.SPI_MOSI_Semantic & 0xFFFF)); - cmdLine.serial().printf("NumWords=%d\r\n", (g_MAX11131_device.NumWords & 0xFFFF)); - cmdLine.serial().printf("isExternalClock=%d\r\n", (g_MAX11131_device.isExternalClock & 0xFFFF)); - cmdLine.serial().printf("ScanMode=%d\r\n", (g_MAX11131_device.ScanMode & 0xFFFF)); - cmdLine.serial().printf("channelNumber_0_15=%d\r\n", - (g_MAX11131_device.channelNumber_0_15 & 0xFFFF)); - cmdLine.serial().printf("PowerManagement_0_2=%d\r\n", - (g_MAX11131_device.PowerManagement_0_2 & 0xFFFF)); - cmdLine.serial().printf("chan_id_0_1=%d\r\n", (g_MAX11131_device.chan_id_0_1 & 0xFFFF)); - cmdLine.serial().printf("average_0_4_8_16_32=%d\r\n", - (g_MAX11131_device.average_0_4_8_16_32 & 0xFFFF)); - cmdLine.serial().printf("nscan_4_8_12_16=%d\r\n", (g_MAX11131_device.nscan_4_8_12_16 & 0xFFFF)); - cmdLine.serial().printf("swcnv_0_1=%d\r\n", (g_MAX11131_device.swcnv_0_1 & 0xFFFF)); - cmdLine.serial().printf("enabledChannelsMask=0x%4.4x\r\n", - (g_MAX11131_device.enabledChannelsMask & 0xFFFF)); - // - cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX11131_device.VRef); - // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB - // - return true; // command was handled by MAX11131 - } - //case '&': - //{ - // // TODO: cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual"); - //} - break; - case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command - { - // TODO: '~' is not recommended for menu commands, interferes with ssh -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - } - break; - case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command - { -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - } - break; - } // end switch (cmdLine[0]) - return false; // command not handled -} // end bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine) -#endif - -//-------------------------------------------------- -#if 0 // APPLICATION_MAX5171 // MAX5171_menu_onEOLcommandParser moved to Test_Menu_MAX5171.cpp -bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine) -{ - switch (cmdLine[0]) - { - case '0': - { - // recommended for hex command codes 10..1F - //~ cmdLine.serial().printf("\r\n 0 code=? -- CODE"); - uint16_t code; - if (cmdLine.parse_uint16_dec("code", code)) - { - } - cmdLine.serial().printf("CODE code=%d", code); - g_MAX5171_device.CODE(code); - return true; // command was handled by MAX5171 - } - break; - case '4': - { - // recommended for hex command codes 10..1F - //~ cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD"); - uint16_t code; - if (cmdLine.parse_uint16_dec("code", code)) - { - } - cmdLine.serial().printf("CODE_LOAD code=%d", code); - g_MAX5171_device.CODE_LOAD(code); - return true; // command was handled by MAX5171 - } - break; - case '8': - { - // recommended for hex command codes 10..1F - //~ cmdLine.serial().printf("\r\n 8 -- LOAD"); - cmdLine.serial().printf("LOAD"); - g_MAX5171_device.LOAD(); - return true; // command was handled by MAX5171 - } - break; - case 'c': case 'C': - { - // recommended for hex command codes 10..1F - //~ cmdLine.serial().printf("\r\n c -- NOP"); - cmdLine.serial().printf("NOP"); - g_MAX5171_device.NOP(); - return true; // command was handled by MAX5171 - } - break; - case 'd': case 'D': - { - // recommended for hex command codes 10..1F - //~ cmdLine.serial().printf("\r\n d -- SHUTDOWN"); - cmdLine.serial().printf("SHUTDOWN"); - g_MAX5171_device.SHUTDOWN(); - return true; // command was handled by MAX5171 - } - break; - case 'e': case 'E': - { - switch (cmdLine[1]) - { - case '0': - { - // recommended for hex command codes 10..1F - //~ cmdLine.serial().printf("\r\n e0 -- UPO_LOW"); - cmdLine.serial().printf("UPO_LOW"); - g_MAX5171_device.UPO_LOW(); - return true; // command was handled by MAX5171 - } - break; - case '8': - { - // recommended for hex command codes 10..1F - //~ cmdLine.serial().printf("\r\n e8 -- UPO_HIGH"); - cmdLine.serial().printf("UPO_HIGH"); - g_MAX5171_device.UPO_HIGH(); - return true; // command was handled by MAX5171 - } - break; - } - } - break; - case 'f': case 'F': - { - switch (cmdLine[1]) - { - case '0': - { - // recommended for hex command codes 10..1F - //~ cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE"); - cmdLine.serial().printf("MODE1_DOUT_SCLK_RISING_EDGE"); - g_MAX5171_device.MODE1_DOUT_SCLK_RISING_EDGE(); - return true; // command was handled by MAX5171 - } - break; - case '8': - { - // recommended for hex command codes 10..1F - //~ cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE"); - cmdLine.serial().printf("MODE0_DOUT_SCLK_FALLING_EDGE"); - g_MAX5171_device.MODE0_DOUT_SCLK_FALLING_EDGE(); - return true; // command was handled by MAX5171 - } - break; - } - } - break; - case 'a': case 'A': - { - // recommended for hex command codes A0..AF - switch (cmdLine[1]) - { - case 't': case 'T': -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL - // AT command: skip the prompt to avoid confusing modem detector - return; -#endif // IGNORE_AT_COMMANDS - } - } - break; - case 'x': case 'X': - { - } - break; - case 'y': case 'Y': - { - } - break; - case 'z': case 'Z': - { - } - break; - case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command - { - // TODO: '~' is not recommended for menu commands, interferes with ssh -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - } - break; - case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command - { -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - } - break; - } // end switch (cmdLine[0]) - return false; // command not handled -} // end bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine) -#endif - -//-------------------------------------------------- -#if 0 // APPLICATION_MAX11410 // MAX11410_menu_onEOLcommandParser moved to Test_Menu_MAX11410.cpp -bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine) -{ - switch (cmdLine[0]) - { - // TODO1: MAX11410 main_menu_onEOLcommandParser - case '0': - { - // recommended for hex command codes 00..0F - // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); - uint16_t ch = g_MAX5715_device.channelNumber_0_3; - uint16_t code; - if (cmdLine.parse_uint16_dec("ch", ch)) - { - } - if (cmdLine.parse_uint16_dec("code", code)) - { - } - if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG)) - { - isUpdatedSPIConfig = true; - } - cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); - MAX5715_CODEnLOADn(ch, code); - cmdLine.serial().printf("\r\n placeholder"); - return true; // command was handled by MAX11410 - } - break; - case '1': - { - // recommended for hex command codes 10..1F - } - break; - case '2': - { - // recommended for hex command codes 20..2F - } - break; - case '3': - { - // recommended for hex command codes 30..3F - } - break; - case '4': - { - // recommended for hex command codes 40..4F - } - break; - case '5': - { - // recommended for hex command codes 50..5F - } - break; - case '6': - { - // recommended for hex command codes 60..6F - } - break; - case '7': - { - // recommended for hex command codes 70..7F - } - break; - case '8': - { - // recommended for hex command codes 80..8F - } - break; - case '9': - { - // recommended for hex command codes 90..9F - } - break; - case 'a': case 'A': - { - // recommended for hex command codes A0..AF - switch (cmdLine[1]) - { - case 't': case 'T': -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL - // AT command: skip the prompt to avoid confusing modem detector - return; -#endif // IGNORE_AT_COMMANDS - } - } - break; - case 'b': case 'B': - { - // recommended for hex command codes B0..BF - } - break; - case 'c': case 'C': - { - // recommended for hex command codes C0..CF - } - break; - case 'd': case 'D': - { - // recommended for hex command codes D0..DF - } - break; - case 'e': case 'E': - { - // recommended for hex command codes E0..EF - } - break; - case 'f': case 'F': - { - // recommended for hex command codes F0..FF - } - break; - case 'x': case 'X': - { - } - break; - case 'y': case 'Y': - { - } - break; - case 'z': case 'Z': - { - } - break; - case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command - { - // TODO: '~' is not recommended for menu commands, interferes with ssh -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - } - break; - case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command - { -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - } - break; - } // end switch (cmdLine[0]) - return false; // command not handled -} // end bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine) -#endif - - -//-------------------------------------------------- -#if APPLICATION_MAX12345 // MAX12345_menu_onEOLcommandParser see Test_Menu_MAX12345.cpp -bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine) -{ - switch (cmdLine[0]) - { - // TODO1: MAX12345 main_menu_onEOLcommandParser - case '0': - { - // recommended for hex command codes 00..0F - // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); - uint16_t ch = g_MAX5715_device.channelNumber_0_3; - uint16_t code; - if (cmdLine.parse_uint16_dec("ch", ch)) - { - } - if (cmdLine.parse_uint16_dec("code", code)) - { - } - if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG)) - { - isUpdatedSPIConfig = true; - } - cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); - MAX5715_CODEnLOADn(ch, code); - cmdLine.serial().printf("\r\n placeholder"); - return true; // command was handled by MAX12345 - } - break; - case '1': - { - // recommended for hex command codes 10..1F - } - break; - case '2': - { - // recommended for hex command codes 20..2F - } - break; - case '3': - { - // recommended for hex command codes 30..3F - } - break; - case '4': - { - // recommended for hex command codes 40..4F - } - break; - case '5': - { - // recommended for hex command codes 50..5F - } - break; - case '6': - { - // recommended for hex command codes 60..6F - } - break; - case '7': - { - // recommended for hex command codes 70..7F - } - break; - case '8': - { - // recommended for hex command codes 80..8F - } - break; - case '9': - { - // recommended for hex command codes 90..9F - } - break; - case 'a': case 'A': - { - // recommended for hex command codes A0..AF - switch (cmdLine[1]) - { - case 't': case 'T': -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL - // AT command: skip the prompt to avoid confusing modem detector - return; -#endif // IGNORE_AT_COMMANDS - } - } - break; - case 'b': case 'B': - { - // recommended for hex command codes B0..BF - } - break; - case 'c': case 'C': - { - // recommended for hex command codes C0..CF - } - break; - case 'd': case 'D': - { - // recommended for hex command codes D0..DF - } - break; - case 'e': case 'E': - { - // recommended for hex command codes E0..EF - } - break; - case 'f': case 'F': - { - // recommended for hex command codes F0..FF - } - break; - case 'x': case 'X': - { - } - break; - case 'y': case 'Y': - { - } - break; - case 'z': case 'Z': - { - } - break; - case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command - { - // TODO: '~' is not recommended for menu commands, interferes with ssh -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - } - break; - case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command - { -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - } - break; - } // end switch (cmdLine[0]) - return false; // command not handled -} // end bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine) -#endif - -//-------------------------------------------------- -#if MAX11410_ONSPIPRINT -// Optional Diagnostic function to print SPI transactions -void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]) -{ - cmdLine_serial.serial().printf("\r\nSPI MOSI->"); - for (uint8_t index = 0; index < byteCount; index++) { - cmdLine_serial.serial().printf(" 0x%2.2X", mosiData[index]); - } - cmdLine_serial.serial().printf(" MISO<-"); - for (uint8_t index = 0; index < byteCount; index++) { - cmdLine_serial.serial().printf(" 0x%2.2X", misoData[index]); - } - cmdLine_serial.serial().printf(" "); -} -#endif // MAX11410_ONSPIPRINT - -//-------------------------------------------------- -// main menu command-line parser -// invoked by CmdLine::append(char ch) or CmdLine::idleAppendIfReadable() -void main_menu_onEOLcommandParser(CmdLine & cmdLine) -{ - // DIAGNOSTIC: print line buffer - //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str()); - // - switch (cmdLine[0]) - { - case '?': - main_menu_status(cmdLine); - main_menu_help(cmdLine); - // print command prompt - //cmdLine.serial().printf("\r\n>"); - break; - case '\r': case '\n': // ignore blank line - case '\0': // ignore empty line - case '#': // ignore comment line - // # -- lines beginning with # are comments - main_menu_status(cmdLine); - //~ main_menu_help(cmdLine); - // print command prompt - //cmdLine.serial().printf("\r\n>"); - break; -#if ECHO_EOF_ON_EOL - case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file - cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting - diagnostic_led_EOF(); - break; - case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file - cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting - diagnostic_led_EOF(); - break; -#endif -#if APPLICATION_ArduinoPinsMonitor - case '.': - { - // . -- SelfTest - cmdLine.serial().printf("SelfTest()"); - SelfTest(cmdLine); - } - break; - case '%': - { - pinsMonitor_submenu_onEOLcommandParser(cmdLine); - } - break; // case '%' -#endif // APPLICATION_ArduinoPinsMonitor - // - // Application-specific commands here - // alphanumeric command codes A-Z,a-z,0-9 reserved for application use - // -#if APPLICATION_ArduinoPinsMonitor -#endif // APPLICATION_ArduinoPinsMonitor - - // - // TODO1: add new commands here - // - default: -#if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt - extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp - if (!MAX5715_menu_onEOLcommandParser(cmdLine)) -#elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt - extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp - if (!MAX11131_menu_onEOLcommandParser(cmdLine)) -#elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt - extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp - if (!MAX5171_menu_onEOLcommandParser(cmdLine)) -#elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt - extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp - if (!MAX11410_menu_onEOLcommandParser(cmdLine)) -#elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt - extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp - if (!MAX12345_menu_onEOLcommandParser(cmdLine)) -#else - if (0) // not_handled_by_device_submenu -#endif - { - cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str()); -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", - cmdLine.str()[0], cmdLine.str()); -# endif // HAS_DAPLINK_SERIAL - } - } // switch (cmdLine[0]) -// -// print command prompt -#if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt - cmdLine.serial().printf("\r\nMAX5715 > "); -#elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt - cmdLine.serial().printf("\r\nMAX11131 > "); -#elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt - cmdLine.serial().printf("\r\nMAX5171 > "); -#elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt - cmdLine.serial().printf("\r\nMAX11410 > "); -#elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt - cmdLine.serial().printf("\r\nMAX12345 > "); -#else - cmdLine.serial().printf("\r\n> "); -#endif -} // end void main_menu_onEOLcommandParser(CmdLine & cmdLine) - -//-------------------------------------------------- -void InitializeConfiguration() -{ - -#if APPLICATION_MAX5715 // InitializeConfiguration -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\nMAX5715_Init()"); -# endif - cmdLine_serial.serial().printf("\r\nMAX5715_Init()"); - int initResult = g_MAX5715_device.Init(); // defined in #include MAX5715.h -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\nMAX5715_Init() returned %d\r\n", initResult); -# endif - cmdLine_serial.serial().printf("\r\nMAX5715_Init() returned %d\r\n", initResult); -#endif // APPLICATION_MAX5715 - -#if APPLICATION_MAX11131 // InitializeConfiguration -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\nMAX11131_Init()"); -# endif - cmdLine_serial.serial().printf("\r\nMAX11131_Init()"); - g_MAX11131_device.Init(); // defined in #include MAX11131.h -#endif // APPLICATION_MAX11131 - -#if APPLICATION_MAX5171 // InitializeConfiguration -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\nMAX5171_Init()"); -# endif - cmdLine_serial.serial().printf("\r\nMAX5171_Init()"); - int initResult = g_MAX5171_device.Init(); // defined in #include MAX5171.h -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\nMAX5171_Init() returned %d\r\n", initResult); -# endif - cmdLine_serial.serial().printf("\r\nMAX5171_Init() returned %d\r\n", initResult); -#endif // APPLICATION_MAX5171 - -#if APPLICATION_MAX11410 // InitializeConfiguration -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\nMAX11410_Init()"); -# endif - cmdLine_serial.serial().printf("\r\nMAX11410_Init()"); - int initResult = g_MAX11410_device.Init(); // defined in #include MAX11410.h -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\nMAX11410_Init() returned %d\r\n", initResult); -# endif - cmdLine_serial.serial().printf("\r\nMAX11410_Init() returned %d\r\n", initResult); -# if MAX11410_ONSPIPRINT - // Optional Diagnostic function to print SPI transactions - g_MAX11410_device.onSPIprint = onSPIprint_handler; -# endif -#endif // APPLICATION_MAX11410 - -#if APPLICATION_MAX12345 // InitializeConfiguration -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\nMAX12345_Init()"); -# endif - cmdLine_serial.serial().printf("\r\nMAX12345_Init()"); - int initResult = g_MAX12345_device.Init(); // defined in #include MAX12345.h -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("\r\nMAX12345_Init() returned %d\r\n", initResult); -# endif - cmdLine_serial.serial().printf("\r\nMAX12345_Init() returned %d\r\n", initResult); -#endif // APPLICATION_MAX12345 - -} - -//-------------------------------------------------- -// diagnostic rbg led GREEN -void diagnostic_led_EOF() -{ -#if USE_LEDS - led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW - // 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] - ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); - led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN - ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); - led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW - ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); - led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN - ThisThread::sleep_for(250); // [since mbed-os-5.10] vs Thread::wait(250); -#endif // USE_LEDS -} - -//-------------------------------------------------- -// Support commands that get handled immediately w/o waiting for EOL -// handled as immediate command, do not append to buffer -void on_immediate_0x21() // Unicode (U+0021) ! EXCLAMATION MARK -{ -#if USE_LEDS - led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE -#endif // USE_LEDS - InitializeConfiguration(); - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); -} - -//-------------------------------------------------- -// Support commands that get handled immediately w/o waiting for EOL -// handled as immediate command, do not append to buffer -void on_immediate_0x7b() // Unicode (U+007B) { LEFT CURLY BRACKET -{ -#if HAS_BUTTON2_DEMO_INTERRUPT - onButton2FallingEdge(); -#endif -} - -//-------------------------------------------------- -// Support commands that get handled immediately w/o waiting for EOL -// handled as immediate command, do not append to buffer -void on_immediate_0x7d() // Unicode (U+007D) } RIGHT CURLY BRACKET -{ -#if HAS_BUTTON1_DEMO_INTERRUPT - onButton1FallingEdge(); -#endif -} - -//-------------------------------------------------- -// based on example code: https://os.mbed.com/docs/v5.7/reference/pwmout.html -int main() -{ - // Configure serial ports -#if defined(TARGET_MAX32630) - // Note: DAPLINKserial interferes with the timer tick interrupt. Try faster baud rate? - DAPLINKserial.baud(115200); // default 9600 baud - //serial.baud(9600); // class USBSerial has no baud function -# if HAS_DAPLINK_SERIAL - DAPLINKserial.printf("\r\n\r\nDAPLINK_SERIAL: main() startup\r\n"); -# endif -//-------------------------------------------------- -#elif defined(TARGET_MAX32625MBED) - // MAX32625MBED crash if DAPLINKserial.baud(anything other than 9600 baud) - // xxx DAPLINKserial.baud(115200); // default 9600 baud - //serial.baud(9600); // class USBSerial has no baud function -# if HAS_DAPLINK_SERIAL - DAPLINKserial.printf("\r\n\r\nDAPLINK_SERIAL: main() startup\r\n"); -# endif -//-------------------------------------------------- -#elif defined(TARGET_LPC1768) - serial.baud(115200); // default 9600 baud -#else - // unknown target -#endif - cmdLine_serial.clear(); - //~ cmdLine_serial.serial().printf("\r\n cmdLine_serial.serial().printf test\r\n"); - cmdLine_serial.onEOLcommandParser = main_menu_onEOLcommandParser; - cmdLine_serial.diagnostic_led_EOF = diagnostic_led_EOF; - /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21); - cmdLine_serial.on_immediate_0x21 = on_immediate_0x21; - cmdLine_serial.on_immediate_0x7b = on_immediate_0x7b; - cmdLine_serial.on_immediate_0x7d = on_immediate_0x7d; -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.clear(); - //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n"); - cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser; - /// @todo CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21); - cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21; - cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b; - cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d; -# endif - - - print_banner(); - -//#ifdef SCOPE_TRIG_PIN -// scopePinP12 = 0; -// scopePinP12 = 1; -//#endif // SCOPE_TRIG_PIN - -#if HAS_BUTTON1_DEMO_INTERRUPT -# if HAS_BUTTON1_DEMO_INTERRUPT_POLLING -# else - button1.fall(&onButton1FallingEdge); -# endif -#endif // HAS_BUTTON1_DEMO_INTERRUPT -#if HAS_BUTTON2_DEMO_INTERRUPT -# if HAS_BUTTON1_DEMO_INTERRUPT_POLLING -# else - button2.fall(&onButton2FallingEdge); -# endif -#endif // HAS_BUTTON2_DEMO_INTERRUPT - -#if defined(TARGET_MAX32630) - // Timer tick needs to be the highest priority (priority 0, the default). - // DAPLINKserial interferes with the timer tick interrupt. - // Lower the priority of the serial port interrupts to avoid disrupting onTimerTick() handler. - NVIC_SetPriority(UART0_IRQn, 2); // reservedBlueToothSerial(P0_1, P0_0) // 0=highest priority; 1=lower - NVIC_SetPriority(UART1_IRQn, 2); // DAPLINKserial(P2_1, P2_0) // 0=highest priority; 1=lower - NVIC_SetPriority(UART2_IRQn, 2); // reservedSerial(P3_1, P3_0) // 0=highest priority; 1=lower - NVIC_SetPriority(UART3_IRQn, 2); // reservedSerial(P5_4, P5_3) // 0=highest priority; 1=lower - NVIC_SetPriority(GPIO_P0_IRQn, 2); // 0=highest priority; 1=lower - NVIC_SetPriority(GPIO_P1_IRQn, 2); // 0=highest priority; 1=lower - NVIC_SetPriority(GPIO_P2_IRQn, 2); // 0=highest priority; 1=lower - NVIC_SetPriority(GPIO_P3_IRQn, 2); // 0=highest priority; 1=lower - NVIC_SetPriority(GPIO_P4_IRQn, 2); // 0=highest priority; 1=lower - NVIC_SetPriority(GPIO_P5_IRQn, 2); // 0=highest priority; 1=lower - NVIC_SetPriority(GPIO_P6_IRQn, 2); // 0=highest priority; 1=lower - NVIC_SetPriority(GPIO_P7_IRQn, 2); // 0=highest priority; 1=lower - NVIC_SetPriority(GPIO_P8_IRQn, 2); // 0=highest priority; 1=lower - //~ NVIC_SetPriority(RTC0_IRQn, 0); // 0=highest priority; 1=lower - //~ NVIC_SetPriority(RTC3_IRQn, 0); // 0=highest priority; 1=lower - //~ NVIC_SetPriority(US_TIMER_IRQn, 0); // 0=highest priority; 1=lower -#endif - -#if HAS_SPI - // spi init - // mode | POL PHA - // -----+-------- - // 0 | 0 0 - // 1 | 0 1 - // 2 | 1 0 - // 3 | 1 1 - //~ spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default) - //~ spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default) - //~ spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default) - //~ spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default) - // - //~ spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default) - //~ spi.frequency(9600000); // int SCLK_Hz=9600000 = 9.6MHz = 96MHz/10 - //~ spi.frequency(10666666); // int SCLK_Hz=10666666 = 10.6MHz = 96MHz/9 - //~ spi.frequency(12000000); // int SCLK_Hz=12000000 = 12MHz = 96MHz/8 - //~ spi.frequency(13714286); // int SCLK_Hz=13714286 = 13.7MHz = 96MHz/7 - //~ spi.frequency(16000000); // int SCLK_Hz=16000000 = 16MHz = 96MHz/6 - //~ spi.frequency(19200000); // int SCLK_Hz=19200000 = 19.2MHz = 96MHz/5 - //~ spi.frequency(24000000); // int SCLK_Hz=24000000 = 24MHz = 96MHz/4 - //~ spi.frequency(32000000); // int SCLK_Hz=32000000 = 32MHz = 96MHz/3 - //~ spi.frequency(48000000); // int SCLK_Hz=48000000 = 48MHz = 96MHz/2 - // unspecified SPI device - spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default) - spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default) - spi_cs = 1; -#endif - -#if HAS_I2C -// i2c init -// declare in narrower scope: MAX32625MBED I2C i2cMaster(...) -// i2cMaster.frequency(g_I2C_SCL_Hz); -#else - // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 -#if HAS_digitalInOut14 - // DigitalInOut digitalInOut14(P1_6, PIN_INPUT, PullUp, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) - digitalInOut14.input(); -#endif -#if HAS_digitalInOut15 - // DigitalInOut digitalInOut15(P1_7, PIN_INPUT, PullUp, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) - digitalInOut15.input(); -#endif -#if HAS_digitalInOut16 - // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain - // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V - //DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) - digitalInOut16.input(); -#endif -#if HAS_digitalInOut17 - //DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) - digitalInOut17.input(); -#endif -#endif - -#if USE_LEDS -#if defined(TARGET_MAX32630) - led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); -#elif defined(TARGET_MAX32625MBED) - led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); - led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK - ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125); -#else // not defined(TARGET_LPC1768 etc.) - led1 = LED_ON; - led2 = LED_OFF; - led3 = LED_OFF; - led4 = LED_OFF; - ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); - //led1 = LED_ON; - led2 = LED_ON; - ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); - led1 = LED_OFF; - //led2 = LED_ON; - led3 = LED_ON; - ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); - led2 = LED_OFF; - //led3 = LED_ON; - led4 = LED_ON; - ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75); - led3 = LED_OFF; - led4 = LED_ON; - // -#endif // target definition -#endif - - // cmd_TE(); - -#if USE_LEDS - rgb_led.white(); // diagnostic rbg led RED+GREEN+BLUE=WHITE -#endif // USE_LEDS - InitializeConfiguration(); - - while (1) { -#if HAS_BUTTON1_DEMO_INTERRUPT_POLLING - // avoid runtime error on button1 press [mbed-os-5.11] - // instead of using InterruptIn, use DigitalIn and poll in main while(1) -# if HAS_BUTTON1_DEMO_INTERRUPT - static int button1_value_prev = 1; - static int button1_value_now = 1; - button1_value_prev = button1_value_now; - button1_value_now = button1.read(); - if ((button1_value_prev - button1_value_now) == 1) - { - // on button1 falling edge (button1 press) - onButton1FallingEdge(); - } -# endif // HAS_BUTTON1_DEMO_INTERRUPT -# if HAS_BUTTON2_DEMO_INTERRUPT - static int button2_value_prev = 1; - static int button2_value_now = 1; - button2_value_prev = button2_value_now; - button2_value_now = button2.read(); - if ((button2_value_prev - button2_value_now) == 1) - { - // on button2 falling edge (button2 press) - onButton2FallingEdge(); - } -# endif // HAS_BUTTON2_DEMO_INTERRUPT -#endif - # if HAS_DAPLINK_SERIAL - if (DAPLINKserial.readable()) { - cmdLine_DAPLINKserial.append(DAPLINKserial.getc()); - } - # endif // HAS_DAPLINK_SERIAL - if (serial.readable()) { - int c = serial.getc(); - cmdLine_serial.append(c); -#if IGNORE_AT_COMMANDS -# if HAS_DAPLINK_SERIAL - cmdLine_DAPLINKserial.serial().printf("%c", c); -# endif // HAS_DAPLINK_SERIAL -#endif // IGNORE_AT_COMMANDS - // - } - } // while(1) -}