From da45281696b05089d694e6e9c7734968b9496865 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Mon, 20 Apr 2020 18:00:31 +0200 Subject: [PATCH] GetTargetVoltage: Print info about voltage only when info is relevant. --- src/command.c | 6 ++++-- src/platforms/f4discovery/platform.c | 2 +- src/platforms/hydrabus/platform.c | 2 +- src/platforms/launchpad-icdi/platform.c | 2 +- src/platforms/pc/cl_utils.c | 3 ++- src/platforms/swlink/platform.c | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/command.c b/src/command.c index 9f9878d..fd7e0b4 100644 --- a/src/command.c +++ b/src/command.c @@ -171,7 +171,8 @@ static bool cmd_jtag_scan(target *t, int argc, char **argv) (void)t; uint8_t irlens[argc]; - gdb_outf("Target voltage: %s\n", platform_target_voltage()); + if (platform_target_voltage()) + gdb_outf("Target voltage: %s\n", platform_target_voltage()); if (argc > 1) { /* Accept a list of IR lengths on command line */ @@ -216,7 +217,8 @@ bool cmd_swdp_scan(target *t, int argc, char **argv) (void)t; (void)argc; (void)argv; - gdb_outf("Target voltage: %s\n", platform_target_voltage()); + if (platform_target_voltage()) + gdb_outf("Target voltage: %s\n", platform_target_voltage()); if(connect_assert_srst) platform_srst_set_val(true); /* will be deasserted after attach */ diff --git a/src/platforms/f4discovery/platform.c b/src/platforms/f4discovery/platform.c index 875c157..7129ea1 100644 --- a/src/platforms/f4discovery/platform.c +++ b/src/platforms/f4discovery/platform.c @@ -100,7 +100,7 @@ bool platform_srst_get_val(void) { return false; } const char *platform_target_voltage(void) { - return "ABSENT!"; + return NULL; } void platform_request_boot(void) diff --git a/src/platforms/hydrabus/platform.c b/src/platforms/hydrabus/platform.c index e0893e8..1b02976 100644 --- a/src/platforms/hydrabus/platform.c +++ b/src/platforms/hydrabus/platform.c @@ -85,7 +85,7 @@ bool platform_srst_get_val(void) { return false; } const char *platform_target_voltage(void) { - return "ABSENT!"; + return NULL; } void platform_request_boot(void) diff --git a/src/platforms/launchpad-icdi/platform.c b/src/platforms/launchpad-icdi/platform.c index 70bb72a..d794372 100644 --- a/src/platforms/launchpad-icdi/platform.c +++ b/src/platforms/launchpad-icdi/platform.c @@ -115,7 +115,7 @@ void platform_delay(uint32_t ms) const char *platform_target_voltage(void) { - return "not supported"; + return NULL; } char *serialno_read(char *s) diff --git a/src/platforms/pc/cl_utils.c b/src/platforms/pc/cl_utils.c index 6fd4fe9..8719fe3 100644 --- a/src/platforms/pc/cl_utils.c +++ b/src/platforms/pc/cl_utils.c @@ -272,7 +272,8 @@ int cl_execute(BMP_CL_OPTIONS_t *opt) platform_srst_set_val(opt->opt_connect_under_reset); if (opt->opt_mode == BMP_MODE_TEST) printf("Running in Test Mode\n"); - printf("Target voltage: %s Volt\n", platform_target_voltage()); + if (platform_target_voltage()) + printf("Target voltage: %s Volt\n", platform_target_voltage()); if (opt->opt_usejtag) { num_targets = platform_jtag_scan(NULL); } else { diff --git a/src/platforms/swlink/platform.c b/src/platforms/swlink/platform.c index c6d7588..18efbf3 100644 --- a/src/platforms/swlink/platform.c +++ b/src/platforms/swlink/platform.c @@ -177,7 +177,7 @@ const char *platform_target_voltage(void) ret[2] = '0' + val_in_100mV % 10; return ret; } - return "ABSENT!"; + return NULL; } void set_idle_state(int state)