summaryrefslogtreecommitdiff
path: root/src/svf
diff options
context:
space:
mode:
authorJon Povey <jon.povey@racelogic.co.uk>2011-01-02 23:52:48 +0900
committerØyvind Harboe <oyvind.harboe@zylin.com>2011-01-02 20:02:16 +0100
commitd356034f03eb60fd4e8b3537bd979d9e7e5e25f8 (patch)
treefea0d9809e30d584cb26c89a1f412346fc771f93 /src/svf
parent18a5a46bd94f6e224151ba62c0b9094a96b7387a (diff)
downloadopenocd+libswd-d356034f03eb60fd4e8b3537bd979d9e7e5e25f8.tar.gz
openocd+libswd-d356034f03eb60fd4e8b3537bd979d9e7e5e25f8.tar.bz2
openocd+libswd-d356034f03eb60fd4e8b3537bd979d9e7e5e25f8.tar.xz
openocd+libswd-d356034f03eb60fd4e8b3537bd979d9e7e5e25f8.zip
svf: implement sleep for RUNTEST min_time
Signed-off-by: Jon Povey <jon.povey@racelogic.co.uk> min_time was effectively ignored, I needed it to program a Lattice MachXO which uses a RUNTEST to wait for an erase operation, amongst other things. With this patch pauses happen and I can program the device with an SVF generated in LSC ispVM (with "Rev D Standard" checked to suppress nonstandard LOOP statements)
Diffstat (limited to 'src/svf')
-rw-r--r--src/svf/svf.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/src/svf/svf.c b/src/svf/svf.c
index a6f2f6f3..53994a2d 100644
--- a/src/svf/svf.c
+++ b/src/svf/svf.c
@@ -1478,47 +1478,45 @@ static int svf_run_command(struct command_context *cmd_ctx, char *cmd_str)
}
i += 2;
}
- // calculate run_count
- if ((0 == run_count) && (min_time > 0))
- {
- run_count = min_time * svf_para.frequency;
- }
+
// all parameter should be parsed
if (i == num_of_argu)
{
- if (run_count > 0)
- {
- // run_state and end_state is checked to be stable state
- // TODO: do runtest
#if 1
- /* FIXME handle statemove failures */
- int retval;
+ /* FIXME handle statemove failures */
+ int retval;
+ uint32_t min_usec = 1000000 * min_time;
- // enter into run_state if necessary
- if (cmd_queue_cur_state != svf_para.runtest_run_state)
- {
- retval = svf_add_statemove(svf_para.runtest_run_state);
- }
+ // enter into run_state if necessary
+ if (cmd_queue_cur_state != svf_para.runtest_run_state)
+ {
+ retval = svf_add_statemove(svf_para.runtest_run_state);
+ }
- // call jtag_add_clocks
+ // add clocks and/or min wait
+ if (run_count > 0) {
jtag_add_clocks(run_count);
+ }
- // move to end_state if necessary
- if (svf_para.runtest_end_state != svf_para.runtest_run_state)
- {
- retval = svf_add_statemove(svf_para.runtest_end_state);
- }
+ if (min_usec > 0) {
+ jtag_add_sleep(min_usec);
+ }
+
+ // move to end_state if necessary
+ if (svf_para.runtest_end_state != svf_para.runtest_run_state)
+ {
+ retval = svf_add_statemove(svf_para.runtest_end_state);
+ }
#else
- if (svf_para.runtest_run_state != TAP_IDLE)
- {
- LOG_ERROR("cannot runtest in %s state",
- tap_state_name(svf_para.runtest_run_state));
- return ERROR_FAIL;
- }
+ if (svf_para.runtest_run_state != TAP_IDLE)
+ {
+ LOG_ERROR("cannot runtest in %s state",
+ tap_state_name(svf_para.runtest_run_state));
+ return ERROR_FAIL;
+ }
- jtag_add_runtest(run_count, svf_para.runtest_end_state);
+ jtag_add_runtest(run_count, svf_para.runtest_end_state);
#endif
- }
}
else
{