Compare commits

...

1 commit

Author SHA1 Message Date
lady ada
e7e367ca80 add some gpio retries 2023-02-16 10:48:20 -05:00
2 changed files with 44 additions and 35 deletions

View file

@ -218,6 +218,7 @@ bool Adafruit_TestBed::testAnalogVoltage(uint16_t pin, const char *name,
/**************************************************************************/
bool Adafruit_TestBed::testpins(uint8_t a, uint8_t b, uint8_t *allpins,
uint8_t num_allpins) {
bool ok = false;
theSerial->print(F("\tTesting "));
theSerial->print(a, DEC);
@ -237,6 +238,7 @@ bool Adafruit_TestBed::testpins(uint8_t a, uint8_t b, uint8_t *allpins,
return false;
}
for (int retry=0; retry<3 && !ok; retry++) {
// turn off both pullups
pinMode(a, INPUT);
pinMode(b, INPUT);
@ -248,17 +250,23 @@ bool Adafruit_TestBed::testpins(uint8_t a, uint8_t b, uint8_t *allpins,
int ar = digitalRead(a);
int br = digitalRead(b);
delay(5);
// make sure both are low
if (ar || br) {
theSerial->print(F("Low test fail on "));
theSerial->print(F("Low test fail on pin #"));
if (br)
theSerial->println(b, DEC);
if (ar)
theSerial->println(a, DEC);
return false;
ok = false;
}
ok = true;
}
ok = false;
for (int retry=0; retry<3 && !ok; retry++) {
//theSerial->println("OK!");
// a is an input, b is an output
pinMode(a, INPUT);
pinMode(b, OUTPUT);
@ -271,10 +279,11 @@ bool Adafruit_TestBed::testpins(uint8_t a, uint8_t b, uint8_t *allpins,
|| !digitalRead(b)
#endif
) {
theSerial->println(
F("Ground test 2 fail: both pins should not be grounded"));
theSerial->println(F("Ground test 2 fail: both pins should not be grounded"));
delay(100);
return false;
ok = false;
}
ok = true;
}
// make sure no pins are shorted to pin a or b

View file

@ -157,12 +157,12 @@ void Adafruit_TestBed_Brains::rp2040_targetResetBootRom(int bootsel_pin,
pinMode(bootsel_pin, OUTPUT);
digitalWrite(bootsel_pin, LOW);
delay(reset_ms);
targetReset(reset_ms);
delay(reset_ms);
// change bootsel to input since it is muxed with Flash ChipSelect
digitalWrite(bootsel_pin, HIGH);
pinMode(bootsel_pin, INPUT);
}