In USB cable open(), parport set/get_data/get_status/set_control, return/handle URJ_STATUS_OK/FAIL more correctly

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1642 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Rutger Hofman 16 years ago
parent 2d6c042179
commit 03b5d454ee

@ -1,3 +1,8 @@
2009-06-04 Rutger Hofman <rfhh>
* src/tap/cable/*.c, src/tap/parport/*.c, src/tap/usbconn/*.c: return/handle
URJ_STATUS_OK/FAIL more correctly
2009-06-02 Arnim Laeuger <arniml>
* src/cmd/cmd_initbus.c: use separate index variable for driver selection

@ -43,8 +43,6 @@
#include <urjtag/tap.h>
#include <urjtag/cable.h>
#undef VERBOSE
/* @@@@ RFHH stick these into a (or many) .h files */
extern urj_cable_driver_t urj_tap_cable_arcom_driver;
extern urj_cable_driver_t urj_tap_cable_byteblaster_driver;

@ -54,19 +54,20 @@ arcom_init (urj_cable_t *cable)
{
int data;
if (urj_tap_parport_open (cable->link.port))
return -1;
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
if ((data = urj_tap_parport_get_data (cable->link.port)) < 0)
{
if (urj_tap_parport_set_data (cable->link.port, 1 << TRST))
return -1;
if (urj_tap_parport_set_data (cable->link.port,
1 << TRST) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST;
}
else
PARAM_SIGNALS (cable) = ((data >> TRST) && 1) ? URJ_POD_CS_TRST : 0;
return 0;
return URJ_STATUS_OK;
}
static void
@ -100,6 +101,7 @@ static int
arcom_get_tdo (urj_cable_t *cable)
{
int trst = (PARAM_SIGNALS (cable) & URJ_POD_CS_TRST) ? 1 : 0;
int status;
urj_tap_parport_set_data (cable->link.port, (trst << TRST) | (0 << TCK));
PARAM_SIGNALS (cable) &=
@ -107,7 +109,11 @@ arcom_get_tdo (urj_cable_t *cable)
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) >> TDO) & 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return status;
return (status >> TDO) & 1;
}
static int

@ -71,30 +71,47 @@ static int
byteblaster_init (urj_cable_t *cable)
{
int BB_II = 0;
int status;
if (urj_tap_parport_open (cable->link.port))
return -1;
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST;
/* check if a ByteBlaster or ByteBlasterMV is connected */
urj_tap_parport_set_data (cable->link.port, 1 << BB_CHECK);
if (!((urj_tap_parport_get_status (cable->link.port) >> BB_PRESENT) & 1))
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return URJ_STATUS_FAIL;
if (!((status >> BB_PRESENT) & 1))
BB_II = 1;
urj_tap_parport_set_data (cable->link.port, 0);
if ((urj_tap_parport_get_status (cable->link.port) >> BB_PRESENT) & 1)
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return URJ_STATUS_FAIL;
if ((status >> BB_PRESENT) & 1)
BB_II = 1;
/* check if the power supply is ok (only for ByteBlaster II) */
/* if no ByteBlaster at all is connected this check will fail, too */
if ((BB_II)
&& ((urj_tap_parport_get_status (cable->link.port) >> VCC_OK_N) & 1))
return -1;
if (BB_II)
{
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return URJ_STATUS_FAIL;
if ((status >> VCC_OK_N) & 1)
{
urj_error_set (URJ_ERROR_ILLEGAL_STATE, "Power supply not OK");
return URJ_STATUS_FAIL;
}
}
/* Enable ByteBlaster */
urj_tap_parport_set_control (cable->link.port, BB_ENABLE);
if (urj_tap_parport_set_control (cable->link.port,
BB_ENABLE) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
return 0;
return URJ_STATUS_OK;
}
static void
@ -125,12 +142,18 @@ static int
byteblaster_get_tdo (urj_cable_t *cable)
{
urj_tap_parport_set_data (cable->link.port, 0 << TCK);
int status;
PARAM_SIGNALS (cable) &=
~(URJ_POD_CS_TDI | URJ_POD_CS_TCK | URJ_POD_CS_TMS);
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) >> TDO) & 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return status;
return (status >> TDO) & 1;
}
static int

@ -59,12 +59,12 @@
static int
dlc5_init (urj_cable_t *cable)
{
if (urj_tap_parport_open (cable->link.port))
return -1;
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST;
return 0;
return URJ_STATUS_OK;
}
static void
@ -78,12 +78,12 @@ dlc5_clock (urj_cable_t *cable, int tms, int tdi, int n)
for (i = 0; i < n; i++)
{
urj_tap_parport_set_data (cable->link.port,
(1 << PROG) | (0 << TCK) | (tms << TMS) |
(tdi << TDI));
(1 << PROG) | (0 << TCK) | (tms << TMS)
| (tdi << TDI));
urj_tap_cable_wait (cable);
urj_tap_parport_set_data (cable->link.port,
(1 << PROG) | (1 << TCK) | (tms << TMS) |
(tdi << TDI));
(1 << PROG) | (1 << TCK) | (tms << TMS)
| (tdi << TDI));
urj_tap_cable_wait (cable);
}
@ -96,13 +96,19 @@ dlc5_clock (urj_cable_t *cable, int tms, int tdi, int n)
static int
dlc5_get_tdo (urj_cable_t *cable)
{
int status;
urj_tap_parport_set_data (cable->link.port, (1 << PROG) | (0 << TCK));
PARAM_SIGNALS (cable) &=
~(URJ_POD_CS_TDI | URJ_POD_CS_TCK | URJ_POD_CS_TMS);
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) >> TDO) & 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return status;
return (status >> TDO) & 1;
}
static int

@ -54,19 +54,20 @@ ea253_init (urj_cable_t *cable)
{
int data;
if (urj_tap_parport_open (cable->link.port))
return -1;
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
if ((data = urj_tap_parport_get_data (cable->link.port)) < 0)
{
if (urj_tap_parport_set_data (cable->link.port, 1 << TRST))
return -1;
if (urj_tap_parport_set_data (cable->link.port,
1 << TRST) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST;
}
else
PARAM_SIGNALS (cable) = ((data >> TRST) && 1) ? URJ_POD_CS_TRST : 0;
return 0;
return URJ_STATUS_OK;
}
static void
@ -100,6 +101,7 @@ static int
ea253_get_tdo (urj_cable_t *cable)
{
int trst = (PARAM_SIGNALS (cable) & URJ_POD_CS_TRST) ? 1 : 0;
int status;
urj_tap_parport_set_data (cable->link.port, (trst << TRST) | (0 << TCK));
PARAM_SIGNALS (cable) &=
@ -107,7 +109,11 @@ ea253_get_tdo (urj_cable_t *cable)
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) >> TDO) & 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return status;
return (status >> TDO) & 1;
}
static int

@ -56,19 +56,20 @@ ei012_init (urj_cable_t *cable)
{
int data;
if (urj_tap_parport_open (cable->link.port))
return -1;
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
if ((data = urj_tap_parport_get_data (cable->link.port)) < 0)
{
if (urj_tap_parport_set_data (cable->link.port, 1 << TRST))
return -1;
if (urj_tap_parport_set_data (cable->link.port,
1 << TRST) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST;
}
else
PARAM_SIGNALS (cable) = ((data >> TRST) && 1) ? URJ_POD_CS_TRST : 0;
return 0;
return URJ_STATUS_OK;
}
static void
@ -83,12 +84,12 @@ ei012_clock (urj_cable_t *cable, int tms, int tdi, int n)
for (i = 0; i < n; i++)
{
urj_tap_parport_set_data (cable->link.port,
(trst << TRST) | (0 << TCK) | (tms << TMS) |
(tdi << TDI));
(trst << TRST) | (0 << TCK) | (tms << TMS)
| (tdi << TDI));
urj_tap_cable_wait (cable);
urj_tap_parport_set_data (cable->link.port,
(trst << TRST) | (1 << TCK) | (tms << TMS) |
(tdi << TDI));
(trst << TRST) | (1 << TCK) | (tms << TMS)
| (tdi << TDI));
urj_tap_cable_wait (cable);
}
@ -102,6 +103,7 @@ static int
ei012_get_tdo (urj_cable_t *cable)
{
int trst = (PARAM_SIGNALS (cable) & URJ_POD_CS_TRST) ? 1 : 0;
int status;
urj_tap_parport_set_data (cable->link.port, (trst << TRST) | (0 << TCK));
PARAM_SIGNALS (cable) &=
@ -109,7 +111,11 @@ ei012_get_tdo (urj_cable_t *cable)
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) >> TDO) & 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return status;
return (status >> TDO) & 1;
}
static int

