diff --git a/jtag/src/cmd/dr.c b/jtag/src/cmd/dr.c index 077d1736..6dfa18f0 100644 --- a/jtag/src/cmd/dr.c +++ b/jtag/src/cmd/dr.c @@ -54,15 +54,6 @@ cmd_dr_run( char *params[] ) return 1; } - if (params[1]) { - if (strcasecmp( params[1], "in" ) == 0) - dir = 0; - else if (strcasecmp( params[1], "out" ) == 0) - dir = 1; - else - return -1; - } - if (chain->parts->parts[chain->active_part]->active_instruction == NULL) { printf( _("%s: part without active instruction\n"), "dr" ); return 1; @@ -72,6 +63,30 @@ cmd_dr_run( char *params[] ) return 1; } + if (params[1]) { + if (strcmp( params[1], "in" ) == 0) + dir = 0; + else if (strcmp( params[1], "out" ) == 0) + dir = 1; + else { + unsigned int bit; + if (strspn(params[1], "01") != strlen(params[1])) { + return -1; + } + + r = chain->parts->parts[chain->active_part]->active_instruction->data_register->in; + if (r->len != strlen(params[1])) { + printf( _("%s: register length mismatch\n"), "dr" ); + return 1; + } + for (bit = 0; params[1][bit]; bit++) { + r->data[r->len - 1 - bit] = (params[1][bit] == '1'); + } + + dir = 0; + } + } + if (dir) r = chain->parts->parts[chain->active_part]->active_instruction->data_register->out; else