From 73b205e6c886e99cb6a3157eba9820d23599d70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Wed, 10 Mar 2021 18:31:39 +0100 Subject: [PATCH] application: add menu to measure voltages --- application.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/application.c b/application.c index 6f76555..17e7489 100644 --- a/application.c +++ b/application.c @@ -124,6 +124,15 @@ static void command_swd_scan(void* argument) } } +static void command_voltages(void* argument) +{ + (void)argument; // we won't use the argument + float* voltages = measure_voltages(); // measure voltages + puts("voltages:\n"); + printf("- target: %.02f V\n", (uint32_t)(voltages[1] * 100) / 100.0); + printf("- signal: %.02f V\n", (uint32_t)(voltages[2] * 100) / 100.0); +} + /** display available commands * @param[in] argument no argument required */ @@ -328,7 +337,7 @@ static const struct menu_command_t menu_commands[] = { .command_handler = &command_help, }, { - .shortcut = 'v', + .shortcut = 'V', .name = "version", .command_description = "show software and hardware version", .argument = MENU_ARGUMENT_NONE, @@ -383,6 +392,14 @@ static const struct menu_command_t menu_commands[] = { .argument_description = NULL, .command_handler = &command_swd_scan, }, + { + .shortcut = 'v', + .name = "voltage", + .command_description = "measure target and signal voltages", + .argument = MENU_ARGUMENT_NONE, + .argument_description = NULL, + .command_handler = &command_voltages, + }, }; static void command_help(void* argument)