usb_cables: remove superseeded functions
This commit is contained in:
parent
84d679c3ef
commit
28024ae960
|
@ -123,44 +123,6 @@ static void command_reset(void* argument);
|
|||
*/
|
||||
static void command_bootloader(void* argument);
|
||||
|
||||
/** test USB connectors intra-connections
|
||||
* @param[in] argument no argument required
|
||||
*/
|
||||
static void command_intra(void* argument)
|
||||
{
|
||||
(void)argument; // we won't use the argument
|
||||
|
||||
usb_pins_float(); // start with all pins in safe floating state
|
||||
|
||||
printf("= intra-connector check =\n");
|
||||
for (uint8_t connector = 0; connector < LENGTH(usb_connectors); connector++) { // test from every connector
|
||||
printf("- %s -\n", usb_connectors[connector]->name);
|
||||
bool loaded = usb_cables_check_load(usb_connectors[connector]);
|
||||
if (loaded) {
|
||||
printf("there is %s load on the connector\n", loaded ? "a" : "no");
|
||||
}
|
||||
usb_cables_check_intra(usb_connectors[connector], NULL);
|
||||
}
|
||||
|
||||
usb_pins_float(); // put all pins back in safe floating state
|
||||
}
|
||||
|
||||
/** test USB connectors inter-connections
|
||||
* @param[in] argument no argument required
|
||||
*/
|
||||
static void command_inter(void* argument)
|
||||
{
|
||||
(void)argument; // we won't use the argument
|
||||
|
||||
usb_pins_float(); // start with all pins in safe floating state
|
||||
|
||||
// step 1: find which connectors are connected
|
||||
printf("= inter-connector check =\n");
|
||||
usb_cables_check_inter(usb_connectors, LENGTH(usb_connectors), NULL);
|
||||
|
||||
usb_pins_float(); // put all pins back in safe floating state
|
||||
}
|
||||
|
||||
/** test USB cables
|
||||
* @param[in] argument no argument required
|
||||
*/
|
||||
|
@ -657,22 +619,6 @@ static const struct menu_command_t menu_commands[] = {
|
|||
.argument_description = NULL,
|
||||
.command_handler = &command_bootloader,
|
||||
},
|
||||
{
|
||||
.shortcut = 'a',
|
||||
.name = "intra",
|
||||
.command_description = "test connector intra-connection",
|
||||
.argument = MENU_ARGUMENT_NONE,
|
||||
.argument_description = NULL,
|
||||
.command_handler = &command_intra,
|
||||
},
|
||||
{
|
||||
.shortcut = 'e',
|
||||
.name = "inter",
|
||||
.command_description = "test connector inter-connection",
|
||||
.argument = MENU_ARGUMENT_NONE,
|
||||
.argument_description = NULL,
|
||||
.command_handler = &command_inter,
|
||||
},
|
||||
{
|
||||
.shortcut = 'c',
|
||||
.name = "cables",
|
||||
|
|
109
usb_cables.c
109
usb_cables.c
|
@ -4636,115 +4636,6 @@ uint8_t usb_cables_check_pins(const struct usb_pin_t* pin1, const struct usb_pin
|
|||
return connection;
|
||||
}
|
||||
|
||||
void usb_cables_check_intra(const struct usb_connector_t* connector, bool* connected)
|
||||
{
|
||||
// verify input arguments
|
||||
if (NULL == connector) {
|
||||
return;
|
||||
}
|
||||
|
||||
// initialize output results
|
||||
if (connected) {
|
||||
for (uint8_t pin = 0; connector->pins_nb; pin++) {
|
||||
connected[pin] = false;
|
||||
}
|
||||
}
|
||||
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
|
||||
if (pin_to == pin_from) {
|
||||
continue;
|
||||
}
|
||||
const struct usb_pin_t* usb_pin_from = &usb_pins[connector->pins[pin_from]]; // get from pin
|
||||
const struct usb_pin_t* usb_pin_to = &usb_pins[connector->pins[pin_to]]; // get to pin
|
||||
|
||||
// don't check if power and ground pins are connected because loads lead to false positives
|
||||
if ((USB_PIN_TYPE_GROUND == usb_pin_from->type || USB_PIN_TYPE_SHIELD == usb_pin_from->type) && USB_PIN_TYPE_POWER == usb_pin_to->type) {
|
||||
continue;
|
||||
}
|
||||
if (USB_PIN_TYPE_POWER == usb_pin_from->type && (USB_PIN_TYPE_GROUND == usb_pin_to->type || USB_PIN_TYPE_SHIELD == usb_pin_to->type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint8_t connection = usb_cables_check_pins(usb_pin_from, usb_pin_to);
|
||||
if (connection >= 0x22) {
|
||||
if (connected) {
|
||||
connected[pin_from] = true;
|
||||
connected[pin_to] = true;
|
||||
} else {
|
||||
printf("%s ", connector->name);
|
||||
if (connector->variant) {
|
||||
printf("(%s) ", connector->variant);
|
||||
}
|
||||
printf("%s connected to %s (%02x)\n", usb_pin_from->name, usb_pin_to->name, connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usb_cables_check_inter(const struct usb_connector_t** connectors, uint8_t connectors_nb, bool* connected)
|
||||
{
|
||||
// verify input arguments
|
||||
if (NULL == connectors || 0 == connectors_nb) {
|
||||
return;
|
||||
}
|
||||
|
||||
// initialize output result
|
||||
if (connected) {
|
||||
for (uint8_t connector = 0; connector < connectors_nb; connector++) {
|
||||
connected[connector] = false;
|
||||
}
|
||||
}
|
||||
|
||||
usb_cables_connectors_float(connectors, connectors_nb); // ensure we start in a safe state
|
||||
|
||||
for (uint8_t connector_from = 0; connector_from < connectors_nb; connector_from++) { // test from every connector
|
||||
for (uint8_t pin_from = 0; pin_from < connectors[connector_from]->pins_nb; pin_from++) { // test from every pin
|
||||
for (uint8_t connector_to = connector_from + 1; connector_to < connectors_nb; connector_to++) { // test to every connector (except itself)
|
||||
if (connector_to == connector_from) { // don't test the connector itself since we already did this test
|
||||
continue;
|
||||
}
|
||||
if (connected && connected[connector_to]) { // we already found a connection to this connector
|
||||
continue;
|
||||
}
|
||||
for (uint8_t pin_to = 0; pin_to < connectors[connector_to]->pins_nb; pin_to++) { // test to every pin
|
||||
const struct usb_pin_t* usb_pin_from = &usb_pins[connectors[connector_from]->pins[pin_from]]; // get from pin
|
||||
const struct usb_pin_t* usb_pin_to = &usb_pins[connectors[connector_to]->pins[pin_to]]; // get to pin
|
||||
// don't check if power and ground pins are connected because loads lead to false positives
|
||||
if ((USB_PIN_TYPE_GROUND == usb_pin_from->type || USB_PIN_TYPE_SHIELD == usb_pin_from->type) && USB_PIN_TYPE_POWER == usb_pin_to->type) {
|
||||
continue;
|
||||
}
|
||||
if (USB_PIN_TYPE_POWER == usb_pin_from->type && (USB_PIN_TYPE_GROUND == usb_pin_to->type || USB_PIN_TYPE_SHIELD == usb_pin_to->type)) {
|
||||
continue;
|
||||
}
|
||||
// check if cable is connected
|
||||
uint8_t connection = usb_cables_check_pins(usb_pin_from, usb_pin_to);
|
||||
if (connection >= 0x22) {
|
||||
if (connected) { // remember they are connected
|
||||
connected[connector_from] = true;
|
||||
connected[connector_to] = true;
|
||||
} else {
|
||||
printf("%s ", connectors[connector_from]->name);
|
||||
if (connectors[connector_from]->variant) {
|
||||
printf("(%s) ", connectors[connector_from]->variant);
|
||||
}
|
||||
printf("%s connected to ", usb_pin_from->name);
|
||||
printf("%s ", connectors[connector_to]->name);
|
||||
if (connectors[connector_to]->variant) {
|
||||
printf("(%s) ", connectors[connector_to]->variant);
|
||||
}
|
||||
printf("%s\n", usb_pin_to->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
usb_cables_connectors_float(connectors, connectors_nb); // go back to safe state
|
||||
}
|
||||
|
||||
void usb_cables_check_ground(const struct usb_connector_t** connectors, uint8_t connectors_nb, bool* connected)
|
||||
{
|
||||
// verify input arguments
|
||||
|
|
13
usb_cables.h
13
usb_cables.h
|
@ -94,19 +94,6 @@ const struct usb_connector_t* usb_cables_get_connector(uint8_t pin);
|
|||
* @note setting both levels (high, low) in both directions (pin1 to pin2 and pin2 to pin1) are tested, except for ground pins
|
||||
*/
|
||||
uint8_t usb_cables_check_pins(const struct usb_pin_t* pin1, const struct usb_pin_t* pin2);
|
||||
/** check connector for connections between pins of this connector
|
||||
* @param[in] connector connector to check
|
||||
* @param[out] connected which of the pins are connected (NULL to just print the pins)
|
||||
*/
|
||||
void usb_cables_check_intra(const struct usb_connector_t* connector, bool* connected);
|
||||
/** check connectors for connections between pins of the connectors
|
||||
* @param[in] connectors connectors to check
|
||||
* @param[in] connectors_nb numbers of connectors
|
||||
* @param[out] connected which of the connectors are connected (NULL to just print the connections)
|
||||
* @note connection between pin of the same connector are not checked
|
||||
* @note when connected is NULL all pin connections will be tested, else some might be skipped to speed scan
|
||||
*/
|
||||
void usb_cables_check_inter(const struct usb_connector_t** connectors, uint8_t connectors_nb, bool* connected);
|
||||
/** check connectors for connections between ground pins of the connectors
|
||||
* @param[in] connectors connectors to check
|
||||
* @param[in] connectors_nb numbers of connectors
|
||||
|
|
Loading…
Reference in New Issue