application: print connection details
This commit is contained in:
parent
b7b9de846d
commit
69d2f047c8
156
application.c
156
application.c
|
@ -118,6 +118,80 @@ static void standby(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** print the pin connection details
|
||||||
|
* @param[in] connection connection details to print
|
||||||
|
*/
|
||||||
|
static void print_connection(struct usb_connection_t* connection)
|
||||||
|
{
|
||||||
|
if (NULL == connection) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// count number of connections_nb to print between the connections
|
||||||
|
uint8_t connections_nb = 0;
|
||||||
|
if (connection->tx_pull_float) {
|
||||||
|
connections_nb++;
|
||||||
|
}
|
||||||
|
if (connection->tx_drive_float) {
|
||||||
|
connections_nb++;
|
||||||
|
}
|
||||||
|
if (connection->tx_drive_pull) {
|
||||||
|
connections_nb++;
|
||||||
|
}
|
||||||
|
if (connection->rx_pull_float) {
|
||||||
|
connections_nb++;
|
||||||
|
}
|
||||||
|
if (connection->rx_drive_float) {
|
||||||
|
connections_nb++;
|
||||||
|
}
|
||||||
|
if (connection->rx_drive_pull) {
|
||||||
|
connections_nb++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// print connections
|
||||||
|
if (0 == connections_nb) {
|
||||||
|
puts("no connections");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
connections_nb--; // one less separator
|
||||||
|
}
|
||||||
|
if (connection->tx_pull_float) {
|
||||||
|
puts("P>F");
|
||||||
|
if (connections_nb--) {
|
||||||
|
puts(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (connection->tx_drive_float) {
|
||||||
|
puts("D>F");
|
||||||
|
if (connections_nb--) {
|
||||||
|
puts(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (connection->tx_drive_pull) {
|
||||||
|
puts("D>P");
|
||||||
|
if (connections_nb--) {
|
||||||
|
puts(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (connection->rx_pull_float) {
|
||||||
|
puts("F<P");
|
||||||
|
if (connections_nb--) {
|
||||||
|
puts(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (connection->rx_drive_float) {
|
||||||
|
puts("F<D");
|
||||||
|
if (connections_nb--) {
|
||||||
|
puts(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (connection->rx_drive_pull) {
|
||||||
|
puts("P<D");
|
||||||
|
if (connections_nb--) {
|
||||||
|
puts(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ===================
|
// ===================
|
||||||
// = cable utilities =
|
// = cable utilities =
|
||||||
|
@ -1106,6 +1180,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
|
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("= testing C plugs =\n");
|
||||||
|
puts("connection details: D = pin driven, P = pin pulled, F = pin floating, >/< direction\n");
|
||||||
|
|
||||||
usb_cables_pins_float(); // put all pins to float before making checks
|
usb_cables_pins_float(); // put all pins to float before making checks
|
||||||
|
|
||||||
|
@ -1167,34 +1242,42 @@ static void command_cplug(void* argument)
|
||||||
vbus_all &= vbus;
|
vbus_all &= vbus;
|
||||||
printf("- %s VBUS pins interconnected\n", vbus_all ? "all" : (vbus_any ? "some" : "no"));
|
printf("- %s VBUS pins interconnected\n", vbus_all ? "all" : (vbus_any ? "some" : "no"));
|
||||||
// check if it is a powered cable (VCONN is connected to ground by Ra), or connected to sink
|
// check if it is a powered cable (VCONN is connected to ground by Ra), or connected to sink
|
||||||
bool cc1 = usb_cables_test_pins(&usb_pins[connector->pins[5]], &usb_pins[connector->pins[12 + 1]], NULL); // A5 CC1 - A1 GND
|
struct usb_connection_t cc1_connection;
|
||||||
printf("- CC1 %sconnected to GND\n", cc1 ? "" : "not ");
|
bool cc1 = usb_cables_test_pins(&usb_pins[connector->pins[5]], &usb_pins[connector->pins[12 + 1]], &cc1_connection); // A5 CC1 - A1 GND
|
||||||
bool cc2 = usb_cables_test_pins(&usb_pins[connector->pins[12 + 5]], &usb_pins[connector->pins[12 + 1]], NULL); // B5 CC1 - A1 GND
|
printf("- CC1 %sconnected to GND (", cc1 ? "" : "not ");
|
||||||
printf("- CC2 %sconnected to GND\n", cc2 ? "" : "not ");
|
print_connection(&cc1_connection);
|
||||||
/*
|
puts(")\n");
|
||||||
if (cc1 >= 0x41) {
|
struct usb_connection_t cc2_connection;
|
||||||
puts("- this is a powered cable (CC1 is VCONN)\n");
|
bool cc2 = usb_cables_test_pins(&usb_pins[connector->pins[12 + 5]], &usb_pins[connector->pins[12 + 1]], &cc2_connection); // B5 CC1 - A1 GND
|
||||||
} else if (cc1 >= 0x21) {
|
printf("- CC2 %sconnected to GND (", cc2 ? "" : "not ");
|
||||||
puts("- this cable is to be connected to a sink on the other end (B, mini-B, or micro-B plug)\n");
|
print_connection(&cc2_connection);
|
||||||
} else if (cc2 >= 0x41) {
|
puts(")\n");
|
||||||
puts("- this is a powered cable (CC2 is VCONN)\n");
|
if (cc1_connection.tx_drive_pull && cc1_connection.rx_pull_float) {
|
||||||
} else if (cc2 >= 0x21) {
|
puts("> this is a powered cable (CC1 is VCONN)\n");
|
||||||
puts("- this cable is to be connected to a sink on the other end (B, mini-B, or micro-B plug)\n");
|
} else if (cc1_connection.tx_drive_float && cc1_connection.rx_pull_float) {
|
||||||
|
puts("> this cable is to be connected to a sink on the other end (B, mini-B, or micro-B plug)\n");
|
||||||
|
} else if (cc2_connection.tx_drive_pull && cc2_connection.rx_pull_float) {
|
||||||
|
puts("> this is a powered cable (CC2 is VCONN)\n");
|
||||||
|
} else if (cc2_connection.tx_drive_float && cc2_connection.rx_pull_float) {
|
||||||
|
puts("> this cable is to be connected to a sink on the other end (B, mini-B, or micro-B plug)\n");
|
||||||
} else if (gnd_all && vbus_all) {
|
} else if (gnd_all && vbus_all) {
|
||||||
puts("- this is an unpowered cable\n");
|
puts("> this is an unpowered cable\n");
|
||||||
} else if (gnd_any || vbus_any) {
|
} else if (gnd_all || vbus_all || gnd_any || vbus_any) {
|
||||||
puts("- this is a faulty unpowered cable\n");
|
puts("> this is a faulty unpowered cable\n");
|
||||||
} else {
|
} else {
|
||||||
puts("- there is no plug/cable\n");
|
puts("> there is no plug/cable\n");
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// check if it should be connected to a source
|
// check if it should be connected to a source
|
||||||
cc1 = usb_cables_test_pins(&usb_pins[connector->pins[5]], &usb_pins[connector->pins[4]], NULL); // A5 CC1 - A4 VBUS
|
cc1 = usb_cables_test_pins(&usb_pins[connector->pins[5]], &usb_pins[connector->pins[4]], &cc1_connection); // A5 CC1 - A4 VBUS
|
||||||
printf("- CC1 %sconnected to VBUS\n", cc1 ? "" : "not ");
|
printf("- CC1 %sconnected to VBUS (", cc1 ? "" : "not ");
|
||||||
cc2 = usb_cables_test_pins(&usb_pins[connector->pins[12 + 5]], &usb_pins[connector->pins[4]], NULL); // B5 CC1 - A1 VBUS
|
print_connection(&cc1_connection);
|
||||||
printf("- CC2 %sconnected to VBUS\n", cc2 ? "" : "not ");
|
puts(")\n");
|
||||||
|
cc2 = usb_cables_test_pins(&usb_pins[connector->pins[12 + 5]], &usb_pins[connector->pins[4]], &cc2_connection); // B5 CC1 - A1 VBUS
|
||||||
|
printf("- CC2 %sconnected to VBUS (", cc2 ? "" : "not ");
|
||||||
|
print_connection(&cc2_connection);
|
||||||
|
puts(")\n");
|
||||||
if (cc1 || cc2) {
|
if (cc1 || cc2) {
|
||||||
puts("- this cable is to be connected to a source on the other end (A plug)\n");
|
puts("> this cable is to be connected to a source on the other end (A plug)\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1205,15 +1288,24 @@ static void command_cplug(void* argument)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
puts("cable interconnection\n");
|
puts("cable interconnection\n");
|
||||||
bool conn;
|
struct usb_connection_t connection;
|
||||||
conn = usb_cables_test_pins(&usb_pins[c1->pins[5]], &usb_pins[c2->pins[5]], NULL); // A5 CC1 - A5 CC1
|
bool connected;
|
||||||
printf("- CC1 %sconnected to CC1\n", conn ? "" : "not ");
|
connected = usb_cables_test_pins(&usb_pins[c1->pins[5]], &usb_pins[c2->pins[5]], &connection); // A5 CC1 - A5 CC1
|
||||||
conn = usb_cables_test_pins(&usb_pins[c1->pins[5]], &usb_pins[c2->pins[12 + 5]], NULL); // A5 CC1 - B5 CC2
|
printf("- CC1 %sconnected to CC1 (", connected ? "" : "not ");
|
||||||
printf("- CC1 %sconnected to CC2\n", conn ? "" : "not ");
|
print_connection(&connection);
|
||||||
conn = usb_cables_test_pins(&usb_pins[c1->pins[12 + 5]], &usb_pins[c2->pins[5]], NULL); // B5 CC2 - A5 CC1
|
puts(")\n");
|
||||||
printf("- CC2 %sconnected to CC1\n", conn ? "" : "not ");
|
connected = usb_cables_test_pins(&usb_pins[c1->pins[5]], &usb_pins[c2->pins[12 + 5]], &connection); // A5 CC1 - B5 CC2
|
||||||
conn = usb_cables_test_pins(&usb_pins[c1->pins[12 + 5]], &usb_pins[c2->pins[12 + 5]], NULL); // B5 CC2 - B5 CC2
|
printf("- CC1 %sconnected to CC2 (", connected ? "" : "not ");
|
||||||
printf("- CC2 %sconnected to CC2\n", conn ? "" : "not ");
|
print_connection(&connection);
|
||||||
|
puts(")\n");
|
||||||
|
connected = usb_cables_test_pins(&usb_pins[c1->pins[12 + 5]], &usb_pins[c2->pins[5]], &connection); // B5 CC2 - A5 CC1
|
||||||
|
printf("- CC2 %sconnected to CC1 (", connected ? "" : "not ");
|
||||||
|
print_connection(&connection);
|
||||||
|
puts(")\n");
|
||||||
|
connected = usb_cables_test_pins(&usb_pins[c1->pins[12 + 5]], &usb_pins[c2->pins[12 + 5]], &connection); // B5 CC2 - B5 CC2
|
||||||
|
printf("- CC2 %sconnected to CC2 (", connected ? "" : "not ");
|
||||||
|
print_connection(&connection);
|
||||||
|
puts(")\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================
|
// ====================
|
||||||
|
|
Loading…
Reference in New Issue