From 17c88df4bff6503cf7178df38c6a83c425d8cd52 Mon Sep 17 00:00:00 2001 From: Rutger Hofman Date: Tue, 5 May 2009 15:50:35 +0000 Subject: [PATCH] Introduce manifest BSBIT_DONTCARE value for bits - let the library handle the choice git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1564 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/include/urjtag/bsbit.h | 6 ++++-- urjtag/src/cmd/cmd_bit.c | 23 ++++++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/urjtag/include/urjtag/bsbit.h b/urjtag/include/urjtag/bsbit.h index dd0c06e2..37cee116 100644 --- a/urjtag/include/urjtag/bsbit.h +++ b/urjtag/include/urjtag/bsbit.h @@ -35,6 +35,8 @@ #define URJ_BSBIT_STATE_Z (-1) +#define URJ_BSBIT_DONTCARE '?' + struct urj_bsbit { int bit; @@ -54,7 +56,7 @@ struct urj_bsbit * @param bit * @param name associated signal name * @param type URJ_BSBIT_{INPUT|OUTPUT|BIDIR|CONTROL|INTERNAL} - * @param safe default (safe) value (0|1) + * @param safe default (safe) value (0|1|URJ_BSBIT_DONTCARE) * * @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error */ @@ -68,7 +70,7 @@ int urj_part_bsbit_alloc (urj_part_t *part, int bit, const char *name, * @param bit * @param name associated signal name * @param type URJ_BSBIT_{INPUT|OUTPUT|BIDIR|CONTROL|INTERNAL} - * @param safe default (safe) value (0|1) + * @param safe default (safe) value (0|1|URJ_BSBIT_DONTCARE) * @param ctrl_num control bit number * @param ctrl_val control value * @param ctrl_state control state; valid statis is only URJ_BSBIT_STATE_Z diff --git a/urjtag/src/cmd/cmd_bit.c b/urjtag/src/cmd/cmd_bit.c index de8b2d79..6295cea8 100644 --- a/urjtag/src/cmd/cmd_bit.c +++ b/urjtag/src/cmd/cmd_bit.c @@ -134,15 +134,28 @@ cmd_bit_run (urj_chain_t *chain, char *params[]) "bit", command); return -1; } - safe = (params[3][0] == '1'); + switch (params[3][0]) + { + case '0': + case '1': + safe = params[3][0] - '0'; + break; + case '?': + safe = URJ_BSBIT_DONTCARE; + break; + default: + printf (_("%s: invalid default value for command '%s'\n"), + "bit", command); + return -1; + } /* test for control bit */ if (urj_cmd_params (params) == 5) { if (urj_part_bsbit_alloc (part, bit, params[4], type, safe) != URJ_STATUS_OK) { - printf ("%s for command '%s'\n", urj_error_describe(), command); - urj_error_get_reset(); + printf ("in command '%s'\n", command); + urj_error_reset(); return 1; } @@ -176,8 +189,8 @@ cmd_bit_run (urj_chain_t *chain, char *params[]) control, control_value, control_state) != URJ_STATUS_OK) { - printf ("%s for command '%s'\n", urj_error_describe(), command); - urj_error_get_reset(); + printf ("in command '%s'\n", command); + urj_error_reset(); return 1; } }