minimalist hardware testing support

Dependents:   MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester MAX11410BOB_Tester ... more

MaximTinyTester.h

Committer:
whismanoid
Date:
2019-07-10
Revision:
3:080aa1bb1bc0
Parent:
1:f98ddb04f9e0
Child:
5:67a1cd5a67cc

File content as of revision 3:080aa1bb1bc0:

// /*******************************************************************************
// * 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:
    /** Constructor for MaximTinyTester class.
    *
    * @param[in] AssociatedCmdLine = reference to serial CmdLine
    * @param[in] analogInPin0 = port for analog input measurement
    * @param[in] analogInPin1 = port for analog input measurement
    * @param[in] analogInPin2 = port for analog input measurement
    * @param[in] analogInPin3 = port for analog input measurement
    * @param[in] analogInPin4 = port for analog input measurement
    * @param[in] analogInPin5 = port for analog input measurement
    * @param[in] m_RFailLED = port for red LED; use NC if not connected
    * @param[in] m_GPassLED = port for green LED; use NC if not connected
    * @param[in] m_BBusyLED = port for blue LED; use NC if not connected
    *
    */
    MaximTinyTester(CmdLine& AssociatedCmdLine,
        AnalogIn& analogInPin0,
        AnalogIn& analogInPin1,
        AnalogIn& analogInPin2,
        AnalogIn& analogInPin3,
        AnalogIn& analogInPin4,
        AnalogIn& analogInPin5,
        DigitalOut& m_RFailLED,
        DigitalOut& m_GPassLED,
        DigitalOut& m_BBusyLED);

    AnalogIn& analogInPin0;
    AnalogIn& analogInPin1;
    AnalogIn& analogInPin2;
    AnalogIn& analogInPin3;
    AnalogIn& analogInPin4;
    AnalogIn& analogInPin5;
    float analogInPin_fullScaleVoltage[6];

    // MaximTinyTester add LED indicators m_RFailLED, m_GPassLED, m_BBusyLED
    DigitalOut& m_RFailLED;
    DigitalOut& m_GPassLED;
    DigitalOut& m_BBusyLED;
    int blink_time_msec;

    /** 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