application: show connection details
This commit is contained in:
parent
4067dc090c
commit
ac3975c1b2
|
@ -118,10 +118,13 @@ static void standby(void)
|
|||
|
||||
}
|
||||
|
||||
/** meaning of the print connection information */
|
||||
static const char* connection_legend = "connection details: D = pin driven, P = pin pulled, F = pin floating, >/< direction\n";
|
||||
|
||||
/** print the pin connection details
|
||||
* @param[in] connection connection details to print
|
||||
*/
|
||||
static void print_connection(struct usb_connection_t* connection)
|
||||
static void print_connection(const struct usb_connection_t* connection)
|
||||
{
|
||||
if (NULL == connection) {
|
||||
return;
|
||||
|
@ -1104,6 +1107,7 @@ static void command_connections(void* argument)
|
|||
uint8_t (*connections)[2] = NULL;
|
||||
if (intra) {
|
||||
printf("= testing internal connections =\n");
|
||||
puts(connection_legend);
|
||||
for (uint8_t i = 0; i < LENGTH(usb_connectors); i++) {
|
||||
// test pin connections
|
||||
const struct usb_connector_t* connector = usb_connectors[i];
|
||||
|
@ -1122,7 +1126,15 @@ static void command_connections(void* argument)
|
|||
}
|
||||
printf(": %u connection(s)\n", connections_nb);
|
||||
for (uint16_t connection = 0; connection < connections_nb; connection++) {
|
||||
printf("- %s to %s\n", usb_pins[connections[connection][0]].name, usb_pins[connections[connection][1]].name);
|
||||
struct usb_connection_t connection_detail;
|
||||
const bool connected = usb_cables_test_pins(&usb_pins[connections[i][0]], &usb_pins[connections[i][1]], &connection_detail);
|
||||
printf("- %s to %s (", usb_pins[connections[connection][0]].name, usb_pins[connections[connection][1]].name);
|
||||
if (connected) {
|
||||
print_connection(&connection_detail);
|
||||
} else {
|
||||
puts("connection dropped");
|
||||
}
|
||||
puts(")\n");
|
||||
}
|
||||
printf("there is %s load on the connector\n", load ? "a" : "no");
|
||||
if (connections) {
|
||||
|
@ -1136,6 +1148,7 @@ static void command_connections(void* argument)
|
|||
} else {
|
||||
printf("= testing all connections =\n");
|
||||
}
|
||||
puts(connection_legend);
|
||||
connections = (uint8_t (*)[2])usb_cables_test_connections(usb_connectors, LENGTH(usb_connectors), !inter, false, &connections_nb);
|
||||
if (NULL == connections) {
|
||||
if (connections_nb) {
|
||||
|
@ -1150,9 +1163,12 @@ static void command_connections(void* argument)
|
|||
const struct usb_connector_t* connector_from = usb_cables_get_connector(connections[i][0]);
|
||||
const struct usb_connector_t* connector_to = usb_cables_get_connector(connections[i][1]);
|
||||
if (NULL == connector_from || NULL == connector_to) {
|
||||
printf("no connector for a pin pair\n");
|
||||
puts("no connector for a pin pair\n");
|
||||
continue;
|
||||
}
|
||||
// get connection details
|
||||
struct usb_connection_t connection;
|
||||
const bool connected = usb_cables_test_pins(&usb_pins[connections[i][0]], &usb_pins[connections[i][1]], &connection);
|
||||
printf("%s ", connector_from->name);
|
||||
if (connector_from->variant) {
|
||||
printf("(%s) ", connector_from->variant);
|
||||
|
@ -1161,7 +1177,13 @@ static void command_connections(void* argument)
|
|||
if (connector_to->variant) {
|
||||
printf("(%s) ", connector_to->variant);
|
||||
}
|
||||
printf("%s\n", usb_pins[connections[i][1]].name);
|
||||
printf("%s (", usb_pins[connections[i][1]].name);
|
||||
if (connected) {
|
||||
print_connection(&connection);
|
||||
} else {
|
||||
puts("connection dropped");
|
||||
}
|
||||
puts(")\n");
|
||||
}
|
||||
if (connections) {
|
||||
free(connections);
|
||||
|
@ -1180,7 +1202,7 @@ static void command_cplug(void* argument)
|
|||
const enum usb_connectors_e connectors[] = {USB_CONNECTOR_C_HOST, USB_CONNECTOR_C_DEVICE}; // USB-C connectors to test
|
||||
|
||||
puts("= testing C plugs =\n");
|
||||
puts("connection details: D = pin driven, P = pin pulled, F = pin floating, >/< direction\n");
|
||||
puts(connection_legend);
|
||||
|
||||
usb_cables_pins_float(); // put all pins to float before making checks
|
||||
|
||||
|
|
Loading…
Reference in New Issue