Compare commits

..

No commits in common. "f9cafce309f3b5eea3bb0d0f4b1fa1a70e53728a" and "ca814c5d13a6a233edbf86d195356d37a2ad17c2" have entirely different histories.

3 changed files with 21 additions and 28 deletions

View file

@ -483,7 +483,7 @@ int altera_set_register(struct command *cmd, const struct command_par *par,
}
if (e)
return parser_error_message(cmd, e);
if (how & alt_cmd_save)
if (!e && how & alt_cmd_save)
ssp_response = r.u;
const char *fmt;
int ccsize = cc&0xffff4000 ? 8 : 4;

45
dorn.c
View file

@ -37,34 +37,30 @@ static const struct keywords dorn_trigger_kw[] = {
int dorn_trigger(struct command *cmd, const struct command_par *par)
{
unsigned int a = (unsigned int)par->par;
error_msg_t e = parse_index(cmd, &a, 3, 11, optional_expression | optional_in_brackets);
error_msg_t e = parse_index(cmd, &a, 3, 11, 1);
if (e)
return parser_error_message(cmd, e);
return altera_set_register(cmd, par, dorn_trigger_kw, 0, a, "trigger");
}
static inline
static
error_msg_t parse_channel(struct command *cmd, unsigned int *a, int c, int m, int b)
{
error_msg_t e = parse_index(cmd, a, 3, 11,
optional_expression | optional_close | optional_in_brackets);
error_msg_t e = parse_index(cmd, a, 3, 11, 1);
if (!e)
e = parse_index(cmd, a, 63, c,
optional_brackets | (m ? optional_close : 0) | optional_open);
e = parse_index(cmd, a, 63, c, 2);
if (!e && m)
e = parse_index(cmd, a, m, b,
optional_brackets | optional_open);
e = parse_index(cmd, a, m, b, 2);
return e;
}
int dorn_l1(struct command *cmd, const struct command_par *par)
{
unsigned int how = (unsigned int)par->par;
unsigned int a = how & 0xffff;
unsigned int a = (unsigned int)par->par;
error_msg_t e = parse_channel(cmd, &a, 0, 0, 0);
if (e)
return parser_error_message(cmd, e);
return altera_set_register(cmd, par, 0, how, a, "thres");
return altera_set_register(cmd, par, 0, alt_cmd_inj, a, "thres");
}
static const
@ -76,36 +72,33 @@ struct keywords dorn_l2_kw[] = {
int dorn_l2(struct command *cmd, const struct command_par *par)
{
unsigned int how = (unsigned int)par->par;
unsigned int a = how & 0xffff;
unsigned int a = (unsigned int)par->par;
error_msg_t e = parse_channel(cmd, &a, 4, 7, 1);
if (e)
return parser_error_message(cmd, e);
return altera_set_register(cmd, par, dorn_l2_kw, how, a, "filter");
return altera_set_register(cmd, par, dorn_l2_kw, alt_cmd_inj, a, "filter");
}
int dorn_l3(struct command *cmd, const struct command_par *par)
{
unsigned int how = (unsigned int)par->par;
unsigned int a = how & 0xffff;
unsigned int a = (unsigned int)par->par;
error_msg_t e = parse_channel(cmd, &a, 2, 3, 0);
if (e)
return parser_error_message(cmd, e);
return altera_set_register(cmd, par, 0, how, a, "banana");
return altera_set_register(cmd, par, 0, alt_cmd_inj, a, "banana");
}
static const struct keywords dorn_commands[] = {
CMD_KW("fifo", dorn_fifo, 255, (void*)(0xa080)),
CMD_KW("enable", dorn_trigger, 255, (void*)(0xa008)),
CMD_KW("thres", dorn_l1, 255, (void*)(0xe040|alt_cmd_inj)),
CMD_KW("l1", dorn_l1, 255, (void*)(0xe040|alt_cmd_inj)),
CMD_KW("filter", dorn_l2, 255, (void*)(0xe400|alt_cmd_inj)),
CMD_KW("l2", dorn_l2, 255, (void*)(0xe400|alt_cmd_inj)),
CMD_KW("a", dorn_l2, 255, (void*)(0xe400|alt_cmd_inj)),
CMD_KW("b", dorn_l2, 255, (void*)(0xe401|alt_cmd_inj)),
CMD_KW("ab", dorn_l2, 255, (void*)(0xe400|alt_cmd_inj|alt_cmd_double)),
CMD_KW("banana", dorn_l3, 255, (void*)(0xe100|alt_cmd_inj)),
CMD_KW("l3", dorn_l3, 255, (void*)(0xe100|alt_cmd_inj)),
CMD_KW("thres", dorn_l1, 255, (void*)(0xa040)),
CMD_KW("l1", dorn_l1, 255, (void*)(0xa040)),
CMD_KW("filter", dorn_l2, 255, (void*)(0xa400)),
CMD_KW("l2", dorn_l2, 255, (void*)(0xa400)),
CMD_KW("a", dorn_l2, 255, (void*)(0xa400)),
CMD_KW("b", dorn_l2, 255, (void*)(0xa401)),
CMD_KW("banana", dorn_l3, 255, (void*)(0xa100)),
CMD_KW("l3", dorn_l3, 255, (void*)(0xa100)),
{"", {.par=&parser_unknown_command}}
};

View file

@ -405,7 +405,7 @@ error_msg_t parse_expression_square(struct command *cmd, unsigned int *r, int op
error_msg_t parse_index(struct command *cmd, unsigned int *r, unsigned int m, unsigned int b, int optional)
{
unsigned int a = 0;
unsigned int a;
error_msg_t e = parse_expression_square(cmd, &a, optional);
if (!e && a > m)
e = &parser_value_error;