@ -274,7 +274,7 @@ ft2232_generic_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* safe default values */
@ -288,9 +288,8 @@ ft2232_generic_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_push (cmd_root,
params->low_byte_value | BITMASK_TMS);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK | BITMASK_TDI |
BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
/* Set Data Bits High Byte */
params->high_byte_value = 0;
@ -317,7 +316,7 @@ ft2232_jtagkey_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* static low byte value and direction:
@ -332,9 +331,8 @@ ft2232_jtagkey_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_push (cmd_root,
params->low_byte_value | BITMASK_TMS);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK | BITMASK_TDI |
BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
/* Set Data Bits High Byte
default:
@ -372,7 +370,7 @@ ft2232_armusbocd_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* static low byte value and direction:
@ -387,9 +385,8 @@ ft2232_armusbocd_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_push (cmd_root,
params->low_byte_value | BITMASK_TMS);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK | BITMASK_TDI |
BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
/* Set Data Bits High Byte
default:
@ -427,7 +424,7 @@ ft2232_gnice_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* safe default values */
@ -441,9 +438,8 @@ ft2232_gnice_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_push (cmd_root,
params->low_byte_value | BITMASK_TMS);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK | BITMASK_TDI |
BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
/* Set Data Bits High Byte */
params->high_byte_value = BITMASK_GNICE_nTRST;
@ -473,7 +469,7 @@ ft2232_oocdlinks_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* static low byte value and direction */
@ -487,9 +483,8 @@ ft2232_oocdlinks_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_push (cmd_root,
params->low_byte_value | BITMASK_TMS);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK | BITMASK_TDI |
BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
/* Set Data Bits High Byte
default:
@ -527,7 +522,7 @@ ft2232_turtelizer2_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* static low byte value and direction:
@ -544,9 +539,8 @@ ft2232_turtelizer2_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_push (cmd_root,
params->low_byte_value | BITMASK_TMS);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK | BITMASK_TDI |
BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
/* Set Data Bits High Byte
default:
@ -577,7 +571,7 @@ ft2232_usbtojtagif_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* static low byte value and direction:
@ -595,9 +589,8 @@ ft2232_usbtojtagif_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_push (cmd_root,
params->low_byte_value | BITMASK_TMS);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK | BITMASK_TDI |
BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
/* Set Data Bits High Byte
default:
@ -631,7 +624,7 @@ ft2232_signalyzer_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* static low byte value and direction:
@ -648,9 +641,8 @@ ft2232_signalyzer_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_push (cmd_root,
params->low_byte_value | BITMASK_TMS);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK | BITMASK_TDI |
BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
/* Set Data Bits High Byte */
params->high_byte_value = 0;
@ -677,7 +669,7 @@ ft2232_flyswatter_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* static low byte value and direction:
@ -694,9 +686,8 @@ ft2232_flyswatter_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_push (cmd_root,
params->low_byte_value | BITMASK_TMS);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK | BITMASK_TDI |
BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
/* Set Data Bits High Byte */
/* Turn LED2 on */
@ -724,7 +715,7 @@ ft2232_usbscarab2_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* Check if cable is connected to the target and the target is powered on */
@ -751,9 +742,8 @@ ft2232_usbscarab2_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_push (cmd_root,
params->low_byte_value | BITMASK_TMS);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK | BITMASK_TDI |
BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
/* Set Data Bits High Byte */
/* nLED=0 */
@ -1310,9 +1300,8 @@ ft2232_set_signal_schedule (params_t *params, int mask, int val,
(params->
low_byte_value | low_or) ^ low_xor);
urj_tap_cable_cx_cmd_push (cmd_root,
params->
low_byte_dir | BITMASK_TCK |
BITMASK_TDI | BITMASK_TMS);
params->low_byte_dir | BITMASK_TCK
| BITMASK_TDI | BITMASK_TMS);
}
if (set_high)

