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

Dependencies:   MaximTinyTester CmdLine MAX541 MAX5715 USBDevice

Revision:
3:8913cb4a8b9f
Parent:
2:b3a8a0ca0a94
Child:
5:82037e281451
--- a/main.cpp	Mon Jun 10 15:33:06 2019 +0000
+++ b/main.cpp	Mon Jun 10 16:20:43 2019 +0000
@@ -2023,7 +2023,7 @@
     }
     if (BCHn)
     {
-        cmdLine.serial().printf(" xb=%d", g_MAX11131_device.TwosComplementValue(value_u12));
+        cmdLine.serial().printf(" xb=%ld", g_MAX11131_device.TwosComplementValue(value_u12));
     }
     else
     {
@@ -3939,6 +3939,8 @@
 }
 //--------------------------------------------------
 #if APPLICATION_MAX11131
+#if USE_MAXIMTINYTESTER
+#else // USE_MAXIMTINYTESTER
 bool SelfTest_MAX11131_EOC_expect(CmdLine & cmdLine, int expect_EOC_value, const char *expect_description)
 {
     int actual_EOC_value = -1;
@@ -3958,6 +3960,7 @@
     cmdLine.serial().printf(", missing CNVST or EOC connections?");
     return false;
 }
+#endif // USE_MAXIMTINYTESTER
 #endif
 //--------------------------------------------------
 #if USE_MAXIMTINYTESTER
@@ -4610,6 +4613,14 @@
 #elif APPLICATION_MAX11131
     //
     // MAX11131BOB self-test functions
+#if USE_MAXIMTINYTESTER
+#else // USE_MAXIMTINYTESTER
+#endif // USE_MAXIMTINYTESTER
+//
+#if USE_MAXIMTINYTESTER
+#else // USE_MAXIMTINYTESTER
+#endif // USE_MAXIMTINYTESTER
+//
     //~ SelfTest_FAIL(cmdLine);
     //~ cmdLine.serial().printf("test program not implemented yet");
     int16_t value_u12;
@@ -4655,14 +4666,22 @@
         int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F;
         if (actual_channelId != expect_channelId)
         {
+#if USE_MAXIMTINYTESTER
+            tinyTester.FAIL();
+#else // USE_MAXIMTINYTESTER
             SelfTest_FAIL(cmdLine);
+#endif // USE_MAXIMTINYTESTER
             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
         {
+#if USE_MAXIMTINYTESTER
+            tinyTester.PASS();
+#else // USE_MAXIMTINYTESTER
             SelfTest_PASS(cmdLine);
+#endif // USE_MAXIMTINYTESTER
             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);
         }
@@ -4677,7 +4696,14 @@
     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
+//
+#if USE_MAXIMTINYTESTER
+    // TODO: tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
+    tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "initial value before sending commands");
+#else // USE_MAXIMTINYTESTER
     SelfTest_MAX11131_EOC_expect(cmdLine, 1, "initial value before sending commands"); // TODO1: MAX11131 SelfTest false failure here?
+#endif // USE_MAXIMTINYTESTER
+//
     // 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
@@ -4705,23 +4731,41 @@
         //~ wait_ms(100); // delay
         //~ g_MAX11131_device.CNVSToutputValue(1);
         // g_MAX11131_device.EOCinputWaitUntilLow(); // infinite wait hazard, need to fail if timeout exceeded
+#if USE_MAXIMTINYTESTER
+        // TODO: tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
+        tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 0, "after CNVST pulse");
+#else // USE_MAXIMTINYTESTER
         SelfTest_MAX11131_EOC_expect(cmdLine, 0, "after CNVST pulse");
+#endif // USE_MAXIMTINYTESTER
         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
+#if USE_MAXIMTINYTESTER
+        // TODO: tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
+        tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "after SPI read");
+#else // USE_MAXIMTINYTESTER
         SelfTest_MAX11131_EOC_expect(cmdLine, 1, "after SPI read");
+#endif // USE_MAXIMTINYTESTER
         int expect_channelId = channelIndex;
         int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F;
         if (actual_channelId != expect_channelId)
         {
+#if USE_MAXIMTINYTESTER
+            tinyTester.FAIL();
+#else // USE_MAXIMTINYTESTER
             SelfTest_FAIL(cmdLine);
+#endif // USE_MAXIMTINYTESTER
             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
         {
+#if USE_MAXIMTINYTESTER
+            tinyTester.PASS();
+#else // USE_MAXIMTINYTESTER
             SelfTest_PASS(cmdLine);
+#endif // USE_MAXIMTINYTESTER
             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);
         }
@@ -4828,7 +4872,17 @@
         channelId = 0;
         value_u12 = g_MAX11131_device.AINcode[channelId];
         voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
+//
+#if USE_MAXIMTINYTESTER
+        // TODO: tinyTester.Wait_Output_Settling replaces wait_ms
+        tinyTester.Wait_Output_Settling();
+        // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
+        tinyTester.err_threshold = 0.100;
+        tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
+#else // USE_MAXIMTINYTESTER
         SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, voltageV, 0.100);
+#endif // USE_MAXIMTINYTESTER
+//
     }
     //
     if (SelfTest_has_max541) {
@@ -4859,7 +4913,17 @@
     channelId = 0;
     value_u12 = g_MAX11131_device.AINcode[channelId];
     voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
+//
+#if USE_MAXIMTINYTESTER
+    // TODO: tinyTester.Wait_Output_Settling replaces wait_ms
+    tinyTester.Wait_Output_Settling();
+    // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
+    tinyTester.err_threshold = 0.100;
+    tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
+#else // USE_MAXIMTINYTESTER
     SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, voltageV, 0.100);
+#endif // USE_MAXIMTINYTESTER
+//
     //
     cmdLine.serial().printf("\r\n");
     cmdLine.serial().printf("\r\n      3.4: Test SCAN_0100_StandardExternalClock");
@@ -4901,7 +4965,15 @@
     channelId = 0;
     value_u12 = g_MAX11131_device.AINcode[channelId];
     voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
+#if USE_MAXIMTINYTESTER
+    // TODO: tinyTester.Wait_Output_Settling replaces wait_ms
+    tinyTester.Wait_Output_Settling();
+    // TODO: tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
+    tinyTester.err_threshold = 0.100;
+    tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
+#else // USE_MAXIMTINYTESTER
     SelfTest_AnalogInput_Expect_ch_V(cmdLine, 4, voltageV, 0.100);
+#endif // USE_MAXIMTINYTESTER
     // TODO: compare MAX32625MBED.AIN5 = MAX11131.AIN1
     //channelId = 1;
     //value_u12 = g_MAX11131_device.AINcode[channelId];