From ecc89112729cdd67c650698c61949801fbef9dcf Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Fri, 15 Feb 2019 16:47:14 +0100 Subject: [PATCH] stm32f1: jtag: add command to enable/disable JTAG --- include/shell/jtag.h | 3 +++ source/shell/jtag.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 include/shell/jtag.h create mode 100644 source/shell/jtag.c diff --git a/include/shell/jtag.h b/include/shell/jtag.h new file mode 100644 index 0000000..596b05c --- /dev/null +++ b/include/shell/jtag.h @@ -0,0 +1,3 @@ +#pragma once + +int shell_jtag(struct console *con, size_t argc, const char **argv); diff --git a/source/shell/jtag.c b/source/shell/jtag.c new file mode 100644 index 0000000..be4b32b --- /dev/null +++ b/source/shell/jtag.c @@ -0,0 +1,28 @@ +#include +#include +#include + +#include + +#include + +int shell_jtag(struct console *con, size_t argc, const char **argv) +{ + int state = 0; + + (void)con; + + if (argc >= 2) { + state = (strcmp(argv[1], "on") == 0); + } + + if (state) { + gpio_primary_remap(AFIO_MAPR_SWJ_CFG_FULL_SWJ, + AFIO_MAPR_TIM2_REMAP_PARTIAL_REMAP1); + } else { + gpio_primary_remap(AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON, + AFIO_MAPR_TIM2_REMAP_PARTIAL_REMAP1); + } + + return 0; +}