}
if(hasKHz)
{
- jtag_interface->khz(speed_khz, &jtag_speed);
+ jtag_interface->khz(jtag_get_speed_khz(), &jtag_speed);
hasKHz = false;
}
return jtag_init_reset(cmd_ctx);
}
+void jtag_set_speed_khz(unsigned khz)
+{
+ speed_khz = khz;
+}
+unsigned jtag_get_speed_khz(void)
+{
+ return speed_khz;
+}
+
static int default_khz(int khz, int *jtag_speed)
{
LOG_ERROR("Translation from khz to jtag_speed not implemented");
int retval=ERROR_OK;
LOG_DEBUG("handle jtag khz");
+ int cur_speed = 0;
if(argc == 1)
{
- speed_khz = strtoul(args[0], NULL, 0);
+ jtag_set_speed_khz(strtoul(args[0], NULL, 0));
if (jtag != NULL)
{
- int cur_speed = 0;
LOG_DEBUG("have interface set up");
int speed_div1;
- if ((retval=jtag->khz(speed_khz, &speed_div1))!=ERROR_OK)
+ if ((retval=jtag->khz(jtag_get_speed_khz(), &speed_div1))!=ERROR_OK)
{
- speed_khz = 0;
+ jtag_set_speed_khz(0);
return retval;
}
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
+ cur_speed = jtag_get_speed_khz();
if (jtag!=NULL)
{
- if ((retval=jtag->speed_div(jtag_speed, &speed_khz))!=ERROR_OK)
+ if ((retval=jtag->speed_div(jtag_speed, &cur_speed))!=ERROR_OK)
return retval;
}
- if (speed_khz==0)
- {
+ if (cur_speed)
+ command_print(cmd_ctx, "%d kHz", cur_speed);
+ else
command_print(cmd_ctx, "RCLK - adaptive");
- } else
- {
- command_print(cmd_ctx, "%d kHz", speed_khz);
- }
return retval;
}