minimalist hardware testing support

Dependents:   MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester MAX11410BOB_Tester ... more

Revision:
0:93d4119d3f14
Child:
1:f98ddb04f9e0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MaximTinyTester.h	Mon Jun 10 07:47:42 2019 +0000
@@ -0,0 +1,120 @@
+// /*******************************************************************************
+// * 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.
+// *******************************************************************************
+// */
+// *********************************************************************
+// @file MaximTinyTester.h
+// *********************************************************************
+
+// Prevent multiple declaration
+#ifndef __MaximTinyTester_H__
+#define __MaximTinyTester_H__
+
+#include "mbed.h"
+#include "CmdLine.h"  // https://whismanoid@os.mbed.com/users/whismanoid/code/CmdLine/
+
+/**
+ * @brief MaximTinyTester class supports software and hardware testing
+ *
+ */
+class MaximTinyTester
+{
+protected:
+    CmdLine& associatedCmdLine;
+
+public:
+    MaximTinyTester(CmdLine& AssociatedCmdLine,
+        AnalogIn& analogInPin0,
+        AnalogIn& analogInPin1,
+        AnalogIn& analogInPin2,
+        AnalogIn& analogInPin3,
+        AnalogIn& analogInPin4,
+        AnalogIn& analogInPin5);
+
+    AnalogIn& analogInPin0;
+    AnalogIn& analogInPin1;
+    AnalogIn& analogInPin2;
+    AnalogIn& analogInPin3;
+    AnalogIn& analogInPin4;
+    AnalogIn& analogInPin5;
+    float analogInPin_fullScaleVoltage[6];
+
+    /** err_threshold determines how closely a float or double result must match the expected value
+    */
+    double err_threshold;
+
+    void clear();
+
+    /** serial returns reference to the associated serial port */
+    CmdLine& cmdLine(void) const {
+        return associatedCmdLine;
+    };
+
+    int nPass;
+    int nFail;
+
+    void PASS();
+
+    void FAIL();
+
+    void Report_Summary(void);
+
+    bool FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+        Callback<uint16_t(double)> functionUnderTest,
+        double voltageV, uint16_t expect_result);
+
+    bool FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+        Callback<double(uint16_t)> functionUnderTest,
+        uint16_t value_u16, double expect_result);
+
+    int input_timeout_time_msec;
+
+    bool AnalogIn0_Read_Expect_voltageV(double expect_result);
+    bool AnalogIn1_Read_Expect_voltageV(double expect_result);
+    bool AnalogIn2_Read_Expect_voltageV(double expect_result);
+    bool AnalogIn3_Read_Expect_voltageV(double expect_result);
+    bool AnalogIn4_Read_Expect_voltageV(double expect_result);
+    bool AnalogIn5_Read_Expect_voltageV(double expect_result);
+
+    bool AnalogIn_Read_Expect_voltageV(AnalogIn& analogInPin, double expect_result);
+
+    bool DigitalIn_Read_Expect_WarnOnly(DigitalIn& digitalInPin, const char* pinName, int expect_result, const char *expect_description);
+
+    int settle_time_msec;
+
+    void Wait_Output_Settling();
+
+};
+
+#endif // __MaximTinyTester_H__
+
+// End of file
+