stm32f1: jtag: add command to enable/disable JTAG

master
S.J.R. van Schaik 5 years ago
parent e3c592a9dc
commit ecc8911272
  1. 3
      include/shell/jtag.h
  2. 28
      source/shell/jtag.c

@ -0,0 +1,3 @@
#pragma once
int shell_jtag(struct console *con, size_t argc, const char **argv);

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libopencm3/stm32/gpio.h>
#include <console.h>
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;
}
Loading…
Cancel
Save