usb_cables: fix ground check

This commit is contained in:
King Kévin 2019-12-31 14:21:12 +01:00
parent 43df1a9b33
commit eaed513dec
1 changed files with 4 additions and 4 deletions

View File

@ -4856,11 +4856,11 @@ bool usb_cables_test_ground(const struct usb_connector_t** connectors, uint8_t c
}
for (uint8_t connector_from = 0; connector_from < connectors_nb; connector_from++) { // test from every connector
if (connected[connector_from]) { // we already found ground on this connector
if (connected && connected[connector_from]) { // we already found ground on this connector
continue;
}
for (uint8_t pin_from = 0; pin_from < connectors[connector_from]->pins_nb; pin_from++) { // test from every pin
if (connected[connector_from]) { // we already found ground on this connector
if (connected && connected[connector_from]) { // we already found ground on this connector
break;
}
const struct usb_pin_t* usb_pin_from = &usb_pins[connectors[connector_from]->pins[pin_from]]; // get from pin
@ -4871,11 +4871,11 @@ bool usb_cables_test_ground(const struct usb_connector_t** connectors, uint8_t c
gpio_set_mode(usb_pin_from->port, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, usb_pin_from->pin);
gpio_clear(usb_pin_from->port, usb_pin_from->pin);
for (uint8_t connector_to = connector_from + 1; connector_to < connectors_nb; connector_to++) { // test every next connector
if (connected[connector_to]) { // we already found a grond connection to this connector
if (connected && connected[connector_to]) { // we already found a ground connection to this connector
continue;
}
for (uint8_t pin_to = 0; pin_to < connectors[connector_to]->pins_nb; pin_to++) { // test to every pin
if (connected[connector_to]) { // we already found a ground connection to this connector
if (connected && connected[connector_to]) { // we already found a ground connection to this connector
break;
}
const struct usb_pin_t* usb_pin_to = &usb_pins[connectors[connector_to]->pins[pin_to]]; // get to pin