From 93bc3a155aed37158897d5d24b4070b2e6aaf61b Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Thu, 26 Oct 2017 15:11:55 +0200 Subject: [PATCH] traceswo: Provide command option for async swo. --- src/command.c | 18 ++++++++++++++---- src/platforms/common/traceswo.h | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/command.c b/src/command.c index 9594c3a..648ec88 100644 --- a/src/command.c +++ b/src/command.c @@ -56,7 +56,7 @@ static bool cmd_hard_srst(void); static bool cmd_target_power(target *t, int argc, const char **argv); #endif #ifdef PLATFORM_HAS_TRACESWO -static bool cmd_traceswo(void); +static bool cmd_traceswo(target *t, int argc, const char **argv); #endif #ifdef PLATFORM_HAS_DEBUG static bool cmd_debug_bmp(target *t, int argc, const char **argv); @@ -75,7 +75,7 @@ const struct command_s cmd_list[] = { {"tpwr", (cmd_handler)cmd_target_power, "Supplies power to the target: (enable|disable)"}, #endif #ifdef PLATFORM_HAS_TRACESWO - {"traceswo", (cmd_handler)cmd_traceswo, "Start trace capture" }, + {"traceswo", (cmd_handler)cmd_traceswo, "Start trace capture [(baudrate) for async swo]" }, #endif #ifdef PLATFORM_HAS_DEBUG {"debug_bmp", (cmd_handler)cmd_debug_bmp, "Output BMP \"debug\" strings to the second vcom: (enable|disable)"}, @@ -277,10 +277,20 @@ static bool cmd_target_power(target *t, int argc, const char **argv) #endif #ifdef PLATFORM_HAS_TRACESWO -static bool cmd_traceswo(void) +static bool cmd_traceswo(target *t, int argc, const char **argv) { +#if defined(STM32L0) || defined(STM32F3) || defined(STM32F4) + extern char serial_no[13]; +#else extern char serial_no[9]; - traceswo_init(); +#endif + uint32_t baudrate = 0; + (void)t; + + if (argc > 1) + baudrate = atoi(argv[1]); + + traceswo_init(baudrate); gdb_outf("%s:%02X:%02X\n", serial_no, 5, 0x85); return true; } diff --git a/src/platforms/common/traceswo.h b/src/platforms/common/traceswo.h index 5566f94..fb57a89 100644 --- a/src/platforms/common/traceswo.h +++ b/src/platforms/common/traceswo.h @@ -22,7 +22,7 @@ #include -void traceswo_init(void); +void traceswo_init(uint32_t baudrate); void trace_buf_drain(usbd_device *dev, uint8_t ep); #endif