Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Tests.cpp
00001 #include "Helper.h" 00002 #include "Objects.h" 00003 #include "Tests.h" 00004 00005 00006 //// /////////////////////////////////////////////////////// 00007 //// Measure the voltages and Idut 00008 //// should see 0.757 (2.5v) and (0.5) 1.65v 00009 //// Expect Idut to be below 180mA 00010 //// expect to read below 0.11 across a 2R shunt. 00011 //// /////////////////////////////////////////////////////// 00012 00013 int VCTest (void) { 00014 00015 int result=0; 00016 00017 float tmp_v3v3=0.0; 00018 float tmp_v5v0=0.0; 00019 float duti = 0.0; 00020 00021 00022 for (int i=0; i<100 ; i++){ 00023 tmp_v5v0 = (tmp_v5v0 + v5v0)/2.0; 00024 tmp_v3v3 = (tmp_v3v3 + v3v3)/2.0; 00025 duti = (duti + idut*0.33)/2.0; // this give the number in mA 00026 wait(0.001); 00027 } 00028 00029 00030 pc.printf("idut = %fmA\n",(duti*1000.0)); 00031 pc.printf("v3v3 = %f\n",tmp_v3v3); 00032 pc.printf("v5v0 = %f\n",tmp_v5v0); 00033 00034 00035 // Test the current 00036 // somewhere between 90mA and 200mA 00037 if ((duti < 0.09) || (duti > 0.2)) { 00038 //result |= 0x1; 00039 00040 } 00041 00042 00043 // Test the 3v3 rail 00044 // give a 10% leaway for tolerance and instrumentation error 00045 if ((tmp_v3v3 < 0.45) || (tmp_v3v3 > 0.575)) { 00046 result |= 0x1; 00047 } 00048 00049 // Test the 5v0 rail 00050 // give a 10% leaway for tolerance and instrumentation error 00051 if ((tmp_v5v0 < 0.68) || (tmp_v5v0 > 0.835)) { 00052 result |= 0x1; 00053 } 00054 00055 return(result); 00056 00057 } 00058 00059 00060 00061 //// /////////////////////////////////////////////////////// 00062 //// 00063 //// /////////////////////////////////////////////////////// 00064 00065 int DutSetupTest (void) { 00066 00067 int result=0; 00068 00069 DutBufferFlush(); 00070 00071 Dut.printf("S2"); 00072 00073 led2 = 1; 00074 00075 // wait here until 00076 while (!Dut.readable()) { 00077 led1 = !led1; 00078 wait (0.05); 00079 } 00080 00081 00082 char tmp = Dut.getc(); 00083 00084 if ( tmp != 'P' ) { 00085 result |= DUTSETUPTEST_FAILED; 00086 } 00087 00088 return(result); 00089 } 00090 00091 00092 00093 //// /////////////////////////////////////////////////////// 00094 //// 00095 //// /////////////////////////////////////////////////////// 00096 00097 int IOTest (void) { 00098 00099 int result=0; 00100 00101 DutBufferFlush(); 00102 Dut.printf("S3"); 00103 00104 // wait here until 00105 while (!Dut.readable()) {} 00106 char tmp = Dut.getc(); 00107 00108 if ( tmp != 'P' ) { 00109 result |= IOTEST_FAILED; 00110 } 00111 00112 return(result); 00113 } 00114 00115 //// /////////////////////////////////////////////////////// 00116 //// 00117 //// /////////////////////////////////////////////////////// 00118 00119 int ResetTest (void) { 00120 00121 int result=0; 00122 00123 DutBufferFlush(); 00124 00125 // this should hang the target in a while(1) loop 00126 Dut.printf("S4"); 00127 00128 // reset the target 00129 DUT_NR = 0; 00130 wait(0.1); 00131 DUT_NR = 1; 00132 00133 00134 // Expect to hear that character back 00135 00136 // wait here until 00137 while (!Dut.readable()) {} 00138 char tmp = Dut.getc(); 00139 00140 if ( tmp != 'R' ) { 00141 result |= RESETTEST_FAILED; 00142 } 00143 00144 return(result); 00145 00146 } 00147 00148 //// /////////////////////////////////////////////////////// 00149 //// 00150 //// /////////////////////////////////////////////////////// 00151 00152 int BatteryTest (void) { 00153 int result=0; 00154 00155 // Run the test on the dut. This should ensure the RTC has a sensible value. 00156 // after the power down 00157 00158 DutBufferFlush(); 00159 Dut.printf("S5"); 00160 00161 // wait here until 00162 while (!Dut.readable()) {} 00163 char tmp = Dut.getc(); 00164 00165 if ( tmp != 'P' ) { 00166 result |= BATTERYTEST_FAILED; 00167 } 00168 00169 return(0); 00170 } 00171 00172 00173 //// /////////////////////////////////////////////////////// 00174 //// 00175 //// /////////////////////////////////////////////////////// 00176 00177 int RTCTest (void) { 00178 int result=0; 00179 00180 // Run the test on the dut. This should ensure the RTC has a sensible value. 00181 // after the power down 00182 DutBufferFlush(); 00183 Dut.printf("S5"); 00184 00185 // wait here until 00186 while (!Dut.readable()) {} 00187 char tmp = Dut.getc(); 00188 00189 if ( tmp != 'P' ) { 00190 result |= RTCTEST_FAILED; 00191 } 00192 00193 return(result); 00194 } 00195 00196 00197 00198 00199 //// /////////////////////////////////////////////////////// 00200 //// 00201 //// /////////////////////////////////////////////////////// 00202 00203 int EthernetTest (void) { 00204 int result=0; 00205 00206 DutBufferFlush(); 00207 Dut.printf("S6"); 00208 00209 // wait here until 00210 while (!Dut.readable()) {} 00211 char tmp = Dut.getc(); 00212 00213 if ( tmp != 'P' ) { 00214 result |= ETHERNETTEST_FAILED; 00215 } 00216 00217 return(result); 00218 } 00219 00220 00221 00222 00223 //// /////////////////////////////////////////////////////// 00224 //// 00225 //// /////////////////////////////////////////////////////// 00226 00227 int CleanUp (void) { 00228 int result=0; 00229 00230 DutBufferFlush(); 00231 Dut.printf("S7"); 00232 00233 // wait here until 00234 while (!Dut.readable()) {led3 = !led3; wait (0.1);} 00235 char tmp = Dut.getc(); 00236 00237 if ( tmp != 'P' ) { 00238 result |= CLEANUP_FAILED; 00239 } 00240 00241 return(result); 00242 } 00243
Generated on Mon Jul 18 2022 16:16:11 by
1.7.2