add test action to test USB cables

This commit is contained in:
King Kévin 2019-11-19 18:47:00 +01:00
parent 9750148e86
commit 5a5543ae53
1 changed files with 38 additions and 0 deletions

View File

@ -122,6 +122,36 @@ static void command_reset(void* argument);
*/
static void command_bootloader(void* argument);
/** test USB cable
* @param[in] argument no argument required
*/
static void command_test(void* argument)
{
(void)argument; // we won't use the argument
usb_pins_float(); // start with all pins in safe floating state
// step 0: check for internal shorts on each connector
printf("= intra-connector check =\n");
for (uint8_t connector = 0; connector < LENGTH(usb_connectors); connector++) { // test from every connector
usb_cables_check_intra(&usb_connectors[connector]);
}
usb_pins_float(); // put all pins back 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));
// step 2: check for known cable configuration
printf("= cable check =\n");
for (uint8_t cable = 0; cable < LENGTH(usb_cables); cable++) { // test from every connector
uint8_t pair_defined, pair_undefined, pair_disconnected, pair_error;
printf("%s:", usb_cables[cable].name);
bool result = usb_cables_check_cable(&usb_cables[cable], &pair_defined, &pair_undefined, &pair_disconnected, &pair_error);
printf("%s (defined=%u, undefined=%u, disconnected=%u, error=%u)\n", result ? "ok" : "ko", pair_defined, pair_undefined, pair_disconnected, pair_error);
}
}
/** list of all supported commands */
static const struct menu_command_t menu_commands[] = {
{
@ -174,6 +204,14 @@ static const struct menu_command_t menu_commands[] = {
.argument_description = NULL,
.command_handler = &command_bootloader,
},
{
.shortcut = 't',
.name = "test",
.command_description = "test USB cable",
.argument = MENU_ARGUMENT_NONE,
.argument_description = NULL,
.command_handler = &command_test,
},
};
static void command_help(void* argument)