]> git.sur5r.net Git - openocd/commitdiff
Add accessors for speed_khz; use them in jim command handler.
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 5 Jun 2009 00:02:00 +0000 (00:02 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 5 Jun 2009 00:02:00 +0000 (00:02 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@2058 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/jtag/jtag.c
src/jtag/jtag.h

index 6f65a3ec896367a25b12f344e3ec604c3f1ba35d..28883c7c5c0cfd72d98771e2b53c5df9b505e5a3 100644 (file)
@@ -1659,7 +1659,7 @@ int jtag_interface_init(struct command_context_s *cmd_ctx)
        }
        if(hasKHz)
        {
-               jtag_interface->khz(speed_khz, &jtag_speed);
+               jtag_interface->khz(jtag_get_speed_khz(), &jtag_speed);
                hasKHz = false;
        }
 
@@ -1772,6 +1772,15 @@ int jtag_init(struct command_context_s *cmd_ctx)
        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");
@@ -2130,17 +2139,17 @@ static int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd,
        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;
                        }
 
@@ -2157,20 +2166,18 @@ static int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd,
        {
                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;
 
 }
index 8f427fbe4b8eff87f4b405e4926588a247943db1..ba82df7c2c70ecaf30f8f96d1cdd1df593b27dc1 100644 (file)
@@ -642,5 +642,7 @@ extern int jtag_add_statemove(tap_state_t goal_state);
 
 /// @returns the number of times the scan queue has been flushed
 int jtag_get_flush_queue_count(void);
+void jtag_set_speed_khz(unsigned speed);
+unsigned jtag_get_speed_khz(void);
 
 #endif /* JTAG_H */