diff --git a/testjig/production/electrical_test.cpp b/testjig/production/electrical_test.cpp index 10d6ed42e81827c1280ac64264beb4396b579440..f215e9991267b908fa69f8cd621a0f5fee725973 100644 --- a/testjig/production/electrical_test.cpp +++ b/testjig/production/electrical_test.cpp @@ -286,6 +286,59 @@ bool ElectricalTest::testUSBConnections() return true; } +bool ElectricalTest::testSerialConnections() +{ + target.log(logLevel, "ETEST: Testing serial connections"); + + // This tests serial RX, TX, and the DMA loopback, which are all adjacent. + target.pinMode(target.PTB0, OUTPUT); + target.pinMode(target.PTC0, INPUT); + for (unsigned i = 0; i < 10; i++) { + target.digitalWrite(target.PTB0, i&1); + if (target.digitalRead(target.PTC0) != (i&1)) { + target.log(LOG_ERROR, "ETEST: Bad connection between DMA loopback pins PTB0 and PTC0"); + return false; + } + } + + // Leave that connection driven, check for shorts to serial RX/TX + if (!testHighZ(fcTXPin)) { + target.log(LOG_ERROR, "ETEST: Fault on serial TX pin, expected High-Z"); + return false; + } + if (!testHighZ(fcRXPin)) { + target.log(LOG_ERROR, "ETEST: Fault on serial RX pin, expected High-Z"); + return false; + } + + // Drive serial TX, check for results and make sure there's no short to RX + target.pinMode(target.PTB17, OUTPUT); + for (unsigned i = 0; i < 10; i++) { + target.digitalWrite(target.PTB17, i&1); + if (digitalRead(fcTXPin) != (i&1)) { + target.log(LOG_ERROR, "ETEST: Bad connection on serial TX pin"); + return false; + } + } + if (!testHighZ(fcRXPin)) { + target.log(LOG_ERROR, "ETEST: Short between serial TX and RX"); + return false; + } + + // Drive RX, and test that + pinMode(fcRXPin, OUTPUT); + target.pinMode(target.PTB16, INPUT); + for (unsigned i = 0; i < 10; i++) { + digitalWrite(fcRXPin, i&1); + if (target.digitalRead(target.PTB16) != (i&1)) { + target.log(LOG_ERROR, "ETEST: Bad connection on serial RX pin"); + return false; + } + } + + return true; +} + bool ElectricalTest::runAll() { target.log(logLevel, "ETEST: Beginning electrical test"); @@ -301,6 +354,10 @@ bool ElectricalTest::runAll() if (!testAllOutputPatterns()) return false; + // Test serial connections, and the adjacent DMA loopback + if (!testSerialConnections()) + return false; + // Now try dialing down the power supply voltage, and make sure it still works if (!testBoostConverter()) return false; diff --git a/testjig/production/electrical_test.h b/testjig/production/electrical_test.h index 9b951e0fc2f622104d252a2c1ddcac8c856083df..fcc47b9f3d08c0ace061771e0071794460465faf 100644 --- a/testjig/production/electrical_test.h +++ b/testjig/production/electrical_test.h @@ -55,6 +55,7 @@ private: bool testAllOutputPatterns(); bool testUSBConnections(); bool testBoostConverter(); + bool testSerialConnections(); bool testHighZ(int pin); bool testPull(int pin, bool state); bool initTarget(); diff --git a/testjig/production/testjig.h b/testjig/production/testjig.h index ee99a7a11c3af23e0c84c83364e9e242a41b62f0..f5b85021e5b7277377d54fb7f226e54466ebadd9 100644 --- a/testjig/production/testjig.h +++ b/testjig/production/testjig.h @@ -11,6 +11,8 @@ static const unsigned swclkPin = 3; static const unsigned swdioPin = 4; // Electrical testing +static const unsigned fcTXPin = 0; +static const unsigned fcRXPin = 1; static const unsigned powerPWMPin = 10; static const unsigned usbDMinusPin = 5; static const unsigned usbDPlusPin = 6;