minimalist hardware testing support

Dependents:   MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester MAX11410BOB_Tester ... more

Committer:
whismanoid
Date:
Fri May 15 08:36:01 2020 +0000
Revision:
14:10219b869ac3
Parent:
12:55db0f4a417d
Child:
15:ac3e4930df8b
Support FunctionCall_f_u_Expect

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 0:93d4119d3f14 1 // /*******************************************************************************
whismanoid 0:93d4119d3f14 2 // * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 0:93d4119d3f14 3 // *
whismanoid 0:93d4119d3f14 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 0:93d4119d3f14 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 0:93d4119d3f14 6 // * to deal in the Software without restriction, including without limitation
whismanoid 0:93d4119d3f14 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 0:93d4119d3f14 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 0:93d4119d3f14 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 0:93d4119d3f14 10 // *
whismanoid 0:93d4119d3f14 11 // * The above copyright notice and this permission notice shall be included
whismanoid 0:93d4119d3f14 12 // * in all copies or substantial portions of the Software.
whismanoid 0:93d4119d3f14 13 // *
whismanoid 0:93d4119d3f14 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 0:93d4119d3f14 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 0:93d4119d3f14 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 0:93d4119d3f14 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 0:93d4119d3f14 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 0:93d4119d3f14 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 0:93d4119d3f14 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 0:93d4119d3f14 21 // *
whismanoid 0:93d4119d3f14 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 0:93d4119d3f14 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 0:93d4119d3f14 24 // * Products, Inc. Branding Policy.
whismanoid 0:93d4119d3f14 25 // *
whismanoid 0:93d4119d3f14 26 // * The mere transfer of this software does not imply any licenses
whismanoid 0:93d4119d3f14 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 0:93d4119d3f14 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 0:93d4119d3f14 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 0:93d4119d3f14 30 // * ownership rights.
whismanoid 0:93d4119d3f14 31 // *******************************************************************************
whismanoid 0:93d4119d3f14 32 // */
whismanoid 0:93d4119d3f14 33 // *********************************************************************
whismanoid 0:93d4119d3f14 34 // @file MaximTinyTester.h
whismanoid 0:93d4119d3f14 35 // *********************************************************************
whismanoid 0:93d4119d3f14 36
whismanoid 0:93d4119d3f14 37 // Prevent multiple declaration
whismanoid 0:93d4119d3f14 38 #ifndef __MaximTinyTester_H__
whismanoid 0:93d4119d3f14 39 #define __MaximTinyTester_H__
whismanoid 0:93d4119d3f14 40
whismanoid 0:93d4119d3f14 41 #include "mbed.h"
whismanoid 0:93d4119d3f14 42 #include "CmdLine.h" // https://whismanoid@os.mbed.com/users/whismanoid/code/CmdLine/
whismanoid 0:93d4119d3f14 43
whismanoid 0:93d4119d3f14 44 /**
whismanoid 0:93d4119d3f14 45 * @brief MaximTinyTester class supports software and hardware testing
whismanoid 0:93d4119d3f14 46 *
whismanoid 0:93d4119d3f14 47 */
whismanoid 0:93d4119d3f14 48 class MaximTinyTester
whismanoid 0:93d4119d3f14 49 {
whismanoid 0:93d4119d3f14 50 protected:
whismanoid 0:93d4119d3f14 51 CmdLine& associatedCmdLine;
whismanoid 0:93d4119d3f14 52
whismanoid 0:93d4119d3f14 53 public:
whismanoid 3:080aa1bb1bc0 54 /** Constructor for MaximTinyTester class.
whismanoid 3:080aa1bb1bc0 55 *
whismanoid 3:080aa1bb1bc0 56 * @param[in] AssociatedCmdLine = reference to serial CmdLine
whismanoid 3:080aa1bb1bc0 57 * @param[in] analogInPin0 = port for analog input measurement
whismanoid 3:080aa1bb1bc0 58 * @param[in] analogInPin1 = port for analog input measurement
whismanoid 3:080aa1bb1bc0 59 * @param[in] analogInPin2 = port for analog input measurement
whismanoid 3:080aa1bb1bc0 60 * @param[in] analogInPin3 = port for analog input measurement
whismanoid 3:080aa1bb1bc0 61 * @param[in] analogInPin4 = port for analog input measurement
whismanoid 3:080aa1bb1bc0 62 * @param[in] analogInPin5 = port for analog input measurement
whismanoid 3:080aa1bb1bc0 63 * @param[in] m_RFailLED = port for red LED; use NC if not connected
whismanoid 3:080aa1bb1bc0 64 * @param[in] m_GPassLED = port for green LED; use NC if not connected
whismanoid 3:080aa1bb1bc0 65 * @param[in] m_BBusyLED = port for blue LED; use NC if not connected
whismanoid 3:080aa1bb1bc0 66 *
whismanoid 3:080aa1bb1bc0 67 */
whismanoid 0:93d4119d3f14 68 MaximTinyTester(CmdLine& AssociatedCmdLine,
whismanoid 0:93d4119d3f14 69 AnalogIn& analogInPin0,
whismanoid 0:93d4119d3f14 70 AnalogIn& analogInPin1,
whismanoid 0:93d4119d3f14 71 AnalogIn& analogInPin2,
whismanoid 0:93d4119d3f14 72 AnalogIn& analogInPin3,
whismanoid 0:93d4119d3f14 73 AnalogIn& analogInPin4,
whismanoid 1:f98ddb04f9e0 74 AnalogIn& analogInPin5,
whismanoid 1:f98ddb04f9e0 75 DigitalOut& m_RFailLED,
whismanoid 1:f98ddb04f9e0 76 DigitalOut& m_GPassLED,
whismanoid 1:f98ddb04f9e0 77 DigitalOut& m_BBusyLED);
whismanoid 0:93d4119d3f14 78
whismanoid 0:93d4119d3f14 79 AnalogIn& analogInPin0;
whismanoid 0:93d4119d3f14 80 AnalogIn& analogInPin1;
whismanoid 0:93d4119d3f14 81 AnalogIn& analogInPin2;
whismanoid 0:93d4119d3f14 82 AnalogIn& analogInPin3;
whismanoid 0:93d4119d3f14 83 AnalogIn& analogInPin4;
whismanoid 0:93d4119d3f14 84 AnalogIn& analogInPin5;
whismanoid 0:93d4119d3f14 85 float analogInPin_fullScaleVoltage[6];
whismanoid 0:93d4119d3f14 86
whismanoid 1:f98ddb04f9e0 87 // MaximTinyTester add LED indicators m_RFailLED, m_GPassLED, m_BBusyLED
whismanoid 1:f98ddb04f9e0 88 DigitalOut& m_RFailLED;
whismanoid 1:f98ddb04f9e0 89 DigitalOut& m_GPassLED;
whismanoid 1:f98ddb04f9e0 90 DigitalOut& m_BBusyLED;
whismanoid 1:f98ddb04f9e0 91 int blink_time_msec;
whismanoid 1:f98ddb04f9e0 92
whismanoid 0:93d4119d3f14 93 /** err_threshold determines how closely a float or double result must match the expected value
whismanoid 0:93d4119d3f14 94 */
whismanoid 0:93d4119d3f14 95 double err_threshold;
whismanoid 0:93d4119d3f14 96
whismanoid 0:93d4119d3f14 97 void clear();
whismanoid 0:93d4119d3f14 98
whismanoid 0:93d4119d3f14 99 /** serial returns reference to the associated serial port */
whismanoid 0:93d4119d3f14 100 CmdLine& cmdLine(void) const {
whismanoid 0:93d4119d3f14 101 return associatedCmdLine;
whismanoid 0:93d4119d3f14 102 };
whismanoid 0:93d4119d3f14 103
whismanoid 0:93d4119d3f14 104 int nPass;
whismanoid 0:93d4119d3f14 105 int nFail;
whismanoid 0:93d4119d3f14 106
whismanoid 0:93d4119d3f14 107 void PASS();
whismanoid 0:93d4119d3f14 108
whismanoid 0:93d4119d3f14 109 void FAIL();
whismanoid 0:93d4119d3f14 110
whismanoid 9:3ec00515891d 111 void print(const char* stringLiteralMessage);
whismanoid 9:3ec00515891d 112
whismanoid 0:93d4119d3f14 113 void Report_Summary(void);
whismanoid 0:93d4119d3f14 114
whismanoid 10:b11ab5d7ac58 115
whismanoid 10:b11ab5d7ac58 116 bool Expect(const char *nameOfTest, int actual_result, int expect_result);
whismanoid 10:b11ab5d7ac58 117 bool Expect(const char *nameOfTest, double actual_result, double expect_result);
whismanoid 10:b11ab5d7ac58 118
whismanoid 12:55db0f4a417d 119 bool FunctionCall_u_f_Expect(const char *nameOfFunctionUnderTest,
whismanoid 0:93d4119d3f14 120 Callback<uint16_t(double)> functionUnderTest,
whismanoid 8:9171f0ab3c17 121 double arg_1_voltageV,
whismanoid 8:9171f0ab3c17 122 uint16_t expect_result);
whismanoid 0:93d4119d3f14 123
whismanoid 12:55db0f4a417d 124 bool FunctionCall_f_d_Expect(const char *nameOfFunctionUnderTest,
whismanoid 10:b11ab5d7ac58 125 Callback<double(int)> functionUnderTest,
whismanoid 10:b11ab5d7ac58 126 int arg_1_u16,
whismanoid 10:b11ab5d7ac58 127 double expect_result);
whismanoid 0:93d4119d3f14 128
whismanoid 12:55db0f4a417d 129 bool FunctionCall_f_d_d_Expect(const char *nameOfFunctionUnderTest,
whismanoid 12:55db0f4a417d 130 Callback<double(int, int)> functionUnderTest,
whismanoid 12:55db0f4a417d 131 int arg_1_int,
whismanoid 12:55db0f4a417d 132 int arg_2_int,
whismanoid 12:55db0f4a417d 133 double expect_result);
whismanoid 12:55db0f4a417d 134
whismanoid 14:10219b869ac3 135 bool FunctionCall_f_u_Expect(const char *nameOfFunctionUnderTest,
whismanoid 14:10219b869ac3 136 Callback<double(uint16_t)> functionUnderTest,
whismanoid 14:10219b869ac3 137 uint16_t arg_1_u16,
whismanoid 14:10219b869ac3 138 double expect_result);
whismanoid 14:10219b869ac3 139
whismanoid 12:55db0f4a417d 140 bool FunctionCall_f_lu_Expect(const char *nameOfFunctionUnderTest,
whismanoid 5:67a1cd5a67cc 141 Callback<double(uint32_t)> functionUnderTest,
whismanoid 8:9171f0ab3c17 142 uint32_t arg_1_u32,
whismanoid 8:9171f0ab3c17 143 double expect_result);
whismanoid 5:67a1cd5a67cc 144
whismanoid 12:55db0f4a417d 145 bool FunctionCall_f_f_Expect(const char *nameOfFunctionUnderTest,
whismanoid 5:67a1cd5a67cc 146 Callback<double(double)> functionUnderTest,
whismanoid 8:9171f0ab3c17 147 double arg_1_d,
whismanoid 8:9171f0ab3c17 148 double expect_result);
whismanoid 8:9171f0ab3c17 149
whismanoid 12:55db0f4a417d 150 bool FunctionCall_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 8:9171f0ab3c17 151 Callback<uint8_t()> functionUnderTest,
whismanoid 8:9171f0ab3c17 152 uint8_t expect_result);
whismanoid 5:67a1cd5a67cc 153
whismanoid 12:55db0f4a417d 154 bool FunctionCall_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 12:55db0f4a417d 155 Callback<uint8_t(uint8_t)> functionUnderTest,
whismanoid 12:55db0f4a417d 156 uint8_t arg_1,
whismanoid 12:55db0f4a417d 157 uint8_t expect_result);
whismanoid 12:55db0f4a417d 158
whismanoid 12:55db0f4a417d 159 bool FunctionCall_su_d_Expect(const char *nameOfFunctionUnderTest,
whismanoid 10:b11ab5d7ac58 160 Callback<uint8_t(int)> functionUnderTest,
whismanoid 10:b11ab5d7ac58 161 int arg_1,
whismanoid 7:5b40b6370f8a 162 uint8_t expect_result);
whismanoid 7:5b40b6370f8a 163
whismanoid 12:55db0f4a417d 164 bool FunctionCall_su_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 12:55db0f4a417d 165 Callback<uint8_t(uint8_t, uint8_t)> functionUnderTest,
whismanoid 12:55db0f4a417d 166 uint8_t arg_1,
whismanoid 12:55db0f4a417d 167 uint8_t arg_2,
whismanoid 12:55db0f4a417d 168 uint8_t expect_result);
whismanoid 12:55db0f4a417d 169
whismanoid 12:55db0f4a417d 170 bool FunctionCall_su_d_d_Expect(const char *nameOfFunctionUnderTest,
whismanoid 10:b11ab5d7ac58 171 Callback<uint8_t(int, int)> functionUnderTest,
whismanoid 10:b11ab5d7ac58 172 int arg_1,
whismanoid 10:b11ab5d7ac58 173 int arg_2,
whismanoid 7:5b40b6370f8a 174 uint8_t expect_result);
whismanoid 7:5b40b6370f8a 175
whismanoid 12:55db0f4a417d 176 bool FunctionCall_su_d_lu_Expect(const char *nameOfFunctionUnderTest,
whismanoid 12:55db0f4a417d 177 Callback<uint8_t(int, uint32_t)> functionUnderTest,
whismanoid 12:55db0f4a417d 178 int arg_1,
whismanoid 12:55db0f4a417d 179 uint32_t arg_2,
whismanoid 12:55db0f4a417d 180 uint8_t expect_result);
whismanoid 10:b11ab5d7ac58 181
whismanoid 12:55db0f4a417d 182
whismanoid 12:55db0f4a417d 183 bool FunctionCall_su_d_plu_Expect(const char *nameOfFunctionUnderTest,
whismanoid 10:b11ab5d7ac58 184 Callback<uint8_t(int, uint32_t*)> functionUnderTest,
whismanoid 10:b11ab5d7ac58 185 int arg_1,
whismanoid 10:b11ab5d7ac58 186 uint32_t* arg_2,
whismanoid 10:b11ab5d7ac58 187 uint8_t expect_result,
whismanoid 10:b11ab5d7ac58 188 uint32_t expect_buffer);
whismanoid 10:b11ab5d7ac58 189
whismanoid 12:55db0f4a417d 190 bool FunctionCall_su_su_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 7:5b40b6370f8a 191 Callback<uint8_t(uint8_t, uint8_t, uint8_t)> functionUnderTest,
whismanoid 7:5b40b6370f8a 192 uint8_t arg_1,
whismanoid 7:5b40b6370f8a 193 uint8_t arg_2,
whismanoid 7:5b40b6370f8a 194 uint8_t arg_3,
whismanoid 7:5b40b6370f8a 195 uint8_t expect_result);
whismanoid 7:5b40b6370f8a 196
whismanoid 12:55db0f4a417d 197 bool FunctionCall_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 7:5b40b6370f8a 198 Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest,
whismanoid 7:5b40b6370f8a 199 uint8_t arg_1,
whismanoid 7:5b40b6370f8a 200 uint8_t arg_2,
whismanoid 7:5b40b6370f8a 201 uint8_t arg_3,
whismanoid 7:5b40b6370f8a 202 uint8_t arg_4,
whismanoid 7:5b40b6370f8a 203 uint8_t expect_result);
whismanoid 7:5b40b6370f8a 204
whismanoid 12:55db0f4a417d 205 bool FunctionCall_su_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 7:5b40b6370f8a 206 Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest,
whismanoid 7:5b40b6370f8a 207 uint8_t arg_1,
whismanoid 7:5b40b6370f8a 208 uint8_t arg_2,
whismanoid 7:5b40b6370f8a 209 uint8_t arg_3,
whismanoid 7:5b40b6370f8a 210 uint8_t arg_4,
whismanoid 7:5b40b6370f8a 211 uint8_t arg_5,
whismanoid 7:5b40b6370f8a 212 uint8_t expect_result);
whismanoid 7:5b40b6370f8a 213
whismanoid 7:5b40b6370f8a 214 // TODO1 #167 support callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)>
whismanoid 12:55db0f4a417d 215 // bool FunctionCall_su_su_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 7:5b40b6370f8a 216 // Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest,
whismanoid 7:5b40b6370f8a 217 // uint8_t arg_1,
whismanoid 7:5b40b6370f8a 218 // uint8_t arg_2,
whismanoid 7:5b40b6370f8a 219 // uint8_t arg_3,
whismanoid 7:5b40b6370f8a 220 // uint8_t arg_4,
whismanoid 7:5b40b6370f8a 221 // uint8_t arg_5,
whismanoid 7:5b40b6370f8a 222 // uint8_t arg_6,
whismanoid 7:5b40b6370f8a 223 // uint8_t expect_result);
whismanoid 7:5b40b6370f8a 224
whismanoid 0:93d4119d3f14 225 int input_timeout_time_msec;
whismanoid 0:93d4119d3f14 226
whismanoid 0:93d4119d3f14 227 bool AnalogIn0_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 228 bool AnalogIn1_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 229 bool AnalogIn2_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 230 bool AnalogIn3_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 231 bool AnalogIn4_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 232 bool AnalogIn5_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 233
whismanoid 0:93d4119d3f14 234 bool AnalogIn_Read_Expect_voltageV(AnalogIn& analogInPin, double expect_result);
whismanoid 0:93d4119d3f14 235
whismanoid 0:93d4119d3f14 236 bool DigitalIn_Read_Expect_WarnOnly(DigitalIn& digitalInPin, const char* pinName, int expect_result, const char *expect_description);
whismanoid 0:93d4119d3f14 237
whismanoid 0:93d4119d3f14 238 int settle_time_msec;
whismanoid 0:93d4119d3f14 239
whismanoid 0:93d4119d3f14 240 void Wait_Output_Settling();
whismanoid 0:93d4119d3f14 241
whismanoid 0:93d4119d3f14 242 };
whismanoid 0:93d4119d3f14 243
whismanoid 0:93d4119d3f14 244 #endif // __MaximTinyTester_H__
whismanoid 0:93d4119d3f14 245
whismanoid 0:93d4119d3f14 246 // End of file