minimalist hardware testing support
Dependents: MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester MAX11410BOB_Tester ... more
MaximTinyTester.h@12:55db0f4a417d, 2020-04-13 (annotated)
- Committer:
- whismanoid
- Date:
- Mon Apr 13 02:53:26 2020 +0000
- Revision:
- 12:55db0f4a417d
- Parent:
- 10:b11ab5d7ac58
- Child:
- 14:10219b869ac3
use return type and arg type signatures in names e.g. FunctionCall_su_d_lu_Expect
Who changed what in which revision?
User | Revision | Line number | New 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 | 12:55db0f4a417d | 135 | bool FunctionCall_f_lu_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 5:67a1cd5a67cc | 136 | Callback<double(uint32_t)> functionUnderTest, |
whismanoid | 8:9171f0ab3c17 | 137 | uint32_t arg_1_u32, |
whismanoid | 8:9171f0ab3c17 | 138 | double expect_result); |
whismanoid | 5:67a1cd5a67cc | 139 | |
whismanoid | 12:55db0f4a417d | 140 | bool FunctionCall_f_f_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 5:67a1cd5a67cc | 141 | Callback<double(double)> functionUnderTest, |
whismanoid | 8:9171f0ab3c17 | 142 | double arg_1_d, |
whismanoid | 8:9171f0ab3c17 | 143 | double expect_result); |
whismanoid | 8:9171f0ab3c17 | 144 | |
whismanoid | 12:55db0f4a417d | 145 | bool FunctionCall_su_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 8:9171f0ab3c17 | 146 | Callback<uint8_t()> functionUnderTest, |
whismanoid | 8:9171f0ab3c17 | 147 | uint8_t expect_result); |
whismanoid | 5:67a1cd5a67cc | 148 | |
whismanoid | 12:55db0f4a417d | 149 | bool FunctionCall_su_su_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 12:55db0f4a417d | 150 | Callback<uint8_t(uint8_t)> functionUnderTest, |
whismanoid | 12:55db0f4a417d | 151 | uint8_t arg_1, |
whismanoid | 12:55db0f4a417d | 152 | uint8_t expect_result); |
whismanoid | 12:55db0f4a417d | 153 | |
whismanoid | 12:55db0f4a417d | 154 | bool FunctionCall_su_d_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 10:b11ab5d7ac58 | 155 | Callback<uint8_t(int)> functionUnderTest, |
whismanoid | 10:b11ab5d7ac58 | 156 | int arg_1, |
whismanoid | 7:5b40b6370f8a | 157 | uint8_t expect_result); |
whismanoid | 7:5b40b6370f8a | 158 | |
whismanoid | 12:55db0f4a417d | 159 | bool FunctionCall_su_su_su_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 12:55db0f4a417d | 160 | Callback<uint8_t(uint8_t, uint8_t)> functionUnderTest, |
whismanoid | 12:55db0f4a417d | 161 | uint8_t arg_1, |
whismanoid | 12:55db0f4a417d | 162 | uint8_t arg_2, |
whismanoid | 12:55db0f4a417d | 163 | uint8_t expect_result); |
whismanoid | 12:55db0f4a417d | 164 | |
whismanoid | 12:55db0f4a417d | 165 | bool FunctionCall_su_d_d_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 10:b11ab5d7ac58 | 166 | Callback<uint8_t(int, int)> functionUnderTest, |
whismanoid | 10:b11ab5d7ac58 | 167 | int arg_1, |
whismanoid | 10:b11ab5d7ac58 | 168 | int arg_2, |
whismanoid | 7:5b40b6370f8a | 169 | uint8_t expect_result); |
whismanoid | 7:5b40b6370f8a | 170 | |
whismanoid | 12:55db0f4a417d | 171 | bool FunctionCall_su_d_lu_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 12:55db0f4a417d | 172 | Callback<uint8_t(int, uint32_t)> functionUnderTest, |
whismanoid | 12:55db0f4a417d | 173 | int arg_1, |
whismanoid | 12:55db0f4a417d | 174 | uint32_t arg_2, |
whismanoid | 12:55db0f4a417d | 175 | uint8_t expect_result); |
whismanoid | 10:b11ab5d7ac58 | 176 | |
whismanoid | 12:55db0f4a417d | 177 | |
whismanoid | 12:55db0f4a417d | 178 | bool FunctionCall_su_d_plu_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 10:b11ab5d7ac58 | 179 | Callback<uint8_t(int, uint32_t*)> functionUnderTest, |
whismanoid | 10:b11ab5d7ac58 | 180 | int arg_1, |
whismanoid | 10:b11ab5d7ac58 | 181 | uint32_t* arg_2, |
whismanoid | 10:b11ab5d7ac58 | 182 | uint8_t expect_result, |
whismanoid | 10:b11ab5d7ac58 | 183 | uint32_t expect_buffer); |
whismanoid | 10:b11ab5d7ac58 | 184 | |
whismanoid | 12:55db0f4a417d | 185 | bool FunctionCall_su_su_su_su_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 7:5b40b6370f8a | 186 | Callback<uint8_t(uint8_t, uint8_t, uint8_t)> functionUnderTest, |
whismanoid | 7:5b40b6370f8a | 187 | uint8_t arg_1, |
whismanoid | 7:5b40b6370f8a | 188 | uint8_t arg_2, |
whismanoid | 7:5b40b6370f8a | 189 | uint8_t arg_3, |
whismanoid | 7:5b40b6370f8a | 190 | uint8_t expect_result); |
whismanoid | 7:5b40b6370f8a | 191 | |
whismanoid | 12:55db0f4a417d | 192 | bool FunctionCall_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 7:5b40b6370f8a | 193 | Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest, |
whismanoid | 7:5b40b6370f8a | 194 | uint8_t arg_1, |
whismanoid | 7:5b40b6370f8a | 195 | uint8_t arg_2, |
whismanoid | 7:5b40b6370f8a | 196 | uint8_t arg_3, |
whismanoid | 7:5b40b6370f8a | 197 | uint8_t arg_4, |
whismanoid | 7:5b40b6370f8a | 198 | uint8_t expect_result); |
whismanoid | 7:5b40b6370f8a | 199 | |
whismanoid | 12:55db0f4a417d | 200 | bool FunctionCall_su_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 7:5b40b6370f8a | 201 | Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest, |
whismanoid | 7:5b40b6370f8a | 202 | uint8_t arg_1, |
whismanoid | 7:5b40b6370f8a | 203 | uint8_t arg_2, |
whismanoid | 7:5b40b6370f8a | 204 | uint8_t arg_3, |
whismanoid | 7:5b40b6370f8a | 205 | uint8_t arg_4, |
whismanoid | 7:5b40b6370f8a | 206 | uint8_t arg_5, |
whismanoid | 7:5b40b6370f8a | 207 | uint8_t expect_result); |
whismanoid | 7:5b40b6370f8a | 208 | |
whismanoid | 7:5b40b6370f8a | 209 | // TODO1 #167 support callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)> |
whismanoid | 12:55db0f4a417d | 210 | // bool FunctionCall_su_su_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest, |
whismanoid | 7:5b40b6370f8a | 211 | // Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest, |
whismanoid | 7:5b40b6370f8a | 212 | // uint8_t arg_1, |
whismanoid | 7:5b40b6370f8a | 213 | // uint8_t arg_2, |
whismanoid | 7:5b40b6370f8a | 214 | // uint8_t arg_3, |
whismanoid | 7:5b40b6370f8a | 215 | // uint8_t arg_4, |
whismanoid | 7:5b40b6370f8a | 216 | // uint8_t arg_5, |
whismanoid | 7:5b40b6370f8a | 217 | // uint8_t arg_6, |
whismanoid | 7:5b40b6370f8a | 218 | // uint8_t expect_result); |
whismanoid | 7:5b40b6370f8a | 219 | |
whismanoid | 0:93d4119d3f14 | 220 | int input_timeout_time_msec; |
whismanoid | 0:93d4119d3f14 | 221 | |
whismanoid | 0:93d4119d3f14 | 222 | bool AnalogIn0_Read_Expect_voltageV(double expect_result); |
whismanoid | 0:93d4119d3f14 | 223 | bool AnalogIn1_Read_Expect_voltageV(double expect_result); |
whismanoid | 0:93d4119d3f14 | 224 | bool AnalogIn2_Read_Expect_voltageV(double expect_result); |
whismanoid | 0:93d4119d3f14 | 225 | bool AnalogIn3_Read_Expect_voltageV(double expect_result); |
whismanoid | 0:93d4119d3f14 | 226 | bool AnalogIn4_Read_Expect_voltageV(double expect_result); |
whismanoid | 0:93d4119d3f14 | 227 | bool AnalogIn5_Read_Expect_voltageV(double expect_result); |
whismanoid | 0:93d4119d3f14 | 228 | |
whismanoid | 0:93d4119d3f14 | 229 | bool AnalogIn_Read_Expect_voltageV(AnalogIn& analogInPin, double expect_result); |
whismanoid | 0:93d4119d3f14 | 230 | |
whismanoid | 0:93d4119d3f14 | 231 | bool DigitalIn_Read_Expect_WarnOnly(DigitalIn& digitalInPin, const char* pinName, int expect_result, const char *expect_description); |
whismanoid | 0:93d4119d3f14 | 232 | |
whismanoid | 0:93d4119d3f14 | 233 | int settle_time_msec; |
whismanoid | 0:93d4119d3f14 | 234 | |
whismanoid | 0:93d4119d3f14 | 235 | void Wait_Output_Settling(); |
whismanoid | 0:93d4119d3f14 | 236 | |
whismanoid | 0:93d4119d3f14 | 237 | }; |
whismanoid | 0:93d4119d3f14 | 238 | |
whismanoid | 0:93d4119d3f14 | 239 | #endif // __MaximTinyTester_H__ |
whismanoid | 0:93d4119d3f14 | 240 | |
whismanoid | 0:93d4119d3f14 | 241 | // End of file |