usb_cables: add function to float all USB pins
This commit is contained in:
parent
25b8a59663
commit
2e09990f2b
17
usb_cables.c
17
usb_cables.c
|
@ -4509,7 +4509,15 @@ const struct usb_cable_t usb_cables[] = {
|
|||
},
|
||||
};
|
||||
|
||||
void usb_cables_pins_float(const struct usb_connector_t* connector)
|
||||
void usb_cables_pins_float(void)
|
||||
{
|
||||
for (uint8_t pin = 0; pin < LENGTH(usb_pins); pin++) { // go through every pin
|
||||
const struct usb_pin_t* usb_pin = &usb_pins[pin]; // get pin
|
||||
gpio_set_mode(usb_pin->port, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, usb_pin->pin); // put pin to floating
|
||||
}
|
||||
}
|
||||
|
||||
void usb_cables_connector_float(const struct usb_connector_t* connector)
|
||||
{
|
||||
// input argument check
|
||||
if (NULL == connector) {
|
||||
|
@ -4529,7 +4537,7 @@ void usb_cables_connectors_float(const struct usb_connector_t** connectors, uint
|
|||
}
|
||||
|
||||
for (uint8_t connector = 0; connector < connectors_nb; connector++) { // go through every connector
|
||||
usb_cables_pins_float(connectors[connector]);
|
||||
usb_cables_connector_float(connectors[connector]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4620,7 +4628,7 @@ void usb_cables_check_intra(const struct usb_connector_t* connector, bool* conne
|
|||
connected[pin] = false;
|
||||
}
|
||||
}
|
||||
usb_cables_pins_float(connector); // ensure we start in a safe state
|
||||
usb_cables_pins_float(); // ensure we start in a safe state
|
||||
for (uint8_t pin_from = 0; pin_from < connector->pins_nb; pin_from++) { // test from every pin
|
||||
for (uint8_t pin_to = 0; pin_to < connector->pins_nb; pin_to++) { // test to every pin (except itself)
|
||||
// don't check the same pins
|
||||
|
@ -4653,7 +4661,6 @@ void usb_cables_check_intra(const struct usb_connector_t* connector, bool* conne
|
|||
}
|
||||
}
|
||||
}
|
||||
usb_cables_pins_float(connector); // go back to safe state
|
||||
}
|
||||
|
||||
void usb_cables_check_inter(const struct usb_connector_t** connectors, uint8_t connectors_nb, bool* connected)
|
||||
|
@ -4805,7 +4812,7 @@ bool usb_cables_check_load(const struct usb_connector_t* connector)
|
|||
return false;
|
||||
}
|
||||
|
||||
usb_cables_pins_float(connector); // ensure we start with all pins floating to not influence the check
|
||||
usb_cables_pins_float(); // ensure we start with all pins floating to not influence the check
|
||||
|
||||
bool loaded = false; // remember if we found a load
|
||||
|
||||
|
|
|
@ -71,10 +71,12 @@ extern const struct usb_connector_t* usb_connectors[8];
|
|||
/** USB cables definitions */
|
||||
extern const struct usb_cable_t usb_cables[77];
|
||||
|
||||
/** set every USB pin from every USB connector to input floating */
|
||||
void usb_cables_pins_float(void);
|
||||
/** set every pin of connector to input floating
|
||||
* @param[in] connector connector on which to set the pins floating
|
||||
*/
|
||||
void usb_cables_pins_float(const struct usb_connector_t* connector);
|
||||
void usb_cables_connector_float(const struct usb_connector_t* connector);
|
||||
/** set every pin to the connectors to input floating
|
||||
* @param[in] connectors list on connectors on which to set the pins floating
|
||||
* @param[in] connectors_nb numbers of connectors
|
||||
|
|
Loading…
Reference in New Issue