diff --git a/usb_cables.c b/usb_cables.c index 49f52fa..fdb8672 100644 --- a/usb_cables.c +++ b/usb_cables.c @@ -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