stm32f1: jtag: add command to enable/disable JTAG
This commit is contained in:
parent
e3c592a9dc
commit
ecc8911272
2 changed files with 31 additions and 0 deletions
3
include/shell/jtag.h
Normal file
3
include/shell/jtag.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
int shell_jtag(struct console *con, size_t argc, const char **argv);
|
28
source/shell/jtag.c
Normal file
28
source/shell/jtag.c
Normal file
|
@ -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…
Add table
Reference in a new issue