@ -50,9 +50,9 @@ jim_cable_connect (urj_cable_t *cable, const urj_param_t *params[])
jim_cable_params_t *cable_params;
urj_jim_state_t *s;
if (urj_param_num (params) < 1)
if (urj_param_num (params) > 0)
{
urj_error_set (URJ_ERROR_SYNTAX, _("not enough arguments"));
urj_error_set (URJ_ERROR_SYNTAX, _("too many arguments"));
return URJ_STATUS_FAIL;
}

@ -177,6 +177,7 @@ jlink_get_status (urj_usbconn_libusb_param_t *params)
if (result == 8)
{
int vref = data->usb_in_buffer[0] + (data->usb_in_buffer[1] << 8);
// @@@@ RFHH how can we handle this gracefully in liburjtag?
urj_log (URJ_LOG_LEVEL_NORMAL,
"Vref = %d.%d TCK=%d TDI=%d TDO=%d TMS=%d TRES=%d TRST=%d\n",
vref / 1000, vref % 1000,
@ -187,15 +188,17 @@ jlink_get_status (urj_usbconn_libusb_param_t *params)
data->usb_in_buffer[6], data->usb_in_buffer[7]);
if (vref < 1500)
{
urj_log (URJ_LOG_LEVEL_ERROR,
"Vref too low. Possibly the target isn't powered or disconnected?\n");
result = -15;
urj_error_set (URJ_ERROR_USB,
"Vref too low. Possibly the target isn't powered or disconnected?");
result = -1;
}
}
else
{
urj_log (URJ_LOG_LEVEL_ERROR,
"J-Link command 0x07 (get status) failed (%d)\n", result);
urj_error_set (URJ_ERROR_USB,
"J-Link command 0x07 (get status) failed (%d)\n",
result);
result = -1;
}
return result;
@ -425,7 +428,7 @@ jlink_init (urj_cable_t *cable)
}
data = params->data;
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
jlink_tap_init (data);
@ -443,6 +446,7 @@ jlink_init (urj_cable_t *cable)
result = jlink_get_status (params);
if (result < 0)
{
// retain error state
urj_log (URJ_LOG_LEVEL_ERROR,
"Resetting J-Link. Please retry the cable command.\n");
usb_reset (params->handle);

@ -66,7 +66,7 @@
static int
keithkoep_init (urj_cable_t *cable)
{
if (urj_tap_parport_open (cable->link.port))
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
urj_tap_parport_set_control (cable->link.port, 1 << TRST);
@ -102,13 +102,19 @@ keithkoep_clock (urj_cable_t *cable, int tms, int tdi, int n)
static int
keithkoep_get_tdo (urj_cable_t *cable)
{
int status;
urj_tap_parport_set_data (cable->link.port, 0 << TCK);
PARAM_SIGNALS (cable) &=
~(URJ_POD_CS_TDI | URJ_POD_CS_TCK | URJ_POD_CS_TMS);
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) >> TDO) & 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return status;
return (status >> TDO) & 1;
}
static int
@ -133,9 +139,8 @@ keithkoep_set_signal (urj_cable_t *cable, int mask, int val)
if ((mask & URJ_POD_CS_TRST) != 0)
{
urj_tap_parport_set_control (cable->link.port,
(sigs & URJ_POD_CS_TRST) ? (1 <<
TRST) :
0);
(sigs & URJ_POD_CS_TRST)
? (1 << TRST) : 0);
}
PARAM_SIGNALS (cable) = sigs;
}

@ -56,13 +56,13 @@ lattice_init (urj_cable_t *cable)
{
int data;
if (urj_tap_parport_open (cable->link.port))
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
if ((data = urj_tap_parport_get_data (cable->link.port)) < 0)
{
if (urj_tap_parport_set_data (cable->link.port, 1 << TRST)
!= URJ_STATUS_OK)
if (urj_tap_parport_set_data (cable->link.port,
1 << TRST) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST;
}
@ -103,6 +103,7 @@ static int
lattice_get_tdo (urj_cable_t *cable)
{
int trst = (PARAM_SIGNALS (cable) & URJ_POD_CS_TRST) ? 1 : 0;
int status;
urj_tap_parport_set_data (cable->link.port, (trst << TRST) | (0 << TCK));
PARAM_SIGNALS (cable) &=
@ -110,7 +111,11 @@ lattice_get_tdo (urj_cable_t *cable)
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) >> TDO) & 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return status;
return (status >> TDO) & 1;
}
static int

@ -64,7 +64,7 @@
static int
mpcbdm_init (urj_cable_t *cable)
{
if (urj_tap_parport_open (cable->link.port))
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
urj_tap_parport_set_control (cable->link.port, 0);
@ -101,12 +101,18 @@ static int
mpcbdm_get_tdo (urj_cable_t *cable)
{
urj_tap_parport_set_data (cable->link.port, 0 << TCK);
int status;
PARAM_SIGNALS (cable) &=
~(URJ_POD_CS_TDI | URJ_POD_CS_TCK | URJ_POD_CS_TMS);
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) >> TDO) & 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return status;
return (status >> TDO) & 1;
}
static int

@ -69,7 +69,7 @@
static int
triton_init (urj_cable_t *cable)
{
if (urj_tap_parport_open (cable->link.port))
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST | URJ_POD_CS_RESET;
@ -111,6 +111,7 @@ triton_get_tdo (urj_cable_t *cable)
{
int trst = (PARAM_SIGNALS (cable) & URJ_POD_CS_TRST) ? 1 : 0;
int sreset = (PARAM_SIGNALS (cable) & URJ_POD_CS_RESET) ? 1 : 0;
int status;
urj_tap_parport_set_data (cable->link.port,
(trst << TRST) | (sreset << SRESET) | (0 << TCK));
@ -119,7 +120,11 @@ triton_get_tdo (urj_cable_t *cable)
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) >> TDO) & 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return status;
return (status >> TDO) & 1;
}
static int

@ -155,7 +155,7 @@ ts7800_connect (urj_cable_t *cable, const urj_param_t *params[])
{
ts7800_params_t *cable_params;
if (urj_param_num (params) != 1)
if (urj_param_num (params) > 0)
{
urj_error_set (URJ_ERROR_SYNTAX,
_("This cable type does not accept parameters"));
@ -200,7 +200,7 @@ ts7800_init (urj_cable_t *cable)
{
ts7800_params_t *p = cable->params;
if (ts7800_gpio_open (cable))
if (ts7800_gpio_open (cable) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
p->signals = URJ_POD_CS_TRST;

@ -114,7 +114,7 @@ usbblaster_init (urj_cable_t *cable)
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
urj_tap_cable_cx_cmd_queue (cmd_root, 0);

@ -198,7 +198,7 @@ ep9307_connect (urj_cable_t *cable, const urj_param_t *params[])
{
ep9307_params_t *cable_params;
if (urj_param_num (params) != 1)
if (urj_param_num (params) != 0)
{
urj_error_set (URJ_ERROR_SYNTAX,
_("This cable type does not accept parameters"));
@ -235,7 +235,7 @@ ep9307_init (urj_cable_t *cable)
{
ep9307_params_t *p = cable->params;
if (ep9307_gpio_open (cable))
if (ep9307_gpio_open (cable) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
ep9307_gpio_write (cable, 1 << TRST);

@ -272,14 +272,14 @@ wiggler_init (urj_cable_t *cable)
{
int data;
if (urj_tap_parport_open (cable->link.port))
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return -1;
if ((data = urj_tap_parport_get_data (cable->link.port)) < 0)
{
if (urj_tap_parport_set_data (cable->link.port,
(PRM_TRST_ACT (cable)
| PRM_TRST_INACT (cable))
PRM_TRST_ACT (cable)
| PRM_TRST_INACT (cable)
| PRM_UNUSED_BITS (cable))
!= URJ_STATUS_OK)
return URJ_STATUS_FAIL;
@ -319,7 +319,7 @@ wiggler_clock (urj_cable_t *cable, int tms, int tdi, int n)
| PRM_TCK_ACT (cable)
| (tms ? PRM_TMS_ACT (cable)
: PRM_TMS_INACT (cable))
| (tdi ? PRM_TDI_ACT (cable)
| (tdi ? PRM_TDI_ACT (cable)
: PRM_TDI_INACT (cable))
| PRM_UNUSED_BITS (cable));
urj_tap_cable_wait (cable);
@ -335,14 +335,19 @@ wiggler_clock (urj_cable_t *cable, int tms, int tdi, int n)
static int
wiggler_get_tdo (urj_cable_t *cable)
{
int status;
urj_tap_parport_set_data (cable->link.port, PRM_TRST_LVL (cable) |
PRM_TCK_INACT (cable) |
PRM_UNUSED_BITS (cable));
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) &
(PRM_TDO_ACT (cable) | PRM_TDO_INACT (cable))) ^
PRM_TDO_ACT (cable) ? 0 : 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return -1;
return (status & (PRM_TDO_ACT (cable) | PRM_TDO_INACT (cable)))
^ PRM_TDO_ACT (cable) ? 0 : 1;
}
static int

@ -70,7 +70,7 @@ wiggler2_init (urj_cable_t *cable)
{
int data;
if (urj_tap_parport_open (cable->link.port))
if (urj_tap_parport_open (cable->link.port) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
// TODO: CPU_RESET bit is set to zero here and can't be changed afterwards
@ -121,6 +121,7 @@ static int
wiggler2_get_tdo (urj_cable_t *cable)
{
int trst = (PARAM_SIGNALS (cable) & URJ_POD_CS_TRST) ? 1 : 0;
int status;
urj_tap_parport_set_data (cable->link.port,
(trst << TRST) | (0 << TCK) | UNUSED_BITS);
@ -129,7 +130,11 @@ wiggler2_get_tdo (urj_cable_t *cable)
urj_tap_cable_wait (cable);
return (urj_tap_parport_get_status (cable->link.port) >> TDO) & 1;
status = urj_tap_parport_get_status (cable->link.port);
if (status == -1)
return status;
return (status >> TDO) & 1;
}
static int

@ -305,7 +305,7 @@ xpcu_common_init (urj_cable_t *cable)
uint16_t buf;
struct usb_dev_handle *xpcu;
if (urj_tap_usbconn_open (cable->link.usb))
if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
xpcu = ((urj_usbconn_libusb_param_t *) (cable->link.usb->params))->handle;

@ -247,9 +247,7 @@ direct_connect (const char *devname)
parport = direct_parport_alloc (port);
if (!parport)
{
return NULL;
}
return parport;
}

@ -295,7 +295,7 @@ usbconn_ftdi_connect (urj_usbconn_cable_t *template,
/* do a test open with the specified cable paramters,
alternatively we could use libusb to detect the presence of the
specified USB device */
if (usbconn_ftdi_common_open (c, URJ_LOG_LEVEL_DETAIL) != 0)
if (usbconn_ftdi_common_open (c, URJ_LOG_LEVEL_DETAIL) != URJ_STATUS_OK)
{
usbconn_ftdi_free (c);
return NULL;
@ -432,7 +432,7 @@ usbconn_ftdi_open (urj_usbconn_t *conn)
struct ftdi_context *fc = p->fc;
int r;
if (usbconn_ftdi_common_open (conn, URJ_LOG_LEVEL_NORMAL) < 0)
if (usbconn_ftdi_common_open (conn, URJ_LOG_LEVEL_NORMAL) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
r = seq_reset (fc);
@ -482,7 +482,7 @@ usbconn_ftdi_mpsse_open (urj_usbconn_t *conn)
struct ftdi_context *fc = p->fc;
int r;
if (usbconn_ftdi_common_open (conn, URJ_LOG_LEVEL_NORMAL) < 0)
if (usbconn_ftdi_common_open (conn, URJ_LOG_LEVEL_NORMAL) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
/* This sequence might seem weird and containing superfluous stuff.

Loading…
Cancel
Save