Compare commits
1 commit
master
...
rp2040brai
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7e367ca80 |
2 changed files with 44 additions and 35 deletions
|
|
@ -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,
|
bool Adafruit_TestBed::testpins(uint8_t a, uint8_t b, uint8_t *allpins,
|
||||||
uint8_t num_allpins) {
|
uint8_t num_allpins) {
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
theSerial->print(F("\tTesting "));
|
theSerial->print(F("\tTesting "));
|
||||||
theSerial->print(a, DEC);
|
theSerial->print(a, DEC);
|
||||||
|
|
@ -237,44 +238,52 @@ bool Adafruit_TestBed::testpins(uint8_t a, uint8_t b, uint8_t *allpins,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn off both pullups
|
for (int retry=0; retry<3 && !ok; retry++) {
|
||||||
pinMode(a, INPUT);
|
// turn off both pullups
|
||||||
pinMode(b, INPUT);
|
pinMode(a, INPUT);
|
||||||
|
pinMode(b, INPUT);
|
||||||
// make a an output
|
|
||||||
pinMode(a, OUTPUT);
|
// make a an output
|
||||||
digitalWrite(a, LOW);
|
pinMode(a, OUTPUT);
|
||||||
delay(1);
|
digitalWrite(a, LOW);
|
||||||
|
delay(1);
|
||||||
int ar = digitalRead(a);
|
|
||||||
int br = digitalRead(b);
|
int ar = digitalRead(a);
|
||||||
|
int br = digitalRead(b);
|
||||||
// make sure both are low
|
delay(5);
|
||||||
if (ar || br) {
|
|
||||||
theSerial->print(F("Low test fail on "));
|
// make sure both are low
|
||||||
if (br)
|
if (ar || br) {
|
||||||
theSerial->println(b, DEC);
|
theSerial->print(F("Low test fail on pin #"));
|
||||||
if (ar)
|
if (br)
|
||||||
theSerial->println(a, DEC);
|
theSerial->println(b, DEC);
|
||||||
return false;
|
if (ar)
|
||||||
|
theSerial->println(a, DEC);
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
ok = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a is an input, b is an output
|
ok = false;
|
||||||
pinMode(a, INPUT);
|
for (int retry=0; retry<3 && !ok; retry++) {
|
||||||
pinMode(b, OUTPUT);
|
//theSerial->println("OK!");
|
||||||
digitalWrite(b, HIGH);
|
// a is an input, b is an output
|
||||||
delay(10);
|
pinMode(a, INPUT);
|
||||||
|
pinMode(b, OUTPUT);
|
||||||
// verify neither are grounded
|
digitalWrite(b, HIGH);
|
||||||
if (!digitalRead(a)
|
delay(10);
|
||||||
|
|
||||||
|
// verify neither are grounded
|
||||||
|
if (!digitalRead(a)
|
||||||
#if !defined(ESP32)
|
#if !defined(ESP32)
|
||||||
|| !digitalRead(b)
|
|| !digitalRead(b)
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
theSerial->println(
|
theSerial->println(F("Ground test 2 fail: both pins should not be grounded"));
|
||||||
F("Ground test 2 fail: both pins should not be grounded"));
|
delay(100);
|
||||||
delay(100);
|
ok = false;
|
||||||
return false;
|
}
|
||||||
|
ok = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure no pins are shorted to pin a or b
|
// make sure no pins are shorted to pin a or b
|
||||||
|
|
|
||||||
|
|
@ -157,12 +157,12 @@ void Adafruit_TestBed_Brains::rp2040_targetResetBootRom(int bootsel_pin,
|
||||||
pinMode(bootsel_pin, OUTPUT);
|
pinMode(bootsel_pin, OUTPUT);
|
||||||
|
|
||||||
digitalWrite(bootsel_pin, LOW);
|
digitalWrite(bootsel_pin, LOW);
|
||||||
|
delay(reset_ms);
|
||||||
|
|
||||||
targetReset(reset_ms);
|
targetReset(reset_ms);
|
||||||
delay(reset_ms);
|
delay(reset_ms);
|
||||||
|
|
||||||
// change bootsel to input since it is muxed with Flash ChipSelect
|
// change bootsel to input since it is muxed with Flash ChipSelect
|
||||||
digitalWrite(bootsel_pin, HIGH);
|
|
||||||
pinMode(bootsel_pin, INPUT);
|
pinMode(bootsel_pin, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue