Chris Styles
/
aaaaa_ISPREFLASH
Tests.cpp@0:1e5295127662, 2009-10-23 (annotated)
- Committer:
- chris
- Date:
- Fri Oct 23 14:05:46 2009 +0000
- Revision:
- 0:1e5295127662
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris | 0:1e5295127662 | 1 | #include "Helper.h" |
chris | 0:1e5295127662 | 2 | #include "Objects.h" |
chris | 0:1e5295127662 | 3 | #include "Tests.h" |
chris | 0:1e5295127662 | 4 | |
chris | 0:1e5295127662 | 5 | |
chris | 0:1e5295127662 | 6 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 7 | //// Measure the voltages and Idut |
chris | 0:1e5295127662 | 8 | //// should see 0.757 (2.5v) and (0.5) 1.65v |
chris | 0:1e5295127662 | 9 | //// Expect Idut to be below 180mA |
chris | 0:1e5295127662 | 10 | //// expect to read below 0.11 across a 2R shunt. |
chris | 0:1e5295127662 | 11 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 12 | |
chris | 0:1e5295127662 | 13 | int VCTest (void) { |
chris | 0:1e5295127662 | 14 | |
chris | 0:1e5295127662 | 15 | int result=0; |
chris | 0:1e5295127662 | 16 | |
chris | 0:1e5295127662 | 17 | float tmp_v3v3=0.0; |
chris | 0:1e5295127662 | 18 | float tmp_v5v0=0.0; |
chris | 0:1e5295127662 | 19 | float duti = 0.0; |
chris | 0:1e5295127662 | 20 | |
chris | 0:1e5295127662 | 21 | |
chris | 0:1e5295127662 | 22 | for (int i=0; i<100 ; i++){ |
chris | 0:1e5295127662 | 23 | tmp_v5v0 = (tmp_v5v0 + v5v0)/2.0; |
chris | 0:1e5295127662 | 24 | tmp_v3v3 = (tmp_v3v3 + v3v3)/2.0; |
chris | 0:1e5295127662 | 25 | duti = (duti + idut*0.33)/2.0; // this give the number in mA |
chris | 0:1e5295127662 | 26 | wait(0.001); |
chris | 0:1e5295127662 | 27 | } |
chris | 0:1e5295127662 | 28 | |
chris | 0:1e5295127662 | 29 | |
chris | 0:1e5295127662 | 30 | pc.printf("idut = %fmA\n",(duti*1000.0)); |
chris | 0:1e5295127662 | 31 | pc.printf("v3v3 = %f\n",tmp_v3v3); |
chris | 0:1e5295127662 | 32 | pc.printf("v5v0 = %f\n",tmp_v5v0); |
chris | 0:1e5295127662 | 33 | |
chris | 0:1e5295127662 | 34 | |
chris | 0:1e5295127662 | 35 | // Test the current |
chris | 0:1e5295127662 | 36 | // somewhere between 90mA and 200mA |
chris | 0:1e5295127662 | 37 | if ((duti < 0.09) || (duti > 0.2)) { |
chris | 0:1e5295127662 | 38 | //result |= 0x1; |
chris | 0:1e5295127662 | 39 | |
chris | 0:1e5295127662 | 40 | } |
chris | 0:1e5295127662 | 41 | |
chris | 0:1e5295127662 | 42 | |
chris | 0:1e5295127662 | 43 | // Test the 3v3 rail |
chris | 0:1e5295127662 | 44 | // give a 10% leaway for tolerance and instrumentation error |
chris | 0:1e5295127662 | 45 | if ((tmp_v3v3 < 0.45) || (tmp_v3v3 > 0.575)) { |
chris | 0:1e5295127662 | 46 | result |= 0x1; |
chris | 0:1e5295127662 | 47 | } |
chris | 0:1e5295127662 | 48 | |
chris | 0:1e5295127662 | 49 | // Test the 5v0 rail |
chris | 0:1e5295127662 | 50 | // give a 10% leaway for tolerance and instrumentation error |
chris | 0:1e5295127662 | 51 | if ((tmp_v5v0 < 0.68) || (tmp_v5v0 > 0.835)) { |
chris | 0:1e5295127662 | 52 | result |= 0x1; |
chris | 0:1e5295127662 | 53 | } |
chris | 0:1e5295127662 | 54 | |
chris | 0:1e5295127662 | 55 | return(result); |
chris | 0:1e5295127662 | 56 | |
chris | 0:1e5295127662 | 57 | } |
chris | 0:1e5295127662 | 58 | |
chris | 0:1e5295127662 | 59 | |
chris | 0:1e5295127662 | 60 | |
chris | 0:1e5295127662 | 61 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 62 | //// |
chris | 0:1e5295127662 | 63 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 64 | |
chris | 0:1e5295127662 | 65 | int DutSetupTest (void) { |
chris | 0:1e5295127662 | 66 | |
chris | 0:1e5295127662 | 67 | int result=0; |
chris | 0:1e5295127662 | 68 | |
chris | 0:1e5295127662 | 69 | DutBufferFlush(); |
chris | 0:1e5295127662 | 70 | |
chris | 0:1e5295127662 | 71 | Dut.printf("S2"); |
chris | 0:1e5295127662 | 72 | |
chris | 0:1e5295127662 | 73 | led2 = 1; |
chris | 0:1e5295127662 | 74 | |
chris | 0:1e5295127662 | 75 | // wait here until |
chris | 0:1e5295127662 | 76 | while (!Dut.readable()) { |
chris | 0:1e5295127662 | 77 | led1 = !led1; |
chris | 0:1e5295127662 | 78 | wait (0.05); |
chris | 0:1e5295127662 | 79 | } |
chris | 0:1e5295127662 | 80 | |
chris | 0:1e5295127662 | 81 | |
chris | 0:1e5295127662 | 82 | char tmp = Dut.getc(); |
chris | 0:1e5295127662 | 83 | |
chris | 0:1e5295127662 | 84 | if ( tmp != 'P' ) { |
chris | 0:1e5295127662 | 85 | result |= DUTSETUPTEST_FAILED; |
chris | 0:1e5295127662 | 86 | } |
chris | 0:1e5295127662 | 87 | |
chris | 0:1e5295127662 | 88 | return(result); |
chris | 0:1e5295127662 | 89 | } |
chris | 0:1e5295127662 | 90 | |
chris | 0:1e5295127662 | 91 | |
chris | 0:1e5295127662 | 92 | |
chris | 0:1e5295127662 | 93 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 94 | //// |
chris | 0:1e5295127662 | 95 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 96 | |
chris | 0:1e5295127662 | 97 | int IOTest (void) { |
chris | 0:1e5295127662 | 98 | |
chris | 0:1e5295127662 | 99 | int result=0; |
chris | 0:1e5295127662 | 100 | |
chris | 0:1e5295127662 | 101 | DutBufferFlush(); |
chris | 0:1e5295127662 | 102 | Dut.printf("S3"); |
chris | 0:1e5295127662 | 103 | |
chris | 0:1e5295127662 | 104 | // wait here until |
chris | 0:1e5295127662 | 105 | while (!Dut.readable()) {} |
chris | 0:1e5295127662 | 106 | char tmp = Dut.getc(); |
chris | 0:1e5295127662 | 107 | |
chris | 0:1e5295127662 | 108 | if ( tmp != 'P' ) { |
chris | 0:1e5295127662 | 109 | result |= IOTEST_FAILED; |
chris | 0:1e5295127662 | 110 | } |
chris | 0:1e5295127662 | 111 | |
chris | 0:1e5295127662 | 112 | return(result); |
chris | 0:1e5295127662 | 113 | } |
chris | 0:1e5295127662 | 114 | |
chris | 0:1e5295127662 | 115 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 116 | //// |
chris | 0:1e5295127662 | 117 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 118 | |
chris | 0:1e5295127662 | 119 | int ResetTest (void) { |
chris | 0:1e5295127662 | 120 | |
chris | 0:1e5295127662 | 121 | int result=0; |
chris | 0:1e5295127662 | 122 | |
chris | 0:1e5295127662 | 123 | DutBufferFlush(); |
chris | 0:1e5295127662 | 124 | |
chris | 0:1e5295127662 | 125 | // this should hang the target in a while(1) loop |
chris | 0:1e5295127662 | 126 | Dut.printf("S4"); |
chris | 0:1e5295127662 | 127 | |
chris | 0:1e5295127662 | 128 | // reset the target |
chris | 0:1e5295127662 | 129 | DUT_NR = 0; |
chris | 0:1e5295127662 | 130 | wait(0.1); |
chris | 0:1e5295127662 | 131 | DUT_NR = 1; |
chris | 0:1e5295127662 | 132 | |
chris | 0:1e5295127662 | 133 | |
chris | 0:1e5295127662 | 134 | // Expect to hear that character back |
chris | 0:1e5295127662 | 135 | |
chris | 0:1e5295127662 | 136 | // wait here until |
chris | 0:1e5295127662 | 137 | while (!Dut.readable()) {} |
chris | 0:1e5295127662 | 138 | char tmp = Dut.getc(); |
chris | 0:1e5295127662 | 139 | |
chris | 0:1e5295127662 | 140 | if ( tmp != 'R' ) { |
chris | 0:1e5295127662 | 141 | result |= RESETTEST_FAILED; |
chris | 0:1e5295127662 | 142 | } |
chris | 0:1e5295127662 | 143 | |
chris | 0:1e5295127662 | 144 | return(result); |
chris | 0:1e5295127662 | 145 | |
chris | 0:1e5295127662 | 146 | } |
chris | 0:1e5295127662 | 147 | |
chris | 0:1e5295127662 | 148 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 149 | //// |
chris | 0:1e5295127662 | 150 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 151 | |
chris | 0:1e5295127662 | 152 | int BatteryTest (void) { |
chris | 0:1e5295127662 | 153 | int result=0; |
chris | 0:1e5295127662 | 154 | |
chris | 0:1e5295127662 | 155 | // Run the test on the dut. This should ensure the RTC has a sensible value. |
chris | 0:1e5295127662 | 156 | // after the power down |
chris | 0:1e5295127662 | 157 | |
chris | 0:1e5295127662 | 158 | DutBufferFlush(); |
chris | 0:1e5295127662 | 159 | Dut.printf("S5"); |
chris | 0:1e5295127662 | 160 | |
chris | 0:1e5295127662 | 161 | // wait here until |
chris | 0:1e5295127662 | 162 | while (!Dut.readable()) {} |
chris | 0:1e5295127662 | 163 | char tmp = Dut.getc(); |
chris | 0:1e5295127662 | 164 | |
chris | 0:1e5295127662 | 165 | if ( tmp != 'P' ) { |
chris | 0:1e5295127662 | 166 | result |= BATTERYTEST_FAILED; |
chris | 0:1e5295127662 | 167 | } |
chris | 0:1e5295127662 | 168 | |
chris | 0:1e5295127662 | 169 | return(0); |
chris | 0:1e5295127662 | 170 | } |
chris | 0:1e5295127662 | 171 | |
chris | 0:1e5295127662 | 172 | |
chris | 0:1e5295127662 | 173 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 174 | //// |
chris | 0:1e5295127662 | 175 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 176 | |
chris | 0:1e5295127662 | 177 | int RTCTest (void) { |
chris | 0:1e5295127662 | 178 | int result=0; |
chris | 0:1e5295127662 | 179 | |
chris | 0:1e5295127662 | 180 | // Run the test on the dut. This should ensure the RTC has a sensible value. |
chris | 0:1e5295127662 | 181 | // after the power down |
chris | 0:1e5295127662 | 182 | DutBufferFlush(); |
chris | 0:1e5295127662 | 183 | Dut.printf("S5"); |
chris | 0:1e5295127662 | 184 | |
chris | 0:1e5295127662 | 185 | // wait here until |
chris | 0:1e5295127662 | 186 | while (!Dut.readable()) {} |
chris | 0:1e5295127662 | 187 | char tmp = Dut.getc(); |
chris | 0:1e5295127662 | 188 | |
chris | 0:1e5295127662 | 189 | if ( tmp != 'P' ) { |
chris | 0:1e5295127662 | 190 | result |= RTCTEST_FAILED; |
chris | 0:1e5295127662 | 191 | } |
chris | 0:1e5295127662 | 192 | |
chris | 0:1e5295127662 | 193 | return(result); |
chris | 0:1e5295127662 | 194 | } |
chris | 0:1e5295127662 | 195 | |
chris | 0:1e5295127662 | 196 | |
chris | 0:1e5295127662 | 197 | |
chris | 0:1e5295127662 | 198 | |
chris | 0:1e5295127662 | 199 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 200 | //// |
chris | 0:1e5295127662 | 201 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 202 | |
chris | 0:1e5295127662 | 203 | int EthernetTest (void) { |
chris | 0:1e5295127662 | 204 | int result=0; |
chris | 0:1e5295127662 | 205 | |
chris | 0:1e5295127662 | 206 | DutBufferFlush(); |
chris | 0:1e5295127662 | 207 | Dut.printf("S6"); |
chris | 0:1e5295127662 | 208 | |
chris | 0:1e5295127662 | 209 | // wait here until |
chris | 0:1e5295127662 | 210 | while (!Dut.readable()) {} |
chris | 0:1e5295127662 | 211 | char tmp = Dut.getc(); |
chris | 0:1e5295127662 | 212 | |
chris | 0:1e5295127662 | 213 | if ( tmp != 'P' ) { |
chris | 0:1e5295127662 | 214 | result |= ETHERNETTEST_FAILED; |
chris | 0:1e5295127662 | 215 | } |
chris | 0:1e5295127662 | 216 | |
chris | 0:1e5295127662 | 217 | return(result); |
chris | 0:1e5295127662 | 218 | } |
chris | 0:1e5295127662 | 219 | |
chris | 0:1e5295127662 | 220 | |
chris | 0:1e5295127662 | 221 | |
chris | 0:1e5295127662 | 222 | |
chris | 0:1e5295127662 | 223 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 224 | //// |
chris | 0:1e5295127662 | 225 | //// /////////////////////////////////////////////////////// |
chris | 0:1e5295127662 | 226 | |
chris | 0:1e5295127662 | 227 | int CleanUp (void) { |
chris | 0:1e5295127662 | 228 | int result=0; |
chris | 0:1e5295127662 | 229 | |
chris | 0:1e5295127662 | 230 | DutBufferFlush(); |
chris | 0:1e5295127662 | 231 | Dut.printf("S7"); |
chris | 0:1e5295127662 | 232 | |
chris | 0:1e5295127662 | 233 | // wait here until |
chris | 0:1e5295127662 | 234 | while (!Dut.readable()) {led3 = !led3; wait (0.1);} |
chris | 0:1e5295127662 | 235 | char tmp = Dut.getc(); |
chris | 0:1e5295127662 | 236 | |
chris | 0:1e5295127662 | 237 | if ( tmp != 'P' ) { |
chris | 0:1e5295127662 | 238 | result |= CLEANUP_FAILED; |
chris | 0:1e5295127662 | 239 | } |
chris | 0:1e5295127662 | 240 | |
chris | 0:1e5295127662 | 241 | return(result); |
chris | 0:1e5295127662 | 242 | } |
chris | 0:1e5295127662 | 243 |