static void triton_clock (urj_cable_t *cable, int tms, int tdi, int n) { int i; int trst = (PARAM_SIGNALS (cable) & URJ_POD_CS_TRST) ? 1 : 0; int sreset = (PARAM_SIGNALS (cable) & URJ_POD_CS_RESET) ? 1 : 0; tms = tms ? 1 : 0; tdi = tdi ? 1 : 0; for (i = 0; i < n; i++) { urj_tap_parport_set_data (cable->link.port, (trst << TRST) | (sreset << SRESET) | (0 << TCK) | (tms << TMS) | (tdi << TDI)); urj_tap_cable_wait (cable); urj_tap_parport_set_data (cable->link.port, (trst << TRST) | (sreset << SRESET) | (1 << TCK) | (tms << TMS) | (tdi << TDI)); urj_tap_cable_wait (cable); } PARAM_SIGNALS (cable) &= (URJ_POD_CS_TRST | URJ_POD_CS_RESET); PARAM_SIGNALS (cable) |= URJ_POD_CS_TCK; PARAM_SIGNALS (cable) |= tms ? URJ_POD_CS_TMS : 0; PARAM_SIGNALS (cable) |= tdi ? URJ_POD_CS_TDI : 0; }
static int wiggler_set_signal (urj_cable_t *cable, int mask, int val) { int prev_sigs = PRM_SIGNALS (cable); mask &= (URJ_POD_CS_TMS | URJ_POD_CS_TDI | URJ_POD_CS_TCK | URJ_POD_CS_TRST); // Only these can be modified if (mask != 0) { int sigs = (prev_sigs & ~mask) | (val & mask); PRM_TRST_LVL (cable) = ((sigs & URJ_POD_CS_TRST) ? PRM_TRST_ACT (cable) : PRM_TRST_INACT (cable)); int data = PRM_UNUSED_BITS (cable) | PRM_TRST_LVL (cable); data |= ((sigs & URJ_POD_CS_TCK) ? PRM_TCK_ACT (cable) : PRM_TCK_INACT (cable)); data |= ((sigs & URJ_POD_CS_TMS) ? PRM_TMS_ACT (cable) : PRM_TMS_INACT (cable)); data |= ((sigs & URJ_POD_CS_TDI) ? PRM_TDI_ACT (cable) : PRM_TDI_INACT (cable)); urj_tap_parport_set_data (cable->link.port, data); PRM_SIGNALS (cable) = sigs; } return prev_sigs; }
static int wiggler_init (urj_cable_t *cable) { int data; 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_UNUSED_BITS (cable)) != URJ_STATUS_OK) return URJ_STATUS_FAIL; PRM_TRST_LVL (cable) = PRM_TRST_ACT (cable) | PRM_TRST_INACT (cable); } else PRM_TRST_LVL (cable) = data & (PRM_TRST_ACT (cable) | PRM_TRST_INACT (cable)); PRM_SIGNALS (cable) = (PRM_TRST_LVL (cable) == PRM_TRST_ACT (cable)) ? URJ_POD_CS_TRST : 0; return URJ_STATUS_OK; }
static int triton_init (urj_cable_t *cable) { 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; urj_tap_parport_set_data (cable->link.port, (1 << TRST) | (1 << SRESET)); return URJ_STATUS_OK; }
static void wiggler_clock (urj_cable_t *cable, int tms, int tdi, int n) { int i; tms = tms ? 1 : 0; tdi = tdi ? 1 : 0; for (i = 0; i < n; i++) { urj_tap_parport_set_data (cable->link.port, PRM_TRST_LVL (cable) | PRM_TCK_INACT (cable) | (tms ? PRM_TMS_ACT (cable) : PRM_TMS_INACT (cable)) | (tdi ? PRM_TDI_ACT (cable) : PRM_TDI_INACT (cable)) | PRM_UNUSED_BITS (cable)); urj_tap_cable_wait (cable); urj_tap_parport_set_data (cable->link.port, PRM_TRST_LVL (cable) | PRM_TCK_ACT (cable) | (tms ? PRM_TMS_ACT (cable) : PRM_TMS_INACT (cable)) | (tdi ? PRM_TDI_ACT (cable) : PRM_TDI_INACT (cable)) | PRM_UNUSED_BITS (cable)); urj_tap_cable_wait (cable); } PRM_SIGNALS (cable) &= ~(URJ_POD_CS_TDI | URJ_POD_CS_TMS); if (tms) PRM_SIGNALS (cable) |= URJ_POD_CS_TMS; if (tdi) PRM_SIGNALS (cable) |= URJ_POD_CS_TDI; }
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); 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 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)); PARAM_SIGNALS (cable) &= ~(URJ_POD_CS_TDI | URJ_POD_CS_TCK | URJ_POD_CS_TMS); urj_tap_cable_wait (cable); status = urj_tap_parport_get_status (cable->link.port); if (status == -1) return status; return (status >> TDO) & 1; }
static int triton_set_signal (urj_cable_t *cable, int mask, int val) { int prev_sigs = PARAM_SIGNALS (cable); mask &= (URJ_POD_CS_TDI | URJ_POD_CS_TCK | URJ_POD_CS_TMS | URJ_POD_CS_TRST | URJ_POD_CS_RESET); // only these can be modified if (mask != 0) { int data = 0; int sigs = (PARAM_SIGNALS (cable) & ~mask) | (val & mask); data |= (sigs & URJ_POD_CS_TDI) ? (1 << TDI) : 0; data |= (sigs & URJ_POD_CS_TCK) ? (1 << TCK) : 0; data |= (sigs & URJ_POD_CS_TMS) ? (1 << TMS) : 0; data |= (sigs & URJ_POD_CS_TRST) ? (1 << TRST) : 0; data |= (sigs & URJ_POD_CS_RESET) ? (1 << SRESET) : 0; urj_tap_parport_set_data (cable->link.port, data); PARAM_SIGNALS (cable) = sigs; } return prev_sigs; }