usb_cables: improve power connection test, but reduce pattern length

This commit is contained in:
King Kévin 2020-01-18 13:24:00 +01:00
parent 6d77a2b629
commit caacafb686
1 changed files with 2 additions and 2 deletions

View File

@ -5216,7 +5216,7 @@ bool usb_cables_test_pins(const struct usb_pin_t* pin1, const struct usb_pin_t*
// cross talk, noise, and capacitance are a pain to correctly get rid off
// the result is not perfect, but often checking both directions eliminates false positives
bool connected = true;
for (uint8_t pattern = 0; pattern < 6 && connected; pattern++) { // the pattern is just a sequence on high/low
for (uint8_t pattern = 0; pattern < 4 && connected; pattern++) { // the pattern is just a sequence on high/low
// set alternatively high and low on one pin, and check level on the other pin
gpio_set_mode(to_port, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, to_pin); // first pull to remove capacitance
if (0 == pattern % 2) { // test if high level is detected
@ -5226,7 +5226,7 @@ bool usb_cables_test_pins(const struct usb_pin_t* pin1, const struct usb_pin_t*
gpio_set(to_port, to_pin); // pull up
gpio_clear(from_port, from_pin); // set low
}
if (USB_PIN_TYPE_POWER == pin_from->type) {
if (USB_PIN_TYPE_POWER == pin_from->type || USB_PIN_TYPE_POWER == pin_from->type) {
sleep_us(1200); // wait to cancel capacitance (10 nF, as used on VBUS in C plug)
} else {
sleep_us(10); // wait to settle