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
master
Rutger Hofman 16 years ago
parent 8d1a8d91af
commit 17c88df4bf

@ -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

@ -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;
}
}

Loading…
Cancel
Save