X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fjtag%2Fdrivers%2Fopendous.c;h=efb6cf256d467e0fe04f87168c95881a275808e2;hp=165bec6a08a5bf9507b4d46991b3b4665a2d2334;hb=02192f6b8c63d740a551e371441d85d59930e65c;hpb=6b6e28ff02074b5e34733f83fcab90ae0e88381f diff --git a/src/jtag/drivers/opendous.c b/src/jtag/drivers/opendous.c index 165bec6a08..efb6cf256d 100644 --- a/src/jtag/drivers/opendous.c +++ b/src/jtag/drivers/opendous.c @@ -86,9 +86,6 @@ static uint8_t usb_out_buffer[OPENDOUS_OUT_BUFFER_SIZE]; /* External interface functions */ static int opendous_execute_queue(void); -static int opendous_speed(int speed); -static int opendous_speed_div(int speed, int *khz); -static int opendous_khz(int khz, int *jtag_speed); static int opendous_init(void); static int opendous_quit(void); @@ -194,9 +191,6 @@ struct jtag_interface opendous_interface = { .name = "opendous", .commands = opendous_command_handlers, .execute_queue = opendous_execute_queue, - .speed = opendous_speed, - .speed_div = opendous_speed_div, - .khz = opendous_khz, .init = opendous_init, .quit = opendous_quit, }; @@ -276,33 +270,6 @@ static int opendous_execute_queue(void) return opendous_tap_execute(); } -/* Sets speed in kHz. */ -static int opendous_speed(int speed) -{ - if (speed <= OPENDOUS_MAX_SPEED) { - /* one day... */ - return ERROR_OK; - } else - LOG_INFO("Requested speed %dkHz exceeds maximum of %dkHz, ignored", speed, OPENDOUS_MAX_SPEED); - - return ERROR_OK; -} - -static int opendous_speed_div(int speed, int *khz) -{ - *khz = speed; - - return ERROR_OK; -} - -static int opendous_khz(int khz, int *jtag_speed) -{ - *jtag_speed = khz; - /* TODO: convert this into delay value for opendous */ - - return ERROR_OK; -} - static int opendous_init(void) { int check_cnt; @@ -422,7 +389,9 @@ void opendous_scan(int ir_scan, enum scan_type type, uint8_t *buffer, int scan_s /* Move to appropriate scan state */ opendous_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT); - opendous_state_move(); + if (tap_get_state() != tap_get_end_state()) + opendous_state_move(); + opendous_end_state(saved_end_state); /* Scan */ @@ -465,7 +434,8 @@ void opendous_simple_command(uint8_t command, uint8_t _data) DEBUG_JTAG_IO("0x%02x 0x%02x", command, _data); - usb_out_buffer[0] = (uint16_t) 2; + usb_out_buffer[0] = 2; + usb_out_buffer[1] = 0; usb_out_buffer[2] = command; usb_out_buffer[3] = _data; @@ -512,8 +482,9 @@ void opendous_tap_init(void) void opendous_tap_ensure_space(int scans, int bits) { int available_scans = MAX_PENDING_SCAN_RESULTS - pending_scan_results_length; + int available_bits = OPENDOUS_TAP_BUFFER_SIZE / 2 - tap_length; - if (scans > available_scans) + if ((scans > available_scans) || (bits > available_bits)) opendous_tap_execute(); } @@ -523,6 +494,8 @@ void opendous_tap_append_step(int tms, int tdi) unsigned char _tms = tms ? 1 : 0; unsigned char _tdi = tdi ? 1 : 0; + opendous_tap_ensure_space(0, 1); + int tap_index = tap_length / 4; int bits = (tap_length % 4) * 2; @@ -578,28 +551,28 @@ int opendous_tap_execute(void) for (j = 0, i = 0; j < byte_length;) { - int recieve; + int receive; int transmit = byte_length - j; if (transmit > OPENDOUS_MAX_TAP_TRANSMIT) { transmit = OPENDOUS_MAX_TAP_TRANSMIT; - recieve = (OPENDOUS_MAX_TAP_TRANSMIT) / 2; + receive = (OPENDOUS_MAX_TAP_TRANSMIT) / 2; usb_out_buffer[2] = JTAG_CMD_TAP_OUTPUT; } else { usb_out_buffer[2] = JTAG_CMD_TAP_OUTPUT | ((tap_length % 4) << 4); - recieve = (transmit + 1) / 2; + receive = (transmit + 1) / 2; } usb_out_buffer[0] = (transmit + 1) & 0xff; usb_out_buffer[1] = ((transmit + 1) >> 8) & 0xff; memmove(usb_out_buffer + 3, tms_buffer + j, transmit); - result = opendous_usb_message(opendous_jtag_handle, 3 + transmit, recieve); - if (result != recieve) { - LOG_ERROR("opendous_tap_execute, wrong result %d, expected %d", result, recieve); + result = opendous_usb_message(opendous_jtag_handle, 3 + transmit, receive); + if (result != receive) { + LOG_ERROR("opendous_tap_execute, wrong result %d, expected %d", result, receive); return ERROR_JTAG_QUEUE_FAILED; } - memmove(tdo_buffer + i, usb_in_buffer, recieve); - i += recieve; + memmove(tdo_buffer + i, usb_in_buffer, receive); + i += receive; j += transmit; }