uint32_t part_emudat_get_done (urj_chain_t *chain, int n, int exit) { urj_part_t *part; urj_tap_register_t *r; uint64_t value; int i; urj_parts_t *ps; ps = chain->parts; for (i = 0; i < ps->len; i++) { urj_tap_shift_register_output (chain, ps->parts[i]->active_instruction->data_register->in, ps->parts[i]->active_instruction->data_register->out, (i + 1) == ps->len ? URJ_CHAIN_EXITMODE_UPDATE : URJ_CHAIN_EXITMODE_SHIFT); } part = chain->parts->parts[n]; r = part->active_instruction->data_register->out; value = emudat_value (r); /* TODO Is it good to check EMUDOF here if it's available? */ return value; }
int urj_tap_chain_shift_instructions_mode (urj_chain_t *chain, int capture_output, int capture, int chain_exit) { int i; urj_parts_t *ps; if (!chain || !chain->parts) { urj_error_set (URJ_ERROR_NO_CHAIN, "no chain or no part"); return URJ_STATUS_FAIL; } ps = chain->parts; for (i = 0; i < ps->len; i++) { if (ps->parts[i]->active_instruction == NULL) { urj_error_set (URJ_ERROR_NO_ACTIVE_INSTRUCTION, _("Part %d without active instruction"), i); return URJ_STATUS_FAIL; } } if (capture) urj_tap_capture_ir (chain); /* new implementation: split into defer + retrieve part shift the data register of each part in the chain one by one */ for (i = 0; i < ps->len; i++) { urj_tap_defer_shift_register (chain, ps->parts[i]->active_instruction->value, capture_output ? ps->parts[i]->active_instruction->out : NULL, (i + 1) == ps->len ? chain_exit : URJ_CHAIN_EXITMODE_SHIFT); } if (capture_output) { for (i = 0; i < ps->len; i++) { urj_tap_shift_register_output (chain, ps->parts[i]->active_instruction->value, ps->parts[i]->active_instruction->out, (i + 1) == ps->len ? chain_exit : URJ_CHAIN_EXITMODE_SHIFT); } } else { /* give the cable driver a chance to flush if it's considered useful */ urj_tap_cable_flush (chain->cable, URJ_TAP_CABLE_TO_OUTPUT); } return URJ_STATUS_OK; }