Last commit 23 Oct 2009
Revision 0:1e5295127662, committed 23 Oct 2009
- Comitter:
- Date:
- Fri Oct 23 14:05:46 2009 +0000
- Commit message:
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Helper.cpp Fri Oct 23 14:05:46 2009 +0000
@@ -0,0 +1,89 @@
+#include "Objects.h"
+#include "Helper.h"
+
+
+int JigData=0x0;
+
+
+#ifdef I2CIO
+
+
+void DutVinPowerUp (void) {
+ JigData |= 0x01;
+ JigIO.write(JigData);
+}
+
+void DutVinPowerDown (void) {
+ JigData &= 0xFE;
+ JigIO.write(JigData);
+}
+
+
+void DutUsbPowerUp (void) {
+ JigData |= 0x02;
+ JigIO.write(JigData);
+}
+
+void DutUsbPowerDown (void) {
+ JigData &= 0xFD;
+ JigIO.write(JigData);
+}
+
+void DutUsbConnect (void) {
+ JigData |= 0x04;
+ JigIO.write(JigData);
+}
+
+void DutUsbDisconnect (void) {
+ JigData |= 0xFB;
+ JigIO.write(JigData);
+}
+
+
+void DutISPConnect (void) {
+ JigData |= 0x08;
+ JigIO.write(JigData);
+}
+
+void DutISPDisconnect (void) {
+ JigData |= 0xF7;
+ JigIO.write(JigData);
+}
+
+
+#else
+
+ void DutUsbPowerUp (void) {VBUSrelay=1;}
+ void DutUsbPowerDown (void) {VBUSrelay=0;}
+ void DutUsbConnect (void) {USBrelay=1;}
+ void DutUsbDisconnect (void) {USBrelay=0;}
+ void DutVinPowerUp (void) {VINrelay=1;}
+ void DutVinPowerDown (void) {VINrelay=0;}
+
+#endif
+
+
+
+
+void DutReset (int value) {DUT_NR = value;}
+void DutVB (int value) {DUT_VB=value;}
+
+
+
+
+
+void Beep (int Hz, float time) {
+ piezo.period(1.0/float(Hz));
+ piezo=0.5;
+ wait(time);
+ piezo=0.0;
+}
+
+
+
+
+
+
+void DutBufferFlush(void) {
+ while(Dut.readable()) {char tmp=Dut.getc();}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Helper.h Fri Oct 23 14:05:46 2009 +0000 @@ -0,0 +1,20 @@ +void DutUsbPowerUp (void); +void DutUsbPowerDown (void); + +void DutUsbConnect (void); +void DutUsbDisconnect (void); + +void DutVinPowerUp (void); +void DutVinPowerDown (void); + +void DutReset (int value); +void DutVB (int value); + +void DutISPConnect (void); +void DutISPDisconnect (void); + +void Beep (int Hz,float time); + +void DutBufferFlush (void); + +extern int JigData;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Objects.cpp Fri Oct 23 14:05:46 2009 +0000 @@ -0,0 +1,38 @@ +#include "Objects.h" + +Serial pc (USBTX,USBRX); +Serial Dut (p13,p14); + +TextLCD_I2C lcd (p9,p10,0x20); +PCF8574 JigIO (p9,p10,0x21); + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +BusOut leds (LED1,LED2, LED3, LED4); + +AnalogIn idut (p18); +AnalogIn v3v3 (p19); +AnalogIn v5v0 (p20); + +DigitalInOut VbatGnd (p26); + +DigitalIn rbtn (p24); +DigitalIn gbtn (p25); +DigitalOut rled (p23); +DigitalOut gled (p22); +PwmOut piezo (p21); + +DigitalOut ISPrelay (p11); +DigitalOut USBrelay (p12); + +DigitalOut VBUSrelay (p15); +DigitalOut VINrelay (p16); + +DigitalOut VBatGnd (p26); + +DigitalOut DUT_VB (p30); +DigitalOut DUT_NR (p29); +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Objects.h Fri Oct 23 14:05:46 2009 +0000 @@ -0,0 +1,41 @@ +#include "mbed.h" +#include "TextLCD_I2C.h" +#include "PCF8574.h" + +extern DigitalOut led1; +extern DigitalOut led2; +extern DigitalOut led3; +extern DigitalOut led4; + +extern BusOut leds; + +extern Serial pc; +extern Serial Dut; + +extern TextLCD_I2C lcd; +extern PCF8574 JigIO; + +extern DigitalOut myled; +extern DigitalIn rbtn; +extern DigitalIn gbtn; +extern DigitalOut rled; +extern DigitalOut gled; +extern PwmOut piezo; + +extern DigitalOut VBatGnd; + +extern AnalogIn idut; +extern AnalogIn v3v3; +extern AnalogIn v5v0; + +extern DigitalOut ISPrelay; +extern DigitalOut USBrelay; +extern DigitalOut VBUSrelay; +extern DigitalOut VINrelay; + +extern DigitalOut Gnd; + +extern DigitalOut DUT_VB; +extern DigitalOut DUT_NR; + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Tests.cpp Fri Oct 23 14:05:46 2009 +0000
@@ -0,0 +1,243 @@
+#include "Helper.h"
+#include "Objects.h"
+#include "Tests.h"
+
+
+//// ///////////////////////////////////////////////////////
+//// Measure the voltages and Idut
+//// should see 0.757 (2.5v) and (0.5) 1.65v
+//// Expect Idut to be below 180mA
+//// expect to read below 0.11 across a 2R shunt.
+//// ///////////////////////////////////////////////////////
+
+int VCTest (void) {
+
+ int result=0;
+
+ float tmp_v3v3=0.0;
+ float tmp_v5v0=0.0;
+ float duti = 0.0;
+
+
+ for (int i=0; i<100 ; i++){
+ tmp_v5v0 = (tmp_v5v0 + v5v0)/2.0;
+ tmp_v3v3 = (tmp_v3v3 + v3v3)/2.0;
+ duti = (duti + idut*0.33)/2.0; // this give the number in mA
+ wait(0.001);
+ }
+
+
+ pc.printf("idut = %fmA\n",(duti*1000.0));
+ pc.printf("v3v3 = %f\n",tmp_v3v3);
+ pc.printf("v5v0 = %f\n",tmp_v5v0);
+
+
+ // Test the current
+ // somewhere between 90mA and 200mA
+ if ((duti < 0.09) || (duti > 0.2)) {
+ //result |= 0x1;
+
+ }
+
+
+ // Test the 3v3 rail
+ // give a 10% leaway for tolerance and instrumentation error
+ if ((tmp_v3v3 < 0.45) || (tmp_v3v3 > 0.575)) {
+ result |= 0x1;
+ }
+
+ // Test the 5v0 rail
+ // give a 10% leaway for tolerance and instrumentation error
+ if ((tmp_v5v0 < 0.68) || (tmp_v5v0 > 0.835)) {
+ result |= 0x1;
+ }
+
+ return(result);
+
+}
+
+
+
+//// ///////////////////////////////////////////////////////
+////
+//// ///////////////////////////////////////////////////////
+
+int DutSetupTest (void) {
+
+ int result=0;
+
+ DutBufferFlush();
+
+ Dut.printf("S2");
+
+ led2 = 1;
+
+ // wait here until
+ while (!Dut.readable()) {
+ led1 = !led1;
+ wait (0.05);
+ }
+
+
+ char tmp = Dut.getc();
+
+ if ( tmp != 'P' ) {
+ result |= DUTSETUPTEST_FAILED;
+ }
+
+ return(result);
+}
+
+
+
+//// ///////////////////////////////////////////////////////
+////
+//// ///////////////////////////////////////////////////////
+
+int IOTest (void) {
+
+ int result=0;
+
+ DutBufferFlush();
+ Dut.printf("S3");
+
+ // wait here until
+ while (!Dut.readable()) {}
+ char tmp = Dut.getc();
+
+ if ( tmp != 'P' ) {
+ result |= IOTEST_FAILED;
+ }
+
+ return(result);
+}
+
+//// ///////////////////////////////////////////////////////
+////
+//// ///////////////////////////////////////////////////////
+
+int ResetTest (void) {
+
+ int result=0;
+
+ DutBufferFlush();
+
+ // this should hang the target in a while(1) loop
+ Dut.printf("S4");
+
+ // reset the target
+ DUT_NR = 0;
+ wait(0.1);
+ DUT_NR = 1;
+
+
+ // Expect to hear that character back
+
+ // wait here until
+ while (!Dut.readable()) {}
+ char tmp = Dut.getc();
+
+ if ( tmp != 'R' ) {
+ result |= RESETTEST_FAILED;
+ }
+
+ return(result);
+
+}
+
+//// ///////////////////////////////////////////////////////
+////
+//// ///////////////////////////////////////////////////////
+
+int BatteryTest (void) {
+ int result=0;
+
+ // Run the test on the dut. This should ensure the RTC has a sensible value.
+ // after the power down
+
+ DutBufferFlush();
+ Dut.printf("S5");
+
+ // wait here until
+ while (!Dut.readable()) {}
+ char tmp = Dut.getc();
+
+ if ( tmp != 'P' ) {
+ result |= BATTERYTEST_FAILED;
+ }
+
+ return(0);
+}
+
+
+//// ///////////////////////////////////////////////////////
+////
+//// ///////////////////////////////////////////////////////
+
+int RTCTest (void) {
+ int result=0;
+
+ // Run the test on the dut. This should ensure the RTC has a sensible value.
+ // after the power down
+ DutBufferFlush();
+ Dut.printf("S5");
+
+ // wait here until
+ while (!Dut.readable()) {}
+ char tmp = Dut.getc();
+
+ if ( tmp != 'P' ) {
+ result |= RTCTEST_FAILED;
+ }
+
+ return(result);
+}
+
+
+
+
+//// ///////////////////////////////////////////////////////
+////
+//// ///////////////////////////////////////////////////////
+
+int EthernetTest (void) {
+ int result=0;
+
+ DutBufferFlush();
+ Dut.printf("S6");
+
+ // wait here until
+ while (!Dut.readable()) {}
+ char tmp = Dut.getc();
+
+ if ( tmp != 'P' ) {
+ result |= ETHERNETTEST_FAILED;
+ }
+
+ return(result);
+}
+
+
+
+
+//// ///////////////////////////////////////////////////////
+////
+//// ///////////////////////////////////////////////////////
+
+int CleanUp (void) {
+ int result=0;
+
+ DutBufferFlush();
+ Dut.printf("S7");
+
+ // wait here until
+ while (!Dut.readable()) {led3 = !led3; wait (0.1);}
+ char tmp = Dut.getc();
+
+ if ( tmp != 'P' ) {
+ result |= CLEANUP_FAILED;
+ }
+
+ return(result);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests.h Fri Oct 23 14:05:46 2009 +0000 @@ -0,0 +1,19 @@ + +#define VCTEST_FAILED 0x1 +#define DUTSETUPTEST_FAILED 0x2 +#define IOTEST_FAILED 0x4 +#define RESETTEST_FAILED 0x8 +#define RTCTEST_FAILED 0x10 +#define BATTERYTEST_FAILED 0x20 +#define ETHERNETTEST_FAILED 0x40 +#define CLEANUP_FAILED 0x80 + +int VCTest (void); +int DutSetupTest (void); +int IOTest (void); +int ResetTest (void); +int BatteryTest (void); +int RTCTest (void); +int EthernetTest (void); +int CleanUp (void); +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Oct 23 14:05:46 2009 +0000
@@ -0,0 +1,400 @@
+#include "Objects.h"
+#include "Helper.h"
+#include "Tests.h"
+
+
+//#define AUDIO // it beeps at the end
+
+#define TEST_DELAY 0.001
+
+
+// ============================
+// Tests
+// The numbers are used to trigger
+// The test on the DUT
+// ============================
+// 1. VoltageCurrent
+// 2. DUTSetupTest
+// 3. IOTest
+// 4. Resettest
+// 5. BatteryTest
+// 6. EthernetTest
+// ============================
+// Assumptions
+// ============================
+// All tests run off the initial VUSB power up
+// Vin test explicity fiddles the power
+// ============================
+
+int wibble=1;
+
+int main() {
+
+ DutReset(1);
+
+
+ char result=0;
+
+ pc.printf("mbed-005.1 Production test jig\n");
+
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Reflash jig");
+ lcd.locate(0,1);
+ lcd.printf("Press GREEN");
+
+
+ DutISPConnect();
+
+ wait(0.5);
+
+ while (wibble) {
+
+ // wait for the button to be pressed
+ while (!gbtn) {}
+ // Power up
+ DutUsbPowerUp();
+ wait (1.0);
+
+
+ // wait for the button to be pressed
+ while (!gbtn) {}
+ // Power down
+ DutUsbPowerDown();
+ wait (1.0);
+
+
+
+ }
+
+
+ while (1) {
+
+
+
+
+
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("mbed-005.1 Test");
+ lcd.locate(0,1);
+ lcd.printf("Press GREEN");
+
+ // wait for the button to be pressed
+ while (!gbtn) {}
+
+ // Power up USB and connect
+ DutUsbPowerUp();
+ wait (0.1);
+
+
+
+// Connect the USB after the current test
+// this stops the spiking currents during enumeration from
+// giving false readings
+// DutUsbConnect();
+// wait (0.5);
+
+
+// ========================
+// Voltage and current test
+// ========================
+
+
+
+ lcd.locate(0,1);
+ lcd.printf("VCTest ");
+ wait (TEST_DELAY);
+
+ result |= VCTest ();
+ pc.printf("VCTest 0x%x\n",result);
+
+ gled=0; rled=0; wait (0.05);
+ if (result == 0 ) {gled = 1; rled=0;} else {gled = 0; rled=1;}
+
+
+// ========================
+// Connect USB
+// ========================
+
+ DutUsbConnect();
+ wait (0.5);
+
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Copy TestDUT.bin");
+ lcd.locate(0,1);
+ lcd.printf("Press GREEN");
+ wait(0.5);
+
+ // wait for the button to be pressed
+ while (!gbtn) {}
+
+ // turn off the board and USB, and power it up using VIN
+ DutUsbPowerDown();
+ DutUsbDisconnect();
+
+ wait (0.2);
+ DutVinPowerUp();
+
+ // Turn on the VB power, this is so it can stablise
+ DutVB(1);
+ VBatGnd=1;
+
+ // this covers the debug case when the board
+ // remains powered by USB
+ DUT_NR = 0;
+ wait (0.1);
+ DUT_NR = 1;
+
+
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Waiting for DUT");
+
+
+ // this is where the DUT power up... it will take a bunch of time
+ // for the binary to be programmed
+ // We should wait for a "R" to be sent by the DUT
+
+ DutBufferFlush();
+ // wait here until
+ while (!Dut.readable()) {
+ led4 = !led4;
+ wait (0.05);
+ }
+
+ char tmp = Dut.getc();
+
+ if ( tmp != 'R' ) {
+ }
+
+
+ // Start the test
+ lcd.locate(0,1);
+ lcd.printf("Testing...");
+
+
+
+
+//// ///////////////////////////////////////////////////////
+//// This is where we do the grunt work of running the tests
+//// ///////////////////////////////////////////////////////
+
+
+
+
+
+
+
+
+// ========================
+// Dut setup
+// ========================
+
+ lcd.locate(0,1);
+ lcd.printf("DutSetupTest");
+ result |= DutSetupTest ();
+ pc.printf("DutSetup 0x%x\n",result);
+ wait (TEST_DELAY);
+
+ gled=0; rled=0; wait (0.05);
+ if (result == 0 ) {gled = 1; rled=0;} else {gled = 0; rled=1;}
+
+
+// ========================
+// IO Test
+// ========================
+
+ lcd.locate(0,1);
+ lcd.printf("IOTest ");
+ result |= IOTest ();
+ pc.printf("IOTest 0x%x\n",result);
+ wait (TEST_DELAY);
+
+ gled=0; rled=0; wait (0.05);
+ if (result == 0 ) {gled = 1; rled=0;} else {gled = 0; rled=1;}
+
+
+// ========================
+// Reset Test
+// ========================
+
+ lcd.cls(); lcd.locate(0,0);
+ lcd.printf("ResetTest");
+ result |= ResetTest ();
+ pc.printf("ResetTest 0x%x\n",result);
+ wait (TEST_DELAY);
+
+ gled=0; rled=0; wait (0.05);
+ if (result == 0 ) {gled = 1; rled=0;} else {gled = 0; rled=1;}
+
+
+// ========================
+// Ethernet test
+// ========================
+
+
+ lcd.cls(); lcd.locate(0,0);
+ lcd.printf("EthernetTest");
+ result |= EthernetTest ();
+ pc.printf("EthernetTest 0x%x\n",result);
+ wait (TEST_DELAY);
+
+ gled=0; rled=0; wait (0.05);
+ if (result == 0 ) {gled = 1; rled=0;} else {gled = 0; rled=1;}
+
+
+
+// ========================
+// RTC Test
+// ========================
+
+
+ lcd.cls(); lcd.locate(0,0);
+ lcd.printf("RTC test");
+
+ result |= RTCTest ();
+ pc.printf("RTCtTest 0x%x\n",result);
+ wait (TEST_DELAY);
+
+ gled=0; rled=0; wait (0.05);
+ if (result == 0 ) {gled = 1; rled=0;} else {gled = 0; rled=1;}
+
+
+
+
+// ========================
+// VBat Test
+// ========================
+
+
+// make sure the clock still has a sensible value
+
+ lcd.cls(); lcd.locate(0,0);
+ lcd.printf("VBat test");
+
+ // Turn off all other power
+ DutVinPowerDown();
+
+ // wait for 1 second
+ wait(0.1);
+
+ // power back on
+ DutVinPowerUp();
+ wait (0.1);
+
+ // flush the buffer (there will be an "R")
+ DutBufferFlush();
+
+ result |= BatteryTest ();
+ pc.printf("VBatTest 0x%x\n",result);
+ wait (TEST_DELAY);
+
+ gled=0; rled=0; wait (0.05);
+ if (result == 0 ) {gled = 1; rled=0;} else {gled = 0; rled=1;}
+
+
+
+
+
+
+
+
+// ========================
+// Clean up
+// ========================
+
+ lcd.cls(); lcd.locate(0,0);
+ if (result==0) {
+ result |= CleanUp ();
+ }
+
+
+
+ gled=0; rled=0; wait (0.05);
+ if (result == 0 ) {gled = 1; rled=0;} else {gled = 0; rled=1;}
+
+
+ // non-zero, Dut failed
+ if (result) {
+ lcd.cls(); lcd.locate(0,0);
+ lcd.printf("Failed : 0x%x",result);
+ gled = 0; rled=1;
+ lcd.locate(0,1);
+ lcd.printf("Info in Test.log",result);
+
+
+
+ // Power up USB and connect
+ DutUsbPowerUp();
+ wait (0.1);
+ DutUsbConnect();
+ wait (0.5);
+
+
+ #ifdef AUDIO
+ Beep(500,0.5);
+ #endif
+
+
+
+
+ } else {
+ lcd.cls();
+ lcd.locate(0,0);
+ lcd.printf("Passed! :-)");
+
+ lcd.locate(0,1);
+ lcd.printf("Press GREEN");
+ gled = 1; rled=0;
+
+ #ifdef AUDIO
+ Beep(4000,0.5);
+ #endif
+ }
+
+//// ///////////////////////////////////////////////////////
+////
+//// ///////////////////////////////////////////////////////
+
+
+ // wait for the button to be pressed
+ while (!gbtn) {}
+ wait(0.1);
+
+ // Clean up for the next pass
+ result = 0;
+ rled=0;
+ gled=0;
+ DutUsbPowerDown ();
+ DutUsbDisconnect ();
+ DutVinPowerDown ();
+ DutReset (1);
+ DutVB (0);
+
+
+
+ } // end of while
+
+} // end of main
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Oct 23 14:05:46 2009 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/1c1ebd0324fa

