summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-04-30 09:13:54 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-04-30 09:13:54 +0000
commit06cdb3ad449edd73dea6f81183a98ddfa4fbd8eb (patch)
treedfd550f9a7340729991cd4492c7663ae2b6b16ab /src
parent26414b39d4d151508bed35c35e5d34c38fd00cc5 (diff)
downloadopenocd_libswd-06cdb3ad449edd73dea6f81183a98ddfa4fbd8eb.tar.gz
openocd_libswd-06cdb3ad449edd73dea6f81183a98ddfa4fbd8eb.tar.bz2
openocd_libswd-06cdb3ad449edd73dea6f81183a98ddfa4fbd8eb.tar.xz
openocd_libswd-06cdb3ad449edd73dea6f81183a98ddfa4fbd8eb.zip
Edgar's added support for printing jtag_khz
git-svn-id: svn://svn.berlios.de/openocd/trunk@628 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/jtag/jtag.c69
-rw-r--r--src/jtag/jtag.h3
2 files changed, 46 insertions, 26 deletions
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c
index 17f212c3..71e40b24 100644
--- a/src/jtag/jtag.c
+++ b/src/jtag/jtag.c
@@ -1501,10 +1501,8 @@ int jtag_interface_init(struct command_context_s *cmd_ctx)
if(hasKHz)
{
/*stay on "reset speed"*/
- if (jtag_interface->khz(speed1, &speed1) == ERROR_OK)
- jtag_speed = speed1;
- if (jtag_interface->khz(speed2, &speed2) == ERROR_OK)
- jtag_speed_post_reset = speed2;
+ jtag_interface->khz(speed1, &jtag_speed);
+ jtag_interface->khz(speed2, &jtag_speed_post_reset);
hasKHz = 0;
}
@@ -1624,6 +1622,12 @@ static int default_khz(int khz, int *jtag_speed)
return ERROR_FAIL;
}
+static int default_speedDiv(int speed, int *khz)
+{
+ LOG_ERROR("Translation from jtag_speed to khz not implemented");
+ return ERROR_FAIL;
+}
+
int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
int i;
@@ -1654,6 +1658,10 @@ int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char
{
jtag_interface->khz = default_khz;
}
+ if (jtag_interface->speedDiv == NULL)
+ {
+ jtag_interface->speedDiv = default_speedDiv;
+ }
return ERROR_OK;
}
}
@@ -1850,7 +1858,11 @@ int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cmd, char
/* this command can be called during CONFIG,
* in which case jtag isn't initialized */
if (jtag)
+ {
+ jtag->speedDiv(jtag_speed, &speed1);
+ jtag->speedDiv(jtag_speed_post_reset, &speed2);
jtag->speed(cur_speed);
+ }
}
command_print(cmd_ctx, "jtag_speed: %d, %d", jtag_speed, jtag_speed_post_reset);
@@ -1861,34 +1873,39 @@ int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char *
{
LOG_DEBUG("handle jtag khz");
- if ((argc<1) || (argc>2))
+ if (argc>2)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc >= 1)
- speed1 = speed2 = strtoul(args[0], NULL, 0);
- if (argc == 2)
- speed2 = strtoul(args[1], NULL, 0);
-
- if (jtag != NULL)
+ if(argc != 0)
{
- int cur_speed = 0;
- LOG_DEBUG("have interface set up");
- int speed_div1, speed_div2;
- if (jtag->khz(speed1, &speed_div1)!=ERROR_OK)
- return ERROR_OK;
- if (jtag->khz(speed2, &speed_div2)!=ERROR_OK)
- return ERROR_OK;
-
+
if (argc >= 1)
- cur_speed = jtag_speed = jtag_speed_post_reset = speed_div1;
+ speed1 = speed2 = strtoul(args[0], NULL, 0);
if (argc == 2)
- cur_speed = jtag_speed_post_reset = speed_div2;
-
- jtag->speed(cur_speed);
- } else
- {
- hasKHz = 1;
+ speed2 = strtoul(args[1], NULL, 0);
+
+ if (jtag != NULL)
+ {
+ int cur_speed = 0;
+ LOG_DEBUG("have interface set up");
+ int speed_div1, speed_div2;
+ if (jtag->khz(speed1, &speed_div1)!=ERROR_OK)
+ return ERROR_OK;
+ if (jtag->khz(speed2, &speed_div2)!=ERROR_OK)
+ return ERROR_OK;
+
+ if (argc >= 1)
+ cur_speed = jtag_speed = jtag_speed_post_reset = speed_div1;
+ if (argc == 2)
+ cur_speed = jtag_speed_post_reset = speed_div2;
+
+ jtag->speed(cur_speed);
+ } else
+ {
+ hasKHz = 1;
+ }
}
+ command_print(cmd_ctx, "jtag_khz: %d, %d", speed1, speed2);
return ERROR_OK;
}
diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h
index 27ffbf87..f5818b98 100644
--- a/src/jtag/jtag.h
+++ b/src/jtag/jtag.h
@@ -198,6 +198,9 @@ typedef struct jtag_interface_s
/* returns JTAG maxium speed for KHz. 0=RTCK. The function returns
a failure if it can't support the KHz/RTCK. */
int (*khz)(int khz, int *jtag_speed);
+ /* returns the KHz for the provided JTAG speed. 0=RTCK. The function returns
+ a failure if it can't support the KHz/RTCK. */
+ int (*speedDiv)(int speed, int *khz);
} jtag_interface_t;