Compare commits

...

2 commits

Author SHA1 Message Date
Stephan I. Böttcher
99af9d8e52 ssp/response 2024-11-08 21:04:53 +01:00
Stephan I. Böttcher
d2510b344b fix adc/status 2024-11-08 21:02:43 +01:00
3 changed files with 72 additions and 3 deletions

View file

@ -286,7 +286,7 @@ int adc_print_cmd(struct command *cmd, const struct command_par *par)
else else
c->status |= 0xA0000000 | rr<<20; c->status |= 0xA0000000 | rr<<20;
} }
if (what & 0x01000000 || c) { if (what & 0x01000000 || r) {
if (r) if (r)
code++; code++;
parser_format_message(cmd, "%03d busy: 0x%x status: 0x%08x\n", parser_format_message(cmd, "%03d busy: 0x%x status: 0x%08x\n",

70
ssp.c
View file

@ -7,6 +7,7 @@
#include "ssp.h" #include "ssp.h"
#include "isr.h" #include "isr.h"
#include "expression.h" #include "expression.h"
#include "message.h"
// The SSP keeps its state in these private static variables. // The SSP keeps its state in these private static variables.
// The interface is through public functions. // The interface is through public functions.
@ -583,7 +584,7 @@ int ssp_read_cmd(struct command *cmd, const struct command_par *par)
} }
if (what & 0x02000000) { if (what & 0x02000000) {
value = what & 0x40 ? 0xffff : 0; value = what & 0x40 ? 0xffff : 0;
if (!(what & 0x80)) if (!(what & 0xc0))
e = parse_expression_square(cmd, &value, 0); e = parse_expression_square(cmd, &value, 0);
if (e) goto error; if (e) goto error;
job.idle_frame = value; job.idle_frame = value;
@ -603,6 +604,8 @@ error:
return parser_error_message(cmd, e); return parser_error_message(cmd, e);
} }
static unsigned int nreads;
int ssp_send_cmd(struct command *cmd, const struct command_par *par) int ssp_send_cmd(struct command *cmd, const struct command_par *par)
{ {
unsigned int n = 0; unsigned int n = 0;
@ -619,15 +622,80 @@ int ssp_send_cmd(struct command *cmd, const struct command_par *par)
frames = reads; frames = reads;
} }
ssp_set_buffer(0, -1); ssp_set_buffer(0, -1);
nreads = reads;
int c = ssp_submit(ssp_scratch, n, frames, reads); int c = ssp_submit(ssp_scratch, n, frames, reads);
parser_format_message(cmd, "%03d ssp %d frames %dw %dr → %d\n", parser_format_message(cmd, "%03d ssp %d frames %dw %dr → %d\n",
par->code, frames, n, reads, c); par->code, frames, n, reads, c);
return par->code; return par->code;
} }
unsigned int ssp_timeout;
const struct keywords ssp_resp_kw[] = {
FLAG_VAL("all", 0x000001ff),
FLAG_VAL("aux", 0x00000100),
FLAG_VAL("status", 0x01000000),
FLAG_VAL("wait", 0x02000000),
FLAG_VAL("send", 0x00010000),
FLAG_VAL("msg", 0x00020000),
FLAG_VAL("force", 0x00100000),
FLAG_VAL("abort", 0x04000000),
{}
};
int ssp_resp_cmd(struct command *cmd, const struct command_par *par)
{
int code = par->code;
unsigned int what = (unsigned int)par->par;
error_msg_t e = parse_flags(cmd, ssp_resp_kw + 2, &what);
if (e)
return parser_error_message(cmd, e);
if (what & 0x07000000) {
int r = 0;
if (what & 0x02000000) {
parse_expression_square(cmd, &ssp_timeout, 1);
r = ssp_wait(ssp_timeout);
}
else
r = ssp_busy();
if (r && what & 0x04000000) {
ssp_abort_batch(0);
}
if (what & 0x01000000 || r) {
if (r)
code++;
parser_format_message(cmd, "%03d ssp busy: 0x%x\n",
code, r);
return code;
}
}
static const char fmt[] = "%03d ssp [%d] %04x %04x %04x %04x %04x %04x %04x %04x\n";
if (what & 0x00020000)
message(MSG_PRIO_INFO, fmt+5, nreads,
ssp_buffer[0], ssp_buffer[1], ssp_buffer[2], ssp_buffer[3],
ssp_buffer[4], ssp_buffer[5], ssp_buffer[6], ssp_buffer[7]);
if (what & 0x00010000) {
printf(printf_partial, "SSP %d 0x%04x", nreads, ssp_buffer[0]);
for (unsigned int i=1; i<nreads; i++)
printf(printf_partial, " 0x%04x", ssp_buffer[i]);
printf(0, "\n");
}
parser_format_message(cmd, fmt, par->code, nreads,
ssp_buffer[0], ssp_buffer[1], ssp_buffer[2], ssp_buffer[3],
ssp_buffer[4], ssp_buffer[5], ssp_buffer[6], ssp_buffer[7]);
return code;
}
const struct keywords ssp_commands[] = { const struct keywords ssp_commands[] = {
CMD_KW("config", ssp_ssel_cmd, 350, 0), CMD_KW("config", ssp_ssel_cmd, 350, 0),
CMD_KW("reads", ssp_read_cmd, 352, 0), CMD_KW("reads", ssp_read_cmd, 352, 0),
CMD_KW("send", ssp_send_cmd, 354, 0), CMD_KW("send", ssp_send_cmd, 354, 0),
CMD_KW("response", ssp_resp_cmd, 356, 0),
CMD_KWF("status", ssp_resp_cmd, 356, 0x01000000),
CMD_END CMD_END
}; };

3
ssp.h
View file

@ -150,7 +150,8 @@ int ssp_run_batch();
int ssp_abort_batch(const struct ssp_batch *batch); int ssp_abort_batch(const struct ssp_batch *batch);
extern const struct keywords ssp_variable_names[]; extern const struct keywords ssp_variable_names[];
extern unsigned int ssp_timeout;
extern const struct keywords ssp_resp_kw[];
error_msg_t ssp_error(const char *m, int c); error_msg_t ssp_error(const char *m, int c);
extern const struct keywords ssp_commands[]; extern const struct keywords ssp_commands[];