minimalist hardware testing support

Dependents:   MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester MAX11410BOB_Tester ... more

Committer:
whismanoid
Date:
Tue Jun 01 19:43:11 2021 -0700
Revision:
17:65fb4afe4991
Parent:
16:bb4b003a5cd2
Child:
18:9874cd1e6cb0
tinyTester.mask; FunctionCall_md_Expect supports int16_t(f*)(void)

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 17:65fb4afe4991 97 /** mask determines which bits must match the expected value
whismanoid 17:65fb4afe4991 98 */
whismanoid 17:65fb4afe4991 99 int mask;
whismanoid 17:65fb4afe4991 100
whismanoid 0:93d4119d3f14 101 void clear();
whismanoid 0:93d4119d3f14 102
whismanoid 0:93d4119d3f14 103 /** serial returns reference to the associated serial port */
whismanoid 0:93d4119d3f14 104 CmdLine& cmdLine(void) const {
whismanoid 0:93d4119d3f14 105 return associatedCmdLine;
whismanoid 0:93d4119d3f14 106 };
whismanoid 0:93d4119d3f14 107
whismanoid 0:93d4119d3f14 108 int nPass;
whismanoid 0:93d4119d3f14 109 int nFail;
whismanoid 0:93d4119d3f14 110
whismanoid 0:93d4119d3f14 111 void PASS();
whismanoid 0:93d4119d3f14 112
whismanoid 0:93d4119d3f14 113 void FAIL();
whismanoid 0:93d4119d3f14 114
whismanoid 9:3ec00515891d 115 void print(const char* stringLiteralMessage);
whismanoid 9:3ec00515891d 116
whismanoid 0:93d4119d3f14 117 void Report_Summary(void);
whismanoid 0:93d4119d3f14 118
whismanoid 10:b11ab5d7ac58 119
whismanoid 10:b11ab5d7ac58 120 bool Expect(const char *nameOfTest, int actual_result, int expect_result);
whismanoid 10:b11ab5d7ac58 121 bool Expect(const char *nameOfTest, double actual_result, double expect_result);
whismanoid 10:b11ab5d7ac58 122
whismanoid 12:55db0f4a417d 123 bool FunctionCall_u_f_Expect(const char *nameOfFunctionUnderTest,
whismanoid 0:93d4119d3f14 124 Callback<uint16_t(double)> functionUnderTest,
whismanoid 8:9171f0ab3c17 125 double arg_1_voltageV,
whismanoid 8:9171f0ab3c17 126 uint16_t expect_result);
whismanoid 0:93d4119d3f14 127
whismanoid 15:ac3e4930df8b 128 // MaximTinyTester FunctionCall_lu_f_Expect support MAX5719
whismanoid 15:ac3e4930df8b 129 bool FunctionCall_lu_f_Expect(const char *nameOfFunctionUnderTest,
whismanoid 15:ac3e4930df8b 130 Callback<uint32_t(double)> functionUnderTest,
whismanoid 15:ac3e4930df8b 131 double arg_1_voltageV,
whismanoid 15:ac3e4930df8b 132 uint32_t expect_result);
whismanoid 15:ac3e4930df8b 133
whismanoid 12:55db0f4a417d 134 bool FunctionCall_f_d_Expect(const char *nameOfFunctionUnderTest,
whismanoid 10:b11ab5d7ac58 135 Callback<double(int)> functionUnderTest,
whismanoid 10:b11ab5d7ac58 136 int arg_1_u16,
whismanoid 10:b11ab5d7ac58 137 double expect_result);
whismanoid 0:93d4119d3f14 138
whismanoid 12:55db0f4a417d 139 bool FunctionCall_f_d_d_Expect(const char *nameOfFunctionUnderTest,
whismanoid 12:55db0f4a417d 140 Callback<double(int, int)> functionUnderTest,
whismanoid 12:55db0f4a417d 141 int arg_1_int,
whismanoid 12:55db0f4a417d 142 int arg_2_int,
whismanoid 12:55db0f4a417d 143 double expect_result);
whismanoid 12:55db0f4a417d 144
whismanoid 14:10219b869ac3 145 bool FunctionCall_f_u_Expect(const char *nameOfFunctionUnderTest,
whismanoid 14:10219b869ac3 146 Callback<double(uint16_t)> functionUnderTest,
whismanoid 14:10219b869ac3 147 uint16_t arg_1_u16,
whismanoid 14:10219b869ac3 148 double expect_result);
whismanoid 14:10219b869ac3 149
whismanoid 12:55db0f4a417d 150 bool FunctionCall_f_lu_Expect(const char *nameOfFunctionUnderTest,
whismanoid 5:67a1cd5a67cc 151 Callback<double(uint32_t)> functionUnderTest,
whismanoid 8:9171f0ab3c17 152 uint32_t arg_1_u32,
whismanoid 8:9171f0ab3c17 153 double expect_result);
whismanoid 5:67a1cd5a67cc 154
whismanoid 12:55db0f4a417d 155 bool FunctionCall_f_f_Expect(const char *nameOfFunctionUnderTest,
whismanoid 5:67a1cd5a67cc 156 Callback<double(double)> functionUnderTest,
whismanoid 8:9171f0ab3c17 157 double arg_1_d,
whismanoid 8:9171f0ab3c17 158 double expect_result);
whismanoid 8:9171f0ab3c17 159
whismanoid 16:bb4b003a5cd2 160 bool FunctionCall_d_Expect(const char *nameOfFunctionUnderTest,
whismanoid 16:bb4b003a5cd2 161 Callback<int()> functionUnderTest,
whismanoid 16:bb4b003a5cd2 162 int expect_result);
whismanoid 16:bb4b003a5cd2 163
whismanoid 17:65fb4afe4991 164 bool FunctionCall_md_Expect(const char *nameOfFunctionUnderTest,
whismanoid 17:65fb4afe4991 165 Callback<int16_t()> functionUnderTest,
whismanoid 17:65fb4afe4991 166 int16_t expect_result);
whismanoid 17:65fb4afe4991 167
whismanoid 12:55db0f4a417d 168 bool FunctionCall_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 8:9171f0ab3c17 169 Callback<uint8_t()> functionUnderTest,
whismanoid 8:9171f0ab3c17 170 uint8_t expect_result);
whismanoid 5:67a1cd5a67cc 171
whismanoid 12:55db0f4a417d 172 bool FunctionCall_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 12:55db0f4a417d 173 Callback<uint8_t(uint8_t)> functionUnderTest,
whismanoid 12:55db0f4a417d 174 uint8_t arg_1,
whismanoid 12:55db0f4a417d 175 uint8_t expect_result);
whismanoid 12:55db0f4a417d 176
whismanoid 12:55db0f4a417d 177 bool FunctionCall_su_d_Expect(const char *nameOfFunctionUnderTest,
whismanoid 10:b11ab5d7ac58 178 Callback<uint8_t(int)> functionUnderTest,
whismanoid 10:b11ab5d7ac58 179 int arg_1,
whismanoid 7:5b40b6370f8a 180 uint8_t expect_result);
whismanoid 7:5b40b6370f8a 181
whismanoid 12:55db0f4a417d 182 bool FunctionCall_su_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 12:55db0f4a417d 183 Callback<uint8_t(uint8_t, uint8_t)> functionUnderTest,
whismanoid 12:55db0f4a417d 184 uint8_t arg_1,
whismanoid 12:55db0f4a417d 185 uint8_t arg_2,
whismanoid 12:55db0f4a417d 186 uint8_t expect_result);
whismanoid 12:55db0f4a417d 187
whismanoid 12:55db0f4a417d 188 bool FunctionCall_su_d_d_Expect(const char *nameOfFunctionUnderTest,
whismanoid 10:b11ab5d7ac58 189 Callback<uint8_t(int, int)> functionUnderTest,
whismanoid 10:b11ab5d7ac58 190 int arg_1,
whismanoid 10:b11ab5d7ac58 191 int arg_2,
whismanoid 7:5b40b6370f8a 192 uint8_t expect_result);
whismanoid 7:5b40b6370f8a 193
whismanoid 12:55db0f4a417d 194 bool FunctionCall_su_d_lu_Expect(const char *nameOfFunctionUnderTest,
whismanoid 12:55db0f4a417d 195 Callback<uint8_t(int, uint32_t)> functionUnderTest,
whismanoid 12:55db0f4a417d 196 int arg_1,
whismanoid 12:55db0f4a417d 197 uint32_t arg_2,
whismanoid 12:55db0f4a417d 198 uint8_t expect_result);
whismanoid 10:b11ab5d7ac58 199
whismanoid 12:55db0f4a417d 200
whismanoid 12:55db0f4a417d 201 bool FunctionCall_su_d_plu_Expect(const char *nameOfFunctionUnderTest,
whismanoid 10:b11ab5d7ac58 202 Callback<uint8_t(int, uint32_t*)> functionUnderTest,
whismanoid 10:b11ab5d7ac58 203 int arg_1,
whismanoid 10:b11ab5d7ac58 204 uint32_t* arg_2,
whismanoid 10:b11ab5d7ac58 205 uint8_t expect_result,
whismanoid 10:b11ab5d7ac58 206 uint32_t expect_buffer);
whismanoid 10:b11ab5d7ac58 207
whismanoid 12:55db0f4a417d 208 bool FunctionCall_su_su_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 7:5b40b6370f8a 209 Callback<uint8_t(uint8_t, uint8_t, uint8_t)> functionUnderTest,
whismanoid 7:5b40b6370f8a 210 uint8_t arg_1,
whismanoid 7:5b40b6370f8a 211 uint8_t arg_2,
whismanoid 7:5b40b6370f8a 212 uint8_t arg_3,
whismanoid 7:5b40b6370f8a 213 uint8_t expect_result);
whismanoid 7:5b40b6370f8a 214
whismanoid 12:55db0f4a417d 215 bool FunctionCall_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 7:5b40b6370f8a 216 Callback<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 expect_result);
whismanoid 7:5b40b6370f8a 222
whismanoid 12:55db0f4a417d 223 bool FunctionCall_su_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 7:5b40b6370f8a 224 Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest,
whismanoid 7:5b40b6370f8a 225 uint8_t arg_1,
whismanoid 7:5b40b6370f8a 226 uint8_t arg_2,
whismanoid 7:5b40b6370f8a 227 uint8_t arg_3,
whismanoid 7:5b40b6370f8a 228 uint8_t arg_4,
whismanoid 7:5b40b6370f8a 229 uint8_t arg_5,
whismanoid 7:5b40b6370f8a 230 uint8_t expect_result);
whismanoid 7:5b40b6370f8a 231
whismanoid 7:5b40b6370f8a 232 // TODO1 #167 support callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)>
whismanoid 12:55db0f4a417d 233 // bool FunctionCall_su_su_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest,
whismanoid 7:5b40b6370f8a 234 // Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest,
whismanoid 7:5b40b6370f8a 235 // uint8_t arg_1,
whismanoid 7:5b40b6370f8a 236 // uint8_t arg_2,
whismanoid 7:5b40b6370f8a 237 // uint8_t arg_3,
whismanoid 7:5b40b6370f8a 238 // uint8_t arg_4,
whismanoid 7:5b40b6370f8a 239 // uint8_t arg_5,
whismanoid 7:5b40b6370f8a 240 // uint8_t arg_6,
whismanoid 7:5b40b6370f8a 241 // uint8_t expect_result);
whismanoid 7:5b40b6370f8a 242
whismanoid 0:93d4119d3f14 243 int input_timeout_time_msec;
whismanoid 0:93d4119d3f14 244
whismanoid 0:93d4119d3f14 245 bool AnalogIn0_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 246 bool AnalogIn1_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 247 bool AnalogIn2_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 248 bool AnalogIn3_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 249 bool AnalogIn4_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 250 bool AnalogIn5_Read_Expect_voltageV(double expect_result);
whismanoid 0:93d4119d3f14 251
whismanoid 0:93d4119d3f14 252 bool AnalogIn_Read_Expect_voltageV(AnalogIn& analogInPin, double expect_result);
whismanoid 0:93d4119d3f14 253
whismanoid 0:93d4119d3f14 254 bool DigitalIn_Read_Expect_WarnOnly(DigitalIn& digitalInPin, const char* pinName, int expect_result, const char *expect_description);
whismanoid 0:93d4119d3f14 255
whismanoid 0:93d4119d3f14 256 int settle_time_msec;
whismanoid 0:93d4119d3f14 257
whismanoid 0:93d4119d3f14 258 void Wait_Output_Settling();
whismanoid 0:93d4119d3f14 259
whismanoid 0:93d4119d3f14 260 };
whismanoid 0:93d4119d3f14 261
whismanoid 0:93d4119d3f14 262 #endif // __MaximTinyTester_H__
whismanoid 0:93d4119d3f14 263
whismanoid 0:93d4119d3f14 264 // End of file