Compare commits

..

No commits in common. "142da6bbb0602610fa0372bcbdeb24c822fbdb55" and "6ad8702936b2a51b8098336351860320010f1dcf" have entirely different histories.

3 changed files with 13 additions and 17 deletions

View file

@ -105,16 +105,13 @@ static int read_auto_cb(struct ads8688_control *c)
ads8688_readings(c, cc, i++, ii); ads8688_readings(c, cc, i++, ii);
return alldone_cb(c); return alldone_cb(c);
} }
unsigned int n = c->nbuf; if (c->frame == 0)
if (c->frame == 0) {
n = 0;
c->frame = 0x0300 | c->channels & 0xff; c->frame = 0x0300 | c->channels & 0xff;
} else if ((c->frame & 0xff) == 0x03)
else if ((c->frame & 0xff) == 0x03)
c->frame = 0xa000; c->frame = 0xa000;
else else
return tcnh_cb(c); return tcnh_cb(c);
ssp_set_buffer(0, n); ssp_set_buffer(0, c->nbuf);
return ssp_submit_batch(&c->frame, 1, 2, 0, 0); return ssp_submit_batch(&c->frame, 1, 2, 0, 0);
} }
@ -146,7 +143,6 @@ static int gains_cb(struct ads8688_control *c)
c->frame = cc + 5 << 9; c->frame = cc + 5 << 9;
if (f & 0x100) if (f & 0x100)
c->frame |= 0x100 | c->gains >> 4*cc; c->frame |= 0x100 | c->gains >> 4*cc;
ssp_set_buffer(0, 1);
return 0; return 0;
} }
@ -185,6 +181,7 @@ static int ads8688_start(int nskip, int nread)
c->status = 0x100; c->status = 0x100;
c->job.command = &c->frame; c->job.command = &c->frame;
c->job.count = 1 + nskip + nread; c->job.count = 1 + nskip + nread;
c->job.idle_frame = 0;
c->match.frame_count = nskip; c->match.frame_count = nskip;
c->match.read_count = nread; c->match.read_count = nread;
return ssp_start_batch(ads8688_batch, 0); return ssp_start_batch(ads8688_batch, 0);
@ -207,6 +204,7 @@ int adc_gains_cmd(struct command *cmd, const struct command_par *par)
} }
unsigned int newgains = c->gains; // volatile unsigned int newgains = c->gains; // volatile
c->nbuf = 8;
c->job.cmd_count = 1; c->job.cmd_count = 1;
c->callback = gains_cb; c->callback = gains_cb;
int r = ads8688_start(1, 1); int r = ads8688_start(1, 1);
@ -239,7 +237,6 @@ int adc_read_cmd(struct command *cmd, const struct command_par *par)
c->callback = read_auto_cb; c->callback = read_auto_cb;
} }
c->job.cmd_count = 0; // idle_frame = continue command c->job.cmd_count = 0; // idle_frame = continue command
c->nbuf = NSCRATCH;
int r = ads8688_start(aidx+1, 1); int r = ads8688_start(aidx+1, 1);
int code = par->code; int code = par->code;
if (r) if (r)
@ -265,7 +262,7 @@ int adc_print_cmd(struct command *cmd, const struct command_par *par)
FLAG_VAL("abort", 0x04000000), FLAG_VAL("abort", 0x04000000),
{} {}
}; };
unsigned int chs = (unsigned int)par->par; unsigned int chs = 0;
error_msg_t e = parse_flags(cmd, kw, &chs); error_msg_t e = parse_flags(cmd, kw, &chs);
if (e) if (e)
return parser_error_message(cmd, e); return parser_error_message(cmd, e);
@ -470,6 +467,5 @@ const struct keywords adc_commands[] = {
CMD_KW("gains", adc_gains_cmd, 372, 0), CMD_KW("gains", adc_gains_cmd, 372, 0),
CMD_KW("read", adc_read_cmd, 374, 0), CMD_KW("read", adc_read_cmd, 374, 0),
CMD_KW("print", adc_print_cmd, 376, 0), CMD_KW("print", adc_print_cmd, 376, 0),
CMD_KWF("status",adc_print_cmd, 376, 0x01000000),
CMD_END CMD_END
}; };

View file

@ -10,7 +10,7 @@ int ltc2656(unsigned int frame, int flags, int timeout)
else else
ssp_deassert_ssel(); ssp_deassert_ssel();
ssp_assert_ssel(); ssp_assert_ssel();
ssp_set_buffer(0, -1); ssp_set_buffer(0,0);
unsigned short cmd[2] = { frame >> 16, frame & 0xffff }; unsigned short cmd[2] = { frame >> 16, frame & 0xffff };
ssp_submit(cmd, 2, 2, 0); ssp_submit(cmd, 2, 2, 0);
int r = ssp_wait(timeout); int r = ssp_wait(timeout);

12
ssp.c
View file

@ -29,8 +29,8 @@ void ssp_set_buffer(short *buf, unsigned int size)
volatile struct ssp_job *j=&job; volatile struct ssp_job *j=&job;
if (!buf) { if (!buf) {
buf = ssp_scratch; buf = ssp_scratch;
if (size > NSCRATCH) if (!size || size > sizeof(ssp_scratch)/2)
size = NSCRATCH; size = sizeof(ssp_scratch)/2;
} }
ssp_buffer = (unsigned short *)buf; ssp_buffer = (unsigned short *)buf;
j->buf_ptr = (unsigned short *)buf; j->buf_ptr = (unsigned short *)buf;
@ -184,8 +184,8 @@ int ssp_submit_job(const struct ssp_job *jj)
{ {
unsigned int iflg = disable_irq(INT_DISABLE); unsigned int iflg = disable_irq(INT_DISABLE);
memcpy((void*)&job, jj, sizeof(job)-8); memcpy((void*)&job, jj, sizeof(job)-8);
if (jj->buf_count) if (jj->buf_ptr || jj->buf_count)
ssp_set_buffer(jj->buf_ptr, jj->buf_count); ssp_set_buffer(0, jj->buf_count);
ssp_frames_sent = 0; ssp_frames_sent = 0;
ssp_frames_read = 0; ssp_frames_read = 0;
ssp_callback = ssp_run_batch; ssp_callback = ssp_run_batch;
@ -333,7 +333,7 @@ int ssp_run_batch()
ssp_init(batch->ssel); ssp_init(batch->ssel);
if (f & ssp_b_scratch) if (f & ssp_b_scratch)
ssp_set_buffer(0, -1); ssp_set_buffer(0, 0);
if (c == ssp_b_buffer) if (c == ssp_b_buffer)
ssp_set_buffer(batch->buffer, f & 0xffff); ssp_set_buffer(batch->buffer, f & 0xffff);
@ -618,7 +618,7 @@ int ssp_send_cmd(struct command *cmd, const struct command_par *par)
if (frames < reads) if (frames < reads)
frames = reads; frames = reads;
} }
ssp_set_buffer(0, -1); ssp_set_buffer(0,0);
